|
10 | 10 | $current_dir = File.expand_path(File.dirname(__FILE__))
|
11 | 11 | $:.unshift File.expand_path(File.join($current_dir, ".."))
|
12 | 12 |
|
13 |
| -gem "coderay", "<1.0" |
14 | 13 | require 'lib/coderay_bash'
|
15 | 14 |
|
16 | 15 | class TestErbBash < Test::Unit::TestCase
|
17 | 16 | def test_0010_ErbBash
|
18 | 17 | eb_file = File.join($current_dir, "erb_bash.sh")
|
19 | 18 | assert_equal(
|
20 |
| - [["#!/bin/sh", :directive], |
21 |
| - ["\n", :end_line], |
22 |
| - ["\n", :end_line], |
23 |
| - ["perl", :ident], |
24 |
| - [" ", :space], |
25 |
| - ["-", :operator], |
26 |
| - ["e", :ident], |
27 |
| - ["'s/to=5/to=10/'", :string], |
28 |
| - [" ", :space], |
29 |
| - ["/", :plain], |
30 |
| - ["test", :method], |
31 |
| - ["/", :plain], |
32 |
| - ["file", :ident], |
33 |
| - ["\n", :end_line], |
34 |
| - ["echo", :method], |
35 |
| - [" ", :space], |
36 |
| - [:open, :string], |
37 |
| - ["\"", :delimiter], |
38 |
| - ["Parsed at ", :content], |
39 |
| - [:open, :inline], |
40 |
| - ["<%=", :inline_delimiter], |
41 |
| - [" ", :space], |
42 |
| - ["Time", :constant], |
43 |
| - [".", :operator], |
44 |
| - ["now", :ident], |
45 |
| - [" ", :space], |
46 |
| - ["%>", :inline_delimiter], |
47 |
| - [:close, :inline], |
48 |
| - ["\"", :delimiter], |
49 |
| - [:close, :string], |
50 |
| - ["\n", :end_line], |
51 |
| - ["echo", :method], |
52 |
| - [" ", :space], |
53 |
| - [:open, :string], |
54 |
| - ["\"", :delimiter], |
55 |
| - ["Executed at `Date`", :content], |
56 |
| - ["\"", :delimiter], |
57 |
| - [:close, :string], |
58 |
| - ["\n", :end_line], |
59 |
| - ["command", :method], |
60 |
| - [" ", :space], |
61 |
| - [">>>>>'open quote<<<<<", :error], |
62 |
| - ["\n", :end_line], |
63 |
| - ["other_command", :ident], |
64 |
| - ["\n", :end_line] |
65 |
| - ], |
66 |
| - CodeRay.scan(File.read(eb_file), :erb_bash, :ignore_errors => false)) |
| 19 | + ["#!/bin/sh", :directive, "\n", :end_line, "\n", :end_line, "perl", :ident, " ", :space, "-", :operator, "e", :ident, "'s/to=5/to=10/'", :string, " ", :space, "/", :plain, "test", :method, "/", :plain, "file", :ident, "\n", :end_line, "echo", :method, " ", :space, :begin_group, :string, "\"", :delimiter, "Parsed at ", :content, :begin_group, :inline, "<%=", :inline_delimiter, " ", :space, "Time", :constant, ".", :operator, "now", :ident, " ", :space, "%>", :inline_delimiter, :end_group, :inline, "\"", :delimiter, :end_group, :string, "\n", :end_line, "echo", :method, " ", :space, :begin_group, :string, "\"", :delimiter, "Executed at `Date`", :content, "\"", :delimiter, :end_group, :string, "\n", :end_line, "command", :method, " ", :space, ">>>>>'open quote<<<<<", :error, "\n", :end_line, "other_command", :ident, "\n", :end_line], |
| 20 | + CodeRay.scan(File.read(eb_file), :erb_bash, :ignore_errors => false).tokens |
| 21 | + ) |
67 | 22 | end
|
68 | 23 |
|
69 | 24 | def test_0011_ErbBash_Ignoring_Errors
|
70 | 25 | eb_file = File.join($current_dir, "erb_bash.sh")
|
71 |
| - assert_equal( |
72 |
| - [["#!/bin/sh", :directive], |
73 |
| - ["\n", :end_line], |
74 |
| - ["\n", :end_line], |
75 |
| - ["perl", :ident], |
76 |
| - [" ", :space], |
77 |
| - ["-", :operator], |
78 |
| - ["e", :ident], |
79 |
| - ["'s/to=5/to=10/'", :string], |
80 |
| - [" ", :space], |
81 |
| - ["/", :plain], |
82 |
| - ["test", :method], |
83 |
| - ["/", :plain], |
84 |
| - ["file", :ident], |
85 |
| - ["\n", :end_line], |
86 |
| - ["echo", :method], |
87 |
| - [" ", :space], |
88 |
| - [:open, :string], |
89 |
| - ["\"", :delimiter], |
90 |
| - ["Parsed at ", :content], |
91 |
| - [:open, :inline], |
92 |
| - ["<%=", :inline_delimiter], |
93 |
| - [" ", :space], |
94 |
| - ["Time", :constant], |
95 |
| - [".", :operator], |
96 |
| - ["now", :ident], |
97 |
| - [" ", :space], |
98 |
| - ["%>", :inline_delimiter], |
99 |
| - [:close, :inline], |
100 |
| - ["\"", :delimiter], |
101 |
| - [:close, :string], |
102 |
| - ["\n", :end_line], |
103 |
| - ["echo", :method], |
104 |
| - [" ", :space], |
105 |
| - [:open, :string], |
106 |
| - ["\"", :delimiter], |
107 |
| - ["Executed at `Date`", :content], |
108 |
| - ["\"", :delimiter], |
109 |
| - [:close, :string], |
110 |
| - ["\n", :end_line], |
111 |
| - ["command", :method], |
112 |
| - [" ", :space], |
113 |
| - ["'open quote", :plain], |
114 |
| - ["\n", :end_line], |
115 |
| - ["other_command", :ident], |
116 |
| - ["\n", :end_line] |
117 |
| - ], |
118 |
| - CodeRay.scan(File.read(eb_file), :erb_bash)) |
| 26 | + assert_equal( |
| 27 | + ["#!/bin/sh", :directive, "\n", :end_line, "\n", :end_line, "perl", :ident, " ", :space, "-", :operator, "e", :ident, "'s/to=5/to=10/'", :string, " ", :space, "/", :plain, "test", :method, "/", :plain, "file", :ident, "\n", :end_line, "echo", :method, " ", :space, :begin_group, :string, "\"", :delimiter, "Parsed at ", :content, :begin_group, :inline, "<%=", :inline_delimiter, " ", :space, "Time", :constant, ".", :operator, "now", :ident, " ", :space, "%>", :inline_delimiter, :end_group, :inline, "\"", :delimiter, :end_group, :string, "\n", :end_line, "echo", :method, " ", :space, :begin_group, :string, "\"", :delimiter, "Executed at `Date`", :content, "\"", :delimiter, :end_group, :string, "\n", :end_line, "command", :method, " ", :space, "'open quote", :plain, "\n", :end_line, "other_command", :ident, "\n", :end_line], |
| 28 | + CodeRay.scan(File.read(eb_file), :erb_bash).tokens |
| 29 | + ) |
119 | 30 | end
|
120 | 31 |
|
121 | 32 | end
|
0 commit comments