-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.rb
107 lines (101 loc) · 3.22 KB
/
tests.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
require 'test/unit'
require './methods.rb'
class RegexTest < Test::Unit::TestCase
def test_show_regex
pass = [
'show welcome',
'show login',
'show data1',
'show Doctors_Qs',
'show men_other_symptoms if (Doctors_Qs.men_headache = "men_yes")',
'show s1pg09afyc if (warning)',
]
fail = [
'show st_pA1b.selected1 if (st_condition1)',
'show st_pA1c.advice1',
'show FAQpain.female if (gender = "female")',
'show',
'set default s2reasons.reason1 to load reasonstoloseweight.reason1 for username',
'begin faqsmenusection'
]
pass.each { |input| assert_equal true, show_token?(input) }
fail.each { |input| assert_equal nil, show_token?(input) }
end
def test_after_regex
pass = [
'after register if (makenewuser(register.username, register.password)) goto login',
'after Safety_Qs_fine if (Safety_Qs_fine.d_q_symptom = "cough") goto cough',
'after signupconfirm if (loadvalue(username, "group") = "intervention") goto baseline1a',
'after s6increase if (paplan = "walk") goto s6benefitswalking',
]
fail = [
'after foo',
'after foo ',
'after page if page goto page',
'after page goto anotherpage',
'show',
'set default s2reasons.reason1 to load reasonstoloseweight.reason1 for username',
'begin faqsmenusection'
]
pass.each { |input| assert_equal true, after_token?(input) }
fail.each { |input| assert_equal nil, after_token?(input) }
end
def test_section_begin_regex
pass = [
'begin session2optionalsection2',
'begin section session2optionalsection2',
'begin introduction',
'begin section introduction',
'begin',
'begin section'
]
fail = [
'#begin section',
'end'
]
pass.each { |input| assert_equal true, begin_token?(input) }
fail.each { |input| assert_equal nil, begin_token?(input) }
end
def test_section_end_regex
pass = [
'end',
'end section',
'end section foo'
]
fail = [
'#end',
'#end section',
'begin'
]
pass.each { |input| assert_equal true, end_token?(input) }
fail.each { |input| assert_equal nil, end_token?(input) }
end
def test_jumpto_link_regex
pass = [
'<a href="?jumpto=pW1">',
'<a href="?jumpto=Doctors_Qs">',
'<a class="popup" href="?jumpto=pT1advice3FightInfection">',
'<a id="foo" class="popup" href="?jumpto=pT1advice3FightInfection">'
]
fail = [
'<a href="somewhereelse.co.uk">',
'<a href="jumpto.co.uk">',
'<a class="?jumpto=foo">'
]
pass.each { |input| assert_equal true, jumpto_link_token?(input) }
fail.each { |input| assert_equal nil, jumpto_link_token?(input) }
end
def test_div_link_regex
pass = [
'<div id="button-1" class="submit-jumpto-button" label="welcome">',
'<div id="button-2" class="submit-jumpto-button" label="login">'
]
fail = [
'<div id="foo" class="submit-jumpto-button">',
'<div id="foo" label="foo">',
'<div id="button-3" class="jumpto-button">'
]
pass.each { |input| assert_equal true, div_link_token?(input) }
fail.each { |input| assert_equal nil, div_link_token?(input) }
end
end