kwartz 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -0
- data/ChangeLog +103 -0
- data/README.txt +37 -0
- data/bin/kwartz +12 -0
- data/doc-api/classes/Kwartz.html +218 -0
- data/doc-api/classes/Kwartz/Assertion.html +140 -0
- data/doc-api/classes/Kwartz/AssertionError.html +148 -0
- data/doc-api/classes/Kwartz/AttrInfo.html +320 -0
- data/doc-api/classes/Kwartz/BaseError.html +206 -0
- data/doc-api/classes/Kwartz/BaseTranslator.html +331 -0
- data/doc-api/classes/Kwartz/CharacterType.html +212 -0
- data/doc-api/classes/Kwartz/CommandOptionError.html +154 -0
- data/doc-api/classes/Kwartz/CommandOptions.html +374 -0
- data/doc-api/classes/Kwartz/Config.html +150 -0
- data/doc-api/classes/Kwartz/ConvertError.html +191 -0
- data/doc-api/classes/Kwartz/Converter.html +252 -0
- data/doc-api/classes/Kwartz/CssStyleParser.html +483 -0
- data/doc-api/classes/Kwartz/DocumentRuleset.html +369 -0
- data/doc-api/classes/Kwartz/ElementExpander.html +325 -0
- data/doc-api/classes/Kwartz/ElementInfo.html +312 -0
- data/doc-api/classes/Kwartz/ElementRuleset.html +582 -0
- data/doc-api/classes/Kwartz/EperlHandler.html +338 -0
- data/doc-api/classes/Kwartz/EperlTranslator.html +167 -0
- data/doc-api/classes/Kwartz/ErubisHandler.html +113 -0
- data/doc-api/classes/Kwartz/ErubisTranslator.html +168 -0
- data/doc-api/classes/Kwartz/ErubyHandler.html +337 -0
- data/doc-api/classes/Kwartz/ErubyTranslator.html +167 -0
- data/doc-api/classes/Kwartz/ExpandStatement.html +227 -0
- data/doc-api/classes/Kwartz/Expression.html +119 -0
- data/doc-api/classes/Kwartz/Handler.html +558 -0
- data/doc-api/classes/Kwartz/JstlHandler.html +657 -0
- data/doc-api/classes/Kwartz/JstlTranslator.html +226 -0
- data/doc-api/classes/Kwartz/KwartzError.html +146 -0
- data/doc-api/classes/Kwartz/Main.html +384 -0
- data/doc-api/classes/Kwartz/NativeExpression.html +236 -0
- data/doc-api/classes/Kwartz/NativeStatement.html +254 -0
- data/doc-api/classes/Kwartz/Node.html +156 -0
- data/doc-api/classes/Kwartz/ParseError.html +148 -0
- data/doc-api/classes/Kwartz/PhpHandler.html +333 -0
- data/doc-api/classes/Kwartz/PhpTranslator.html +194 -0
- data/doc-api/classes/Kwartz/PresentationLogicParser.html +830 -0
- data/doc-api/classes/Kwartz/PrintStatement.html +221 -0
- data/doc-api/classes/Kwartz/RailsHandler.html +587 -0
- data/doc-api/classes/Kwartz/RailsTranslator.html +167 -0
- data/doc-api/classes/Kwartz/RubyStyleParser.html +558 -0
- data/doc-api/classes/Kwartz/Ruleset.html +117 -0
- data/doc-api/classes/Kwartz/Statement.html +119 -0
- data/doc-api/classes/Kwartz/StrutsTranslator.html +190 -0
- data/doc-api/classes/Kwartz/TagInfo.html +314 -0
- data/doc-api/classes/Kwartz/TextConverter.html +270 -0
- data/doc-api/classes/Kwartz/Translator.html +318 -0
- data/doc-api/classes/Test.html +107 -0
- data/doc-api/classes/Test/Unit.html +101 -0
- data/doc-api/created.rid +1 -0
- data/doc-api/files/__/README_txt.html +150 -0
- data/doc-api/files/kwartz/assert_rb.html +114 -0
- data/doc-api/files/kwartz/binding/eperl_rb.html +116 -0
- data/doc-api/files/kwartz/binding/erubis_rb.html +116 -0
- data/doc-api/files/kwartz/binding/eruby_rb.html +115 -0
- data/doc-api/files/kwartz/binding/jstl_rb.html +116 -0
- data/doc-api/files/kwartz/binding/php_rb.html +116 -0
- data/doc-api/files/kwartz/binding/rails_rb.html +115 -0
- data/doc-api/files/kwartz/binding/struts_rb.html +117 -0
- data/doc-api/files/kwartz/config_rb.html +107 -0
- data/doc-api/files/kwartz/converter_rb.html +119 -0
- data/doc-api/files/kwartz/error_rb.html +107 -0
- data/doc-api/files/kwartz/main_rb.html +124 -0
- data/doc-api/files/kwartz/node_rb.html +114 -0
- data/doc-api/files/kwartz/parser_rb.html +117 -0
- data/doc-api/files/kwartz/translator_rb.html +115 -0
- data/doc-api/files/kwartz/util/assert-text-equal_rb.html +115 -0
- data/doc-api/files/kwartz/util/testcase-helper_rb.html +115 -0
- data/doc-api/files/kwartz_rb.html +120 -0
- data/doc-api/fr_class_index.html +75 -0
- data/doc-api/fr_file_index.html +45 -0
- data/doc-api/fr_method_index.html +216 -0
- data/doc-api/index.html +24 -0
- data/doc-api/rdoc-style.css +208 -0
- data/doc/docstyle.css +188 -0
- data/doc/p-pattern.html +1207 -0
- data/doc/reference.html +3396 -0
- data/doc/users-guide.html +1670 -0
- data/examples/breadcrumbs1/Makefile +15 -0
- data/examples/breadcrumbs1/breadcrumbs.eruby.plogic +27 -0
- data/examples/breadcrumbs1/breadcrumbs.html +12 -0
- data/examples/breadcrumbs1/breadcrumbs.jstl.plogic +28 -0
- data/examples/breadcrumbs1/breadcrumbs.php.plogic +26 -0
- data/examples/breadcrumbs1/main.php +12 -0
- data/examples/breadcrumbs1/main.rb +12 -0
- data/examples/breadcrumbs2/Makefile +15 -0
- data/examples/breadcrumbs2/breadcrumbs.eruby.plogic +22 -0
- data/examples/breadcrumbs2/breadcrumbs.html +14 -0
- data/examples/breadcrumbs2/breadcrumbs.jstl.plogic +24 -0
- data/examples/breadcrumbs2/breadcrumbs.php.plogic +23 -0
- data/examples/breadcrumbs2/main.php +12 -0
- data/examples/breadcrumbs2/main.rb +12 -0
- data/examples/pagelayout/Makefile +47 -0
- data/examples/pagelayout/content.eruby.plogic +44 -0
- data/examples/pagelayout/content.jstl.plogic +36 -0
- data/examples/pagelayout/content.php.plogic +37 -0
- data/examples/pagelayout/content1.html +36 -0
- data/examples/pagelayout/content2.html +29 -0
- data/examples/pagelayout/design.css +40 -0
- data/examples/pagelayout/layout.html +50 -0
- data/examples/pagelayout/main.php +55 -0
- data/examples/pagelayout/main.rb +77 -0
- data/examples/pagelayout/menu.eruby.plogic +14 -0
- data/examples/pagelayout/menu.html +13 -0
- data/examples/pagelayout/menu.jstl.plogic +14 -0
- data/examples/pagelayout/menu.php.plogic +14 -0
- data/examples/rails1/Makefile +36 -0
- data/examples/rails1/README +19 -0
- data/examples/rails1/application_helper.rb +31 -0
- data/examples/rails1/edit.html +28 -0
- data/examples/rails1/edit.plogic +10 -0
- data/examples/rails1/form.html +52 -0
- data/examples/rails1/form.plogic +33 -0
- data/examples/rails1/layout.plogic +15 -0
- data/examples/rails1/link_to.plogic +19 -0
- data/examples/rails1/list.html +48 -0
- data/examples/rails1/list.plogic +28 -0
- data/examples/rails1/new.html +27 -0
- data/examples/rails1/new.plogic +10 -0
- data/examples/rails1/reader.plogic +29 -0
- data/examples/rails1/show.html +40 -0
- data/examples/rails1/show.plogic +4 -0
- data/examples/rails1/writer.plogic +8 -0
- data/examples/table1/Makefile +15 -0
- data/examples/table1/main.php +11 -0
- data/examples/table1/main.rb +11 -0
- data/examples/table1/table1.eruby.plogic +21 -0
- data/examples/table1/table1.html +16 -0
- data/examples/table1/table1.jstl.plogic +21 -0
- data/examples/table1/table1.php.plogic +22 -0
- data/kwartz.gemspec +55 -0
- data/lib/kwartz.rb +13 -0
- data/lib/kwartz/assert.rb +31 -0
- data/lib/kwartz/binding/eperl.rb +166 -0
- data/lib/kwartz/binding/erubis.rb +61 -0
- data/lib/kwartz/binding/eruby.rb +164 -0
- data/lib/kwartz/binding/jstl.rb +334 -0
- data/lib/kwartz/binding/php.rb +167 -0
- data/lib/kwartz/binding/rails.rb +295 -0
- data/lib/kwartz/binding/struts.rb +109 -0
- data/lib/kwartz/config.rb +28 -0
- data/lib/kwartz/converter.rb +920 -0
- data/lib/kwartz/error.rb +41 -0
- data/lib/kwartz/main.rb +464 -0
- data/lib/kwartz/node.rb +454 -0
- data/lib/kwartz/parser.rb +903 -0
- data/lib/kwartz/translator.rb +153 -0
- data/lib/kwartz/util/assert-text-equal.rb +44 -0
- data/lib/kwartz/util/testcase-helper.rb +112 -0
- data/setup.rb +1331 -0
- data/test/test-compile.rb +36 -0
- data/test/test-compile.yaml +178 -0
- data/test/test-converter.rb +34 -0
- data/test/test-converter.yaml +127 -0
- data/test/test-directives.rb +32 -0
- data/test/test-directives.yaml +1411 -0
- data/test/test-main.rb +464 -0
- data/test/test-parser.rb +54 -0
- data/test/test-parser.yaml +394 -0
- data/test/test-rails.rb +28 -0
- data/test/test-rails.yaml +301 -0
- data/test/test-ruleset.rb +36 -0
- data/test/test-ruleset.yaml +804 -0
- data/test/test.rb +44 -0
- metadata +236 -0
data/test/test-parser.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
###
|
2
|
+
### $Rev: 117 $
|
3
|
+
### $Release: 3.0.0 $
|
4
|
+
### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
|
5
|
+
###
|
6
|
+
|
7
|
+
require "#{File.dirname(__FILE__)}/test.rb"
|
8
|
+
|
9
|
+
|
10
|
+
class ParserTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
## define test methods
|
13
|
+
filename = __FILE__.sub(/\.rb$/, '.yaml')
|
14
|
+
load_yaml_testdata(filename)
|
15
|
+
|
16
|
+
def _test
|
17
|
+
begin
|
18
|
+
eval @setup if @setup
|
19
|
+
__test
|
20
|
+
ensure
|
21
|
+
eval @teardown if @teardown
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def __test
|
26
|
+
case @parser
|
27
|
+
when 'RubyStyleParser'
|
28
|
+
parser = Kwartz::RubyStyleParser.new()
|
29
|
+
when 'CssStyleParser'
|
30
|
+
parser = Kwartz::CssStyleParser.new()
|
31
|
+
else
|
32
|
+
raise "*** invalid parser class: #{@parser}"
|
33
|
+
end
|
34
|
+
if @name =~ /scan/
|
35
|
+
actual = ''
|
36
|
+
parser.__send__ :reset, @input
|
37
|
+
while (ret = parser.scan()) != nil
|
38
|
+
actual << "#{parser.linenum}:#{parser.column}:"
|
39
|
+
actual << " token=#{parser.token.inspect}, value=#{parser.value.inspect}\n"
|
40
|
+
break if ret == :error
|
41
|
+
end
|
42
|
+
else
|
43
|
+
rulesets = parser.parse(@input)
|
44
|
+
actual = ''
|
45
|
+
rulesets.each do |ruleset|
|
46
|
+
s = ruleset._inspect(1)
|
47
|
+
s[0] = '-'
|
48
|
+
actual << s
|
49
|
+
end if rulesets
|
50
|
+
end
|
51
|
+
assert_text_equal(@expected, actual)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,394 @@
|
|
1
|
+
---
|
2
|
+
- name: scanner1_css
|
3
|
+
parser: CssStyleParser
|
4
|
+
input: |
|
5
|
+
/* comment */
|
6
|
+
#list {
|
7
|
+
value
|
8
|
+
attrs
|
9
|
+
append
|
10
|
+
logic {
|
11
|
+
}
|
12
|
+
}
|
13
|
+
expected: |
|
14
|
+
2:2: token=35, value="#"
|
15
|
+
2:6: token=:ident, value="list"
|
16
|
+
2:8: token=:"{", value="{"
|
17
|
+
3:8: token=:value, value="value"
|
18
|
+
4:8: token=:attrs, value="attrs"
|
19
|
+
5:9: token=:append, value="append"
|
20
|
+
6:8: token=:logic, value="logic"
|
21
|
+
6:10: token=:"{", value="{"
|
22
|
+
7:4: token=:"}", value="}"
|
23
|
+
8:2: token=:"}", value="}"
|
24
|
+
|
25
|
+
- name: scanner1_ruby
|
26
|
+
parser: RubyStyleParser
|
27
|
+
input: |
|
28
|
+
# comment
|
29
|
+
element "list" {
|
30
|
+
value
|
31
|
+
attrs
|
32
|
+
append
|
33
|
+
logic {
|
34
|
+
}
|
35
|
+
}
|
36
|
+
expected: |
|
37
|
+
2:8: token=:element, value="element"
|
38
|
+
2:15: token=:string, value="list"
|
39
|
+
2:17: token=:"{", value="{"
|
40
|
+
3:8: token=:value, value="value"
|
41
|
+
4:8: token=:attrs, value="attrs"
|
42
|
+
5:9: token=:append, value="append"
|
43
|
+
6:8: token=:logic, value="logic"
|
44
|
+
6:10: token=:"{", value="{"
|
45
|
+
7:4: token=:"}", value="}"
|
46
|
+
8:2: token=:"}", value="}"
|
47
|
+
|
48
|
+
---
|
49
|
+
- name: parse_elem1_css
|
50
|
+
parser: CssStyleParser
|
51
|
+
input: |
|
52
|
+
#list {
|
53
|
+
}
|
54
|
+
expected: &elem1|
|
55
|
+
- name: "list"
|
56
|
+
|
57
|
+
- name: parse_elem1_ruby
|
58
|
+
parser: RubyStyleParser
|
59
|
+
input: |
|
60
|
+
element "list" {
|
61
|
+
}
|
62
|
+
expected: *elem1
|
63
|
+
|
64
|
+
---
|
65
|
+
- name: parse_value_part1_css
|
66
|
+
parser: CssStyleParser
|
67
|
+
desc: value part
|
68
|
+
input: |
|
69
|
+
#list {
|
70
|
+
value: @user['name'];
|
71
|
+
}
|
72
|
+
expected: &value1|
|
73
|
+
- name: "list"
|
74
|
+
cont: "@user['name']"
|
75
|
+
|
76
|
+
- name: parse_value_part1_ruby
|
77
|
+
parser: RubyStyleParser
|
78
|
+
desc: value part
|
79
|
+
input: |
|
80
|
+
element "list" {
|
81
|
+
value @user['name']
|
82
|
+
}
|
83
|
+
expected: *value1
|
84
|
+
|
85
|
+
---
|
86
|
+
- name: parse_attrs_part1_css
|
87
|
+
parser: CssStyleParser
|
88
|
+
input: |
|
89
|
+
#list {
|
90
|
+
attrs: "class" @class,
|
91
|
+
'color' @prop[:color];
|
92
|
+
}
|
93
|
+
expected: &attrs1|
|
94
|
+
- name: "list"
|
95
|
+
attrs:
|
96
|
+
- name: "class"
|
97
|
+
value: "@class"
|
98
|
+
- name: "color"
|
99
|
+
value: "@prop[:color]"
|
100
|
+
|
101
|
+
- name: parse_attrs_part1_ruby
|
102
|
+
parser: RubyStyleParser
|
103
|
+
input: |
|
104
|
+
element "list" {
|
105
|
+
attrs "class"=>@class, 'color' => @prop[:color]
|
106
|
+
}
|
107
|
+
expected: *attrs1
|
108
|
+
|
109
|
+
---
|
110
|
+
- name: parse_append_part1_css
|
111
|
+
parser: CssStyleParser
|
112
|
+
input: |
|
113
|
+
#list1 {
|
114
|
+
append: @name==item['name'] ? " checked='checked'" : '',
|
115
|
+
chk(@name);
|
116
|
+
}
|
117
|
+
#list2 {
|
118
|
+
append: aaa, bbb,ccc;
|
119
|
+
}
|
120
|
+
expected: &append1|
|
121
|
+
- name: "list1"
|
122
|
+
append:
|
123
|
+
- "@name==item['name'] ? \" checked='checked'\" : ''"
|
124
|
+
- "chk(@name)"
|
125
|
+
- name: "list2"
|
126
|
+
append:
|
127
|
+
- "aaa, bbb,ccc"
|
128
|
+
|
129
|
+
- name: parse_append_part1_ruby
|
130
|
+
parser: RubyStyleParser
|
131
|
+
input: |
|
132
|
+
element "list1" {
|
133
|
+
append @name==item['name'] ? " checked='checked'" : '', chk(@name)
|
134
|
+
}
|
135
|
+
element "list2" {
|
136
|
+
append aaa, bbb,ccc
|
137
|
+
}
|
138
|
+
expected: |
|
139
|
+
- name: "list1"
|
140
|
+
append:
|
141
|
+
- "@name==item['name'] ? \" checked='checked'\" : ''"
|
142
|
+
- "chk(@name)"
|
143
|
+
- name: "list2"
|
144
|
+
append:
|
145
|
+
- "aaa"
|
146
|
+
- "bbb,ccc"
|
147
|
+
|
148
|
+
---
|
149
|
+
- name: parse_remove_part1_css
|
150
|
+
parser: CssStyleParser
|
151
|
+
input: |
|
152
|
+
#list {
|
153
|
+
remove: "foo", "bar", 'baz';
|
154
|
+
}
|
155
|
+
expected: &remove1|
|
156
|
+
- name: "list"
|
157
|
+
remove:
|
158
|
+
- "foo"
|
159
|
+
- "bar"
|
160
|
+
- "baz"
|
161
|
+
|
162
|
+
- name: parse_remove_part1_ruby
|
163
|
+
parser: RubyStyleParser
|
164
|
+
input: |
|
165
|
+
element "list" {
|
166
|
+
remove "foo", "bar", 'baz'
|
167
|
+
}
|
168
|
+
expected: *remove1
|
169
|
+
|
170
|
+
---
|
171
|
+
- name: parse_tagname_part1_css
|
172
|
+
parser: CssStyleParser
|
173
|
+
input: |
|
174
|
+
#list {
|
175
|
+
tagname: 'html:html';
|
176
|
+
}
|
177
|
+
expected: &tagname1|
|
178
|
+
- name: "list"
|
179
|
+
tagname: "html:html"
|
180
|
+
|
181
|
+
- name: parse_tagname_part1_ruby
|
182
|
+
parser: RubyStyleParser
|
183
|
+
input: |
|
184
|
+
element "list" {
|
185
|
+
tagname 'html:html'
|
186
|
+
}
|
187
|
+
expected: *tagname1
|
188
|
+
|
189
|
+
---
|
190
|
+
- name: parse_logic_part1_css
|
191
|
+
parser: CssStyleParser
|
192
|
+
input: |
|
193
|
+
#list {
|
194
|
+
logic: {
|
195
|
+
@list.each { |item|
|
196
|
+
_stag
|
197
|
+
_cont
|
198
|
+
_etag
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
expected: &logic1|
|
203
|
+
- name: "list"
|
204
|
+
logic:
|
205
|
+
- " @list.each { |item|"
|
206
|
+
- _stag
|
207
|
+
- _cont
|
208
|
+
- _etag
|
209
|
+
- " }"
|
210
|
+
|
211
|
+
- name: parse_logic_part1_ruby
|
212
|
+
parser: RubyStyleParser
|
213
|
+
input: |
|
214
|
+
element "list" {
|
215
|
+
logic {
|
216
|
+
@list.each { |item|
|
217
|
+
_stag
|
218
|
+
_cont
|
219
|
+
_etag
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
expected: *logic1
|
224
|
+
|
225
|
+
---
|
226
|
+
- name: parse_logic_part2_css
|
227
|
+
parser: CssStyleParser
|
228
|
+
input: |
|
229
|
+
#list {
|
230
|
+
logic: {
|
231
|
+
@list.each_with_index { |item, i|
|
232
|
+
if i % 2 == 0
|
233
|
+
_element("foo")
|
234
|
+
else
|
235
|
+
_content('foo')
|
236
|
+
end
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
expected: &logic2|
|
241
|
+
- name: "list"
|
242
|
+
logic:
|
243
|
+
- " @list.each_with_index { |item, i|"
|
244
|
+
- " if i % 2 == 0"
|
245
|
+
- _element("foo")
|
246
|
+
- " else"
|
247
|
+
- _content("foo")
|
248
|
+
- " end"
|
249
|
+
- " }"
|
250
|
+
|
251
|
+
- name: parse_logic_part2_ruby
|
252
|
+
parser: RubyStyleParser
|
253
|
+
input: |
|
254
|
+
element "list" {
|
255
|
+
logic {
|
256
|
+
@list.each_with_index { |item, i|
|
257
|
+
if i % 2 == 0
|
258
|
+
_element("foo")
|
259
|
+
else
|
260
|
+
_content('foo')
|
261
|
+
end
|
262
|
+
}
|
263
|
+
}
|
264
|
+
}
|
265
|
+
expected: *logic2
|
266
|
+
|
267
|
+
---
|
268
|
+
- name: parse_import_command1_css
|
269
|
+
parser: CssStyleParser
|
270
|
+
input: |
|
271
|
+
@import 'common.plogic';
|
272
|
+
#item {
|
273
|
+
value: item;
|
274
|
+
}
|
275
|
+
expected: |
|
276
|
+
- name: "page_link"
|
277
|
+
cont: "page.label"
|
278
|
+
attrs:
|
279
|
+
- name: "href"
|
280
|
+
value: "page.url"
|
281
|
+
logic:
|
282
|
+
- " if page"
|
283
|
+
- _elem
|
284
|
+
- " end"
|
285
|
+
- name: "item"
|
286
|
+
cont: "item"
|
287
|
+
setup: |
|
288
|
+
common_plogic = <<END
|
289
|
+
#page_link {
|
290
|
+
value: page.label;
|
291
|
+
attrs: 'href' page.url;
|
292
|
+
logic: {
|
293
|
+
if page
|
294
|
+
_elem
|
295
|
+
end
|
296
|
+
}
|
297
|
+
}
|
298
|
+
END
|
299
|
+
File.open('common.plogic', 'w') { |f| f.write(common_plogic) }
|
300
|
+
teardown: |
|
301
|
+
filename = 'common.plogic'
|
302
|
+
File.unlink filename if test(?f, filename)
|
303
|
+
|
304
|
+
---
|
305
|
+
- name: parse_document
|
306
|
+
parser: CssStyleParser
|
307
|
+
input: |
|
308
|
+
#DOCUMENT {
|
309
|
+
local: i, item, title, list;
|
310
|
+
global: _context;
|
311
|
+
begin: {
|
312
|
+
title = _context[:title]
|
313
|
+
list = _context[:list]
|
314
|
+
}
|
315
|
+
end: {
|
316
|
+
print "*** debug:\n"
|
317
|
+
_context.each do |key, value|
|
318
|
+
print "*** key=#{key}, value=#{value.inspect}"
|
319
|
+
end
|
320
|
+
}
|
321
|
+
}
|
322
|
+
expected: |
|
323
|
+
- name: "DOCUMENT"
|
324
|
+
global:
|
325
|
+
- _context
|
326
|
+
local:
|
327
|
+
- i
|
328
|
+
- item
|
329
|
+
- title
|
330
|
+
- list
|
331
|
+
begin:
|
332
|
+
- " title = _context[:title]"
|
333
|
+
- " list = _context[:list]"
|
334
|
+
end:
|
335
|
+
- [ <%="*** debug:\n"%>]
|
336
|
+
- " _context.each do |key, value|"
|
337
|
+
- [ <%="*** key=#{key}, value=#{value.inspect}"%>]
|
338
|
+
- " end"
|
339
|
+
|
340
|
+
|
341
|
+
---
|
342
|
+
- name: parse_element_all1_css
|
343
|
+
parser: CssStyleParser
|
344
|
+
input: |
|
345
|
+
#list {
|
346
|
+
value: item.name;
|
347
|
+
attrs: 'title' item.desc,
|
348
|
+
'class' klass;
|
349
|
+
append: item==current_item ? ' checked="checked"' : '';
|
350
|
+
logic: {
|
351
|
+
@list.each_with_index { |item, i|
|
352
|
+
klass = i % 2 == 0 ? 'even' : 'odd'
|
353
|
+
_stag # start tag
|
354
|
+
_cont # content
|
355
|
+
_etag # end tag
|
356
|
+
}
|
357
|
+
}
|
358
|
+
}
|
359
|
+
expected: &all1|
|
360
|
+
- name: "list"
|
361
|
+
cont: "item.name"
|
362
|
+
attrs:
|
363
|
+
- name: "class"
|
364
|
+
value: "klass"
|
365
|
+
- name: "title"
|
366
|
+
value: "item.desc"
|
367
|
+
append:
|
368
|
+
- "item==current_item ? ' checked=\"checked\"' : ''"
|
369
|
+
logic:
|
370
|
+
- " @list.each_with_index { |item, i|"
|
371
|
+
- " klass = i % 2 == 0 ? 'even' : 'odd'"
|
372
|
+
- _stag
|
373
|
+
- _cont
|
374
|
+
- _etag
|
375
|
+
- " }"
|
376
|
+
|
377
|
+
- name: parse_element_all1_ruby
|
378
|
+
parser: RubyStyleParser
|
379
|
+
input: |
|
380
|
+
element "list" {
|
381
|
+
value item.name
|
382
|
+
attrs 'title'=>item.desc, 'class'=>klass
|
383
|
+
append item==current_item ? ' checked="checked"' : ''
|
384
|
+
logic {
|
385
|
+
@list.each_with_index { |item, i|
|
386
|
+
klass = i % 2 == 0 ? 'even' : 'odd'
|
387
|
+
_stag # start tag
|
388
|
+
_cont # content
|
389
|
+
_etag # end tag
|
390
|
+
}
|
391
|
+
}
|
392
|
+
}
|
393
|
+
expected: *all1
|
394
|
+
|
data/test/test-rails.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
###
|
2
|
+
### $Rev: 114 $
|
3
|
+
### $Release: 3.0.0 $
|
4
|
+
### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
|
5
|
+
###
|
6
|
+
|
7
|
+
require "#{File.dirname(__FILE__)}/test.rb"
|
8
|
+
|
9
|
+
|
10
|
+
class RailsTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
|
13
|
+
## define test methods
|
14
|
+
filename = __FILE__.sub(/\.rb$/, '.yaml')
|
15
|
+
load_yaml_testdata(filename)
|
16
|
+
|
17
|
+
|
18
|
+
def _test
|
19
|
+
handler = Kwartz::Handler.get_class(@binding).new
|
20
|
+
converter = Kwartz::TextConverter.new(handler)
|
21
|
+
stmt_list = converter.convert(@pdata)
|
22
|
+
translator = Kwartz::Translator.get_class(@binding).new
|
23
|
+
actual = translator.translate(stmt_list)
|
24
|
+
assert_text_equal(@expected, actual)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|