2
2
require 'coderay'
3
3
4
4
class HtmlTest < Test ::Unit ::TestCase
5
-
5
+
6
6
def test_independent_lines_option
7
-
8
7
snippets = { }
9
-
8
+
10
9
snippets [ :ruby ] = { }
11
-
10
+
12
11
snippets [ :ruby ] [ :in ] = <<-RUBY
13
12
ruby_inside = <<-RUBY_INSIDE
14
13
This is tricky,
15
14
isn't it?
16
15
RUBY_INSIDE
17
- RUBY
18
-
16
+ RUBY
17
+
19
18
snippets [ :ruby ] [ :expected_with_option_off ] = <<-HTML_OPT_INDEPENDENT_LINES_OFF
20
19
ruby_inside = <span class=\" string\" ><span class=\" delimiter\" ><<-RUBY_INSIDE</span></span><span class=\" string\" ><span class=\" content\" >
21
20
This is tricky,
22
21
isn't it?</span><span class=\" delimiter\" >
23
22
RUBY_INSIDE</span></span>
24
- HTML_OPT_INDEPENDENT_LINES_OFF
25
-
23
+ HTML_OPT_INDEPENDENT_LINES_OFF
24
+
26
25
snippets [ :ruby ] [ :expected_with_option_on ] = <<-HTML_OPT_INDEPENDENT_LINES_ON
27
26
ruby_inside = <span class=\" string\" ><span class=\" delimiter\" ><<-RUBY_INSIDE</span></span><span class=\" string\" ><span class=\" content\" ></span></span>
28
27
<span class=\" string\" ><span class=\" content\" >This is tricky,</span></span>
29
28
<span class=\" string\" ><span class=\" content\" >isn't it?</span><span class=\" delimiter\" ></span></span>
30
29
<span class=\" string\" ><span class=\" delimiter\" >RUBY_INSIDE</span></span>
31
- HTML_OPT_INDEPENDENT_LINES_ON
32
-
30
+ HTML_OPT_INDEPENDENT_LINES_ON
31
+
33
32
snippets [ :java ] = { }
34
-
33
+
35
34
snippets [ :java ] [ :in ] = <<-JAVA
36
35
import java.lang.*;
37
36
@@ -51,8 +50,8 @@ def test_independent_lines_option
51
50
System.out.println(MESSAGE);
52
51
}
53
52
}
54
- JAVA
55
-
53
+ JAVA
54
+
56
55
snippets [ :java ] [ :expected_with_option_off ] = <<-HTML_OPT_INDEPENDENT_LINES_OFF
57
56
<span class=\" keyword\" >import</span> <span class=\" include\" >java.lang</span>.*;
58
57
@@ -71,8 +70,8 @@ def test_independent_lines_option
71
70
<span class=\" predefined-type\" >System</span>.out.println(MESSAGE);
72
71
}
73
72
}
74
- HTML_OPT_INDEPENDENT_LINES_OFF
75
-
73
+ HTML_OPT_INDEPENDENT_LINES_OFF
74
+
76
75
snippets [ :java ] [ :expected_with_option_on ] = <<-HTML_OPT_INDEPENDENT_LINES_ON
77
76
<span class=\" keyword\" >import</span> <span class=\" include\" >java.lang</span>.*;
78
77
@@ -91,14 +90,14 @@ def test_independent_lines_option
91
90
<span class=\" predefined-type\" >System</span>.out.println(MESSAGE);
92
91
}
93
92
}
94
- HTML_OPT_INDEPENDENT_LINES_ON
95
-
96
- snippets . entries ( ) . each do | lang , code |
93
+ HTML_OPT_INDEPENDENT_LINES_ON
94
+
95
+ for lang , code in snippets
97
96
tokens = CodeRay . scan code [ :in ] , lang
98
-
97
+
99
98
assert_equal code [ :expected_with_option_off ] , tokens . html
100
99
assert_equal code [ :expected_with_option_off ] , tokens . html ( :independent_lines => false )
101
100
assert_equal code [ :expected_with_option_on ] , tokens . html ( :independent_lines => true )
102
101
end
103
102
end
104
- end
103
+ end
0 commit comments