rtext 0.9.0 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +113 -98
  3. data/Project.yaml +14 -0
  4. data/RText_Protocol +1 -1
  5. data/lib/rtext/default_completer.rb +212 -208
  6. data/lib/rtext/frontend/connector.rb +122 -55
  7. data/lib/rtext/instantiator.rb +11 -3
  8. data/lib/rtext/service.rb +264 -260
  9. metadata +18 -44
  10. data/Rakefile +0 -46
  11. data/test/completer_test.rb +0 -607
  12. data/test/context_builder_test.rb +0 -949
  13. data/test/frontend/context_test.rb +0 -302
  14. data/test/instantiator_test.rb +0 -1733
  15. data/test/integration/backend.out +0 -16
  16. data/test/integration/crash_on_request_editor.rb +0 -12
  17. data/test/integration/ecore_editor.rb +0 -50
  18. data/test/integration/frontend.log +0 -40058
  19. data/test/integration/model/invalid_encoding.invenc +0 -2
  20. data/test/integration/model/test.crash_on_request +0 -18
  21. data/test/integration/model/test.crashing_backend +0 -18
  22. data/test/integration/model/test.dont_open_socket +0 -0
  23. data/test/integration/model/test.invalid_cmd_line +0 -0
  24. data/test/integration/model/test.not_in_rtext +0 -0
  25. data/test/integration/model/test_large_with_errors.ect3 +0 -43523
  26. data/test/integration/model/test_metamodel.ect +0 -24
  27. data/test/integration/model/test_metamodel2.ect +0 -5
  28. data/test/integration/model/test_metamodel3.ect4 +0 -7
  29. data/test/integration/model/test_metamodel_error.ect2 +0 -3
  30. data/test/integration/model/test_metamodel_ok.ect2 +0 -18
  31. data/test/integration/test.rb +0 -968
  32. data/test/link_detector_test.rb +0 -288
  33. data/test/message_helper_test.rb +0 -117
  34. data/test/rtext_test.rb +0 -11
  35. data/test/serializer_test.rb +0 -1024
  36. data/test/tokenizer_test.rb +0 -174
@@ -1,949 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
-
3
- gem 'minitest'
4
- require 'minitest/autorun'
5
- require 'rgen/metamodel_builder'
6
- require 'rtext/language'
7
- require 'rtext/context_builder'
8
-
9
- class ContextBuilderTest < MiniTest::Test
10
-
11
- module TestMM
12
- extend RGen::MetamodelBuilder::ModuleExtension
13
- class TestNode < RGen::MetamodelBuilder::MMBase
14
- has_attr 'text', String
15
- has_attr 'unlabled', String
16
- has_many_attr 'unlabled_array', String
17
- has_many_attr 'nums', Integer
18
- has_many_attr 'strings', String
19
- has_attr 'boolean', Boolean
20
- has_one 'related', TestNode
21
- has_many 'others', TestNode
22
- contains_many 'childs', TestNode, 'parent'
23
- end
24
- end
25
-
26
- def test_root
27
- c = build_context TestMM, <<-END
28
- |
29
- END
30
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
31
- assert_nil(c.element)
32
- end
33
-
34
- def test_root2
35
- c = build_context TestMM, <<-END
36
- |TestNode
37
- END
38
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
39
- assert_nil(c.element)
40
- end
41
-
42
- def test_root_in_cmd
43
- c = build_context TestMM, <<-END
44
- Test|Node
45
- END
46
- assert_context c, :prefix => "Test", :feature => nil, :in_array => false, :in_block => false
47
- assert_nil(c.element)
48
- end
49
-
50
- def test_root_after_cmd
51
- c = build_context TestMM, <<-END
52
- TestNode|
53
- END
54
- assert_context c, :prefix => "TestNode", :feature => nil, :in_array => false, :in_block => false
55
- assert_nil(c.element)
56
- end
57
-
58
- def test_root_after_cmd2
59
- c = build_context TestMM, <<-END
60
- TestNode |
61
- END
62
- assert_context c, :prefix => "", :feature => "unlabled", :in_array => false, :in_block => false
63
- assert(c.element.is_a?(TestMM::TestNode))
64
- end
65
-
66
- def test_root_in_lable
67
- c = build_context TestMM, <<-END
68
- TestNode ot|hers:
69
- END
70
- assert_context c, :prefix => "ot", :feature => "unlabled", :in_array => false, :in_block => false
71
- assert(c.element.is_a?(TestMM::TestNode))
72
- end
73
-
74
- def test_root_after_lable
75
- c = build_context TestMM, <<-END
76
- TestNode others:|
77
- END
78
- assert_context c, :prefix => "", :feature => "others", :in_array => false, :in_block => false, :after_label => true
79
- assert(c.element.is_a?(TestMM::TestNode))
80
- end
81
-
82
- def test_root_after_lable2
83
- c = build_context TestMM, <<-END
84
- TestNode others: |
85
- END
86
- assert_context c, :prefix => "", :feature => "others", :in_array => false, :in_block => false, :after_label => true
87
- assert(c.element.is_a?(TestMM::TestNode))
88
- end
89
-
90
- def test_root_after_lable_with_value
91
- c = build_context TestMM, <<-END
92
- TestNode text: xx, others: |
93
- END
94
- assert_context c, :prefix => "", :feature => "others", :in_array => false, :in_block => false, :after_label => true
95
- assert(c.element.is_a?(TestMM::TestNode))
96
- assert_equal("xx", c.element.text)
97
- end
98
-
99
- def test_root_after_lable_with_value_missing_comma
100
- c = build_context TestMM, <<-END
101
- TestNode text: xx others: |
102
- END
103
- assert_context c, :prefix => "", :feature => "others", :in_array => false, :in_block => false, :after_label => true
104
- assert(c.element.is_a?(TestMM::TestNode))
105
- assert_equal("xx", c.element.text)
106
- end
107
-
108
- def test_root_after_unlabled
109
- c = build_context TestMM, <<-END
110
- TestNode "bla"|
111
- END
112
- assert_context c, :prefix => "\"bla\"", :feature => "unlabled", :in_array => false, :in_block => false
113
- assert(c.element.is_a?(TestMM::TestNode))
114
- assert_nil(c.element.unlabled)
115
- end
116
-
117
- def test_root_after_unlabled_string_with_comma
118
- c = build_context TestMM, <<-END
119
- TestNode "a,b"|
120
- END
121
- assert_context c, :prefix => "\"a,b\"", :feature => "unlabled", :in_array => false, :in_block => false
122
- assert(c.element.is_a?(TestMM::TestNode))
123
- assert_nil(c.element.unlabled)
124
- end
125
-
126
- def test_root_after_unlabled_string_with_quoted_quote
127
- c = build_context TestMM, <<-END
128
- TestNode "a,\\"b"|
129
- END
130
- assert_context c, :prefix => "\"a,\\\"b\"", :feature => "unlabled", :in_array => false, :in_block => false
131
- assert(c.element.is_a?(TestMM::TestNode))
132
- assert_nil(c.element.unlabled)
133
- end
134
-
135
- def test_root_after_unlabled_unclosed_string_with_comma
136
- c = build_context TestMM, <<-END
137
- TestNode "a,b|
138
- END
139
- assert_context c, :prefix => "\"a,b", :feature => "unlabled", :in_array => false, :in_block => false
140
- assert(c.element.is_a?(TestMM::TestNode))
141
- assert_nil(c.element.unlabled)
142
- end
143
-
144
- def test_root_after_unlabled_no_quot
145
- c = build_context TestMM, <<-END
146
- TestNode bla|
147
- END
148
- assert_context c, :prefix => "bla", :feature => "unlabled", :in_array => false, :in_block => false
149
- assert(c.element.is_a?(TestMM::TestNode))
150
- assert_nil(c.element.unlabled)
151
- end
152
-
153
- def test_root_after_unlabled2
154
- c = build_context TestMM, <<-END
155
- TestNode "bla" |
156
- END
157
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false, :problem => :missing_comma
158
- assert(c.element.is_a?(TestMM::TestNode))
159
- assert_equal("bla", c.element.unlabled)
160
- end
161
-
162
- def test_root_after_unlabled2_no_quot
163
- c = build_context TestMM, <<-END
164
- TestNode bla |
165
- END
166
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false, :problem => :missing_comma
167
- assert(c.element.is_a?(TestMM::TestNode))
168
- assert_equal("bla", c.element.unlabled)
169
- end
170
-
171
- def test_root_after_unlabled_comma_no_quot
172
- c = build_context TestMM, <<-END
173
- TestNode bla,|
174
- END
175
- assert_context c, :prefix => "", :feature => "unlabled_array", :in_array => false, :in_block => false
176
- assert(c.element.is_a?(TestMM::TestNode))
177
- assert_equal("bla", c.element.unlabled)
178
- end
179
-
180
- def test_root_after_unlabled_comma
181
- c = build_context TestMM, <<-END
182
- TestNode "bla", |
183
- END
184
- assert_context c, :prefix => "", :feature => "unlabled_array", :in_array => false, :in_block => false
185
- assert(c.element.is_a?(TestMM::TestNode))
186
- assert_equal("bla", c.element.unlabled)
187
- end
188
-
189
- def test_root_after_unlabled_comma_no_ws
190
- c = build_context TestMM, <<-END
191
- TestNode "bla",|
192
- END
193
- assert_context c, :prefix => "", :feature => "unlabled_array", :in_array => false, :in_block => false
194
- assert(c.element.is_a?(TestMM::TestNode))
195
- assert_equal("bla", c.element.unlabled)
196
- end
197
-
198
- def test_root_unlabled_array
199
- c = build_context TestMM, <<-END
200
- TestNode "bla", [|
201
- END
202
- assert_context c, :prefix => "", :feature => "unlabled_array", :in_array => true, :in_block => false
203
- assert(c.element.is_a?(TestMM::TestNode))
204
- assert_equal("bla", c.element.unlabled)
205
- assert_equal([], c.element.unlabled_array)
206
- end
207
-
208
- def test_root_unlabled_array_first_value
209
- c = build_context TestMM, <<-END
210
- TestNode "bla", [a|
211
- END
212
- assert_context c, :prefix => "a", :feature => "unlabled_array", :in_array => true, :in_block => false
213
- assert(c.element.is_a?(TestMM::TestNode))
214
- assert_equal("bla", c.element.unlabled)
215
- assert_equal([], c.element.unlabled_array)
216
- end
217
-
218
- def test_root_unlabled_array_first_value_quoted
219
- c = build_context TestMM, <<-END
220
- TestNode "bla", ["a"|
221
- END
222
- assert_context c, :prefix => "\"a\"", :feature => "unlabled_array", :in_array => true, :in_block => false
223
- assert(c.element.is_a?(TestMM::TestNode))
224
- assert_equal("bla", c.element.unlabled)
225
- assert_equal([], c.element.unlabled_array)
226
- end
227
-
228
- def test_root_unlabled_array_first_value_quoted_open
229
- c = build_context TestMM, <<-END
230
- TestNode "bla", ["a|
231
- END
232
- assert_context c, :prefix => "\"a", :feature => "unlabled_array", :in_array => true, :in_block => false
233
- assert(c.element.is_a?(TestMM::TestNode))
234
- assert_equal("bla", c.element.unlabled)
235
- assert_equal([], c.element.unlabled_array)
236
- end
237
-
238
- def test_root_unlabled_array_first_value_after_space
239
- c = build_context TestMM, <<-END
240
- TestNode "bla", ["a" |
241
- END
242
- # although not having a comma in front is an error, we are already within a feature
243
- # due to the opening square bracket
244
- assert_context c, :prefix => "", :feature => "unlabled_array", :in_array => true, :in_block => false, :problem => :missing_comma
245
- assert(c.element.is_a?(TestMM::TestNode))
246
- assert_equal("bla", c.element.unlabled)
247
- assert_equal(["a"], c.element.unlabled_array)
248
- end
249
-
250
- def test_root_unlabled_array_first_value_after_comma
251
- c = build_context TestMM, <<-END
252
- TestNode "bla", ["a",|
253
- END
254
- assert_context c, :prefix => "", :feature => "unlabled_array", :in_array => true, :in_block => false
255
- assert(c.element.is_a?(TestMM::TestNode))
256
- assert_equal("bla", c.element.unlabled)
257
- assert_equal(["a"], c.element.unlabled_array)
258
- end
259
-
260
- def test_root_unlabled_array_second_value
261
- c = build_context TestMM, <<-END
262
- TestNode "bla", ["a", b|
263
- END
264
- assert_context c, :prefix => "b", :feature => "unlabled_array", :in_array => true, :in_block => false
265
- assert(c.element.is_a?(TestMM::TestNode))
266
- assert_equal("bla", c.element.unlabled)
267
- assert_equal(["a"], c.element.unlabled_array)
268
- end
269
-
270
- def test_root_unlabled_array_second_value_quoted
271
- c = build_context TestMM, <<-END
272
- TestNode "bla", ["a", "b"|
273
- END
274
- assert_context c, :prefix => "\"b\"", :feature => "unlabled_array", :in_array => true, :in_block => false
275
- assert(c.element.is_a?(TestMM::TestNode))
276
- assert_equal("bla", c.element.unlabled)
277
- assert_equal(["a"], c.element.unlabled_array)
278
- end
279
-
280
- def test_root_unlabled_array_second_value_quoted_open
281
- c = build_context TestMM, <<-END
282
- TestNode "bla", ["a", "b|
283
- END
284
- assert_context c, :prefix => "\"b", :feature => "unlabled_array", :in_array => true, :in_block => false
285
- assert(c.element.is_a?(TestMM::TestNode))
286
- assert_equal("bla", c.element.unlabled)
287
- assert_equal(["a"], c.element.unlabled_array)
288
- end
289
-
290
- def test_root_unlabled_array_second_value_after_comma
291
- c = build_context TestMM, <<-END
292
- TestNode "bla", ["a", b,|
293
- END
294
- assert_context c, :prefix => "", :feature => "unlabled_array", :in_array => true, :in_block => false
295
- assert(c.element.is_a?(TestMM::TestNode))
296
- assert_equal("bla", c.element.unlabled)
297
- assert_equal(["a", "b"], c.element.unlabled_array)
298
- end
299
-
300
- def test_root_unlabled_array_after_array
301
- c = build_context TestMM, <<-END
302
- TestNode "bla", ["a", b]|
303
- END
304
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false, :problem => :missing_comma
305
- assert(c.element.is_a?(TestMM::TestNode))
306
- assert_equal("bla", c.element.unlabled)
307
- assert_equal(["a", "b"], c.element.unlabled_array)
308
- end
309
-
310
- def test_root_unlabled_array_after_array2
311
- c = build_context TestMM, <<-END
312
- TestNode "bla", ["a", b] |
313
- END
314
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false, :problem => :missing_comma
315
- assert(c.element.is_a?(TestMM::TestNode))
316
- assert_equal("bla", c.element.unlabled)
317
- assert_equal(["a", "b"], c.element.unlabled_array)
318
- end
319
-
320
- def test_root_unlabled_array_after_array3
321
- c = build_context TestMM, <<-END
322
- TestNode "bla", ["a", b],|
323
- END
324
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
325
- assert(c.element.is_a?(TestMM::TestNode))
326
- assert_equal("bla", c.element.unlabled)
327
- assert_equal(["a", "b"], c.element.unlabled_array)
328
- end
329
-
330
- def test_root_labled_string_value
331
- c = build_context TestMM, <<-END
332
- TestNode text: "a,b"|
333
- END
334
- assert_context c, :prefix => "\"a,b\"", :feature => "text", :in_array => false, :in_block => false, :after_label => true
335
- assert(c.element.is_a?(TestMM::TestNode))
336
- assert_nil(c.element.text)
337
- end
338
-
339
- def test_root_labled_string_value2
340
- c = build_context TestMM, <<-END
341
- TestNode text: "a,b" |
342
- END
343
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false, :problem => :missing_comma
344
- assert(c.element.is_a?(TestMM::TestNode))
345
- assert_equal("a,b", c.element.text)
346
- end
347
-
348
- def test_root_labled_string_value3
349
- c = build_context TestMM, <<-END
350
- TestNode text: "a,b",|
351
- END
352
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
353
- assert(c.element.is_a?(TestMM::TestNode))
354
- assert_equal("a,b", c.element.text)
355
- end
356
-
357
- def test_root_labled_string_value_within
358
- c = build_context TestMM, <<-END
359
- TestNode text: "a,b|
360
- END
361
- assert_context c, :prefix => "\"a,b", :feature => "text", :in_array => false, :in_block => false, :after_label => true
362
- assert(c.element.is_a?(TestMM::TestNode))
363
- assert_nil(c.element.text)
364
- end
365
-
366
- def test_root_labled_string_value_within_no_ws
367
- c = build_context TestMM, <<-END
368
- TestNode text:"a,b|
369
- END
370
- assert_context c, :prefix => "\"a,b", :feature => "text", :in_array => false, :in_block => false, :after_label => true
371
- assert(c.element.is_a?(TestMM::TestNode))
372
- assert_nil(c.element.text)
373
- end
374
-
375
- def test_root_labled_string_value_no_quot
376
- c = build_context TestMM, <<-END
377
- TestNode text: t|
378
- END
379
- assert_context c, :prefix => "t", :feature => "text", :in_array => false, :in_block => false, :after_label => true
380
- assert(c.element.is_a?(TestMM::TestNode))
381
- assert_nil(c.element.text)
382
- end
383
-
384
- def test_root_labled_bool_value
385
- c = build_context TestMM, <<-END
386
- TestNode boolean: t|
387
- END
388
- assert_context c, :prefix => "t", :feature => "boolean", :in_array => false, :in_block => false, :after_label => true
389
- assert(c.element.is_a?(TestMM::TestNode))
390
- assert_nil(c.element.text)
391
- end
392
-
393
- def test_root_after_curly
394
- c = build_context TestMM, <<-END
395
- TestNode {|
396
- END
397
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false, :problem => :after_curly
398
- assert(c.element.is_a?(TestMM::TestNode))
399
- end
400
-
401
- def test_root_after_curly_no_ws
402
- c = build_context TestMM, <<-END
403
- TestNode{|
404
- END
405
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false, :problem => :after_curly
406
- assert(c.element.is_a?(TestMM::TestNode))
407
- end
408
-
409
- def test_in_cmd_after_cmd
410
- c = build_context TestMM, <<-END
411
- TestNode text: a {
412
- TestNode nums: 3 {
413
- TestNode |others: /dummy {
414
- END
415
- assert_context c, :prefix => "", :feature => "unlabled", :in_array => false, :in_block => false
416
- assert_simple_model(c.element)
417
- assert_other_values(c.element, [])
418
- end
419
-
420
- def test_in_cmd_after_cmd2
421
- c = build_context TestMM, <<-END
422
- TestNode text: a {
423
- TestNode| nums: 3 {
424
- END
425
- assert_context c, :prefix => "TestNode", :feature => nil, :in_array => false, :in_block => true
426
- assert(c.element.is_a?(TestMM::TestNode))
427
- end
428
-
429
- def test_in_cmd_in_label
430
- c = build_context TestMM, <<-END
431
- TestNode text: a {
432
- TestNode nums: 3 {
433
- TestNode ot|hers: /dummy {
434
- END
435
- assert_context c, :prefix => "ot", :feature => "unlabled", :in_array => false, :in_block => false
436
- assert_simple_model(c.element)
437
- assert_other_values(c.element, [])
438
- end
439
-
440
- def test_in_cmd_after_label
441
- c = build_context TestMM, <<-END
442
- TestNode text: a {
443
- TestNode nums: 3 {
444
- TestNode others: |/dummy {
445
- END
446
- assert_context c, :prefix => "", :feature => "others", :in_array => false, :in_block => false, :after_label => true
447
- assert_simple_model(c.element)
448
- assert_other_values(c.element, [])
449
- end
450
-
451
- def test_in_cmd_in_label2
452
- c = build_context TestMM, <<-END
453
- TestNode text: a {
454
- TestNode nums: 3 {
455
- TestNode others:| /dummy {
456
- END
457
- assert_context c, :prefix => "", :feature => "others", :in_array => false, :in_block => false, :after_label => true
458
- assert_simple_model(c.element)
459
- assert_other_values(c.element, [])
460
- end
461
-
462
- def test_in_cmd_after_label_no_ws
463
- c = build_context TestMM, <<-END
464
- TestNode text: a {
465
- TestNode nums: 3 {
466
- TestNode others:|/dummy {
467
- END
468
- assert_context c, :prefix => "", :feature => "others", :in_array => false, :in_block => false, :after_label => true
469
- assert_simple_model(c.element)
470
- assert_other_values(c.element, [])
471
- end
472
-
473
- def test_in_cmd_in_value
474
- c = build_context TestMM, <<-END
475
- TestNode text: a {
476
- TestNode nums: 3 {
477
- TestNode others: /du|mmy {
478
- END
479
- assert_context c, :prefix => "/du", :feature => "others", :in_array => false, :in_block => false, :after_label => true
480
- assert_simple_model(c.element)
481
- assert_other_values(c.element, [])
482
- end
483
-
484
- def test_in_cmd_in_value2
485
- c = build_context TestMM, <<-END
486
- TestNode text: a {
487
- TestNode nums: 3 {
488
- TestNode others: /dummy| {
489
- END
490
- assert_context c, :prefix => "/dummy", :feature => "others", :in_array => false, :in_block => false, :after_label => true
491
- assert_simple_model(c.element)
492
- assert_other_values(c.element, [])
493
- end
494
-
495
- def test_in_cmd_after_value
496
- c = build_context TestMM, <<-END
497
- TestNode text: a {
498
- TestNode nums: 3 {
499
- TestNode others: /dummy, |text: x {
500
- END
501
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
502
- assert_simple_model(c.element)
503
- assert_other_values(c.element, ["/dummy"])
504
- end
505
-
506
- def test_in_cmd_after_value_no_ws
507
- c = build_context TestMM, <<-END
508
- TestNode text: a {
509
- TestNode nums: 3 {
510
- TestNode others: /dummy,|text: x {
511
- END
512
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
513
- assert_simple_model(c.element)
514
- assert_other_values(c.element, ["/dummy"])
515
- end
516
-
517
- def test_in_cmd_after_value_no_ws2
518
- c = build_context TestMM, <<-END
519
- TestNode text: a {
520
- TestNode nums: 3 {
521
- TestNode others:/dummy,|text: x {
522
- END
523
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
524
- assert_simple_model(c.element)
525
- assert_other_values(c.element, ["/dummy"])
526
- end
527
-
528
- def test_in_cmd_after_value_directly_after_comma
529
- c = build_context TestMM, <<-END
530
- TestNode text: a {
531
- TestNode nums: 3 {
532
- TestNode others: /dummy,| text: x {
533
- END
534
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
535
- assert_simple_model(c.element)
536
- assert_other_values(c.element, ["/dummy"])
537
- end
538
-
539
- def test_in_cmd_in_second_label
540
- c = build_context TestMM, <<-END
541
- TestNode text: a {
542
- TestNode nums: 3 {
543
- TestNode others: /dummy, te|xt: x {
544
- END
545
- assert_context c, :prefix => "te", :feature => nil, :in_array => false, :in_block => false
546
- assert_simple_model(c.element)
547
- assert_other_values(c.element, ["/dummy"])
548
- end
549
-
550
- def test_in_cmd_after_second_label
551
- c = build_context TestMM, <<-END
552
- TestNode text: a {
553
- TestNode nums: 3 {
554
- TestNode others: /dummy, text: |x {
555
- END
556
- assert_context c, :prefix => "", :feature => "text", :in_array => false, :in_block => false, :after_label => true
557
- assert_simple_model(c.element)
558
- assert_other_values(c.element, ["/dummy"])
559
- end
560
-
561
- def test_in_cmd_after_second_label_no_ws
562
- c = build_context TestMM, <<-END
563
- TestNode text: a {
564
- TestNode nums: 3 {
565
- TestNode others:/dummy,text:|x {
566
- END
567
- assert_context c, :prefix => "", :feature => "text", :in_array => false, :in_block => false, :after_label => true
568
- assert_simple_model(c.element)
569
- assert_other_values(c.element, ["/dummy"])
570
- end
571
-
572
- def test_in_cmd_in_second_value
573
- c = build_context TestMM, <<-END
574
- TestNode text: a {
575
- TestNode nums: 3 {
576
- TestNode others: /dummy, text: x| {
577
- END
578
- assert_context c, :prefix => "x", :feature => "text", :in_array => false, :in_block => false, :after_label => true
579
- assert_simple_model(c.element)
580
- assert_other_values(c.element, ["/dummy"])
581
- end
582
-
583
- def test_in_cmd_in_second_value_no_ws
584
- c = build_context TestMM, <<-END
585
- TestNode text: a {
586
- TestNode nums: 3 {
587
- TestNode others:/dummy,text:x| {
588
- END
589
- assert_context c, :prefix => "x", :feature => "text", :in_array => false, :in_block => false, :after_label => true
590
- assert_simple_model(c.element)
591
- assert_other_values(c.element, ["/dummy"])
592
- end
593
-
594
- def test_in_cmd_in_array
595
- c = build_context TestMM, <<-END
596
- TestNode text: a {
597
- TestNode nums: 3 {
598
- TestNode others: [|/dummy, text: x
599
- END
600
- assert_context c, :prefix => "", :feature => "others", :in_array => true, :in_block => false, :after_label => true
601
- assert_simple_model(c.element)
602
- assert_other_values(c.element, [])
603
- end
604
-
605
- def test_in_cmd_in_array_no_ws
606
- c = build_context TestMM, <<-END
607
- TestNode text: a {
608
- TestNode nums: 3 {
609
- TestNode others:[|/dummy, text: x
610
- END
611
- assert_context c, :prefix => "", :feature => "others", :in_array => true, :in_block => false, :after_label => true
612
- assert_simple_model(c.element)
613
- assert_other_values(c.element, [])
614
- end
615
-
616
- def test_in_cmd_in_array_within_string_value_empty
617
- c = build_context TestMM, <<-END
618
- TestNode text: a {
619
- TestNode nums: 3 {
620
- TestNode strings: ["|
621
- END
622
- assert_context c, :prefix => "\"", :feature => "strings", :in_array => true, :in_block => false, :after_label => true
623
- assert_simple_model(c.element)
624
- assert_other_values(c.element, [])
625
- end
626
-
627
- def test_in_cmd_in_array_within_string_value
628
- c = build_context TestMM, <<-END
629
- TestNode text: a {
630
- TestNode nums: 3 {
631
- TestNode strings: ["a,b|
632
- END
633
- assert_context c, :prefix => "\"a,b", :feature => "strings", :in_array => true, :in_block => false, :after_label => true
634
- assert_simple_model(c.element)
635
- assert_other_values(c.element, [])
636
- end
637
-
638
- def test_in_cmd_in_array_within_second_string_value
639
- c = build_context TestMM, <<-END
640
- TestNode text: a {
641
- TestNode nums: 3 {
642
- TestNode strings: ["a,b", "c,d|
643
- END
644
- assert_context c, :prefix => "\"c,d", :feature => "strings", :in_array => true, :in_block => false, :after_label => true
645
- assert_simple_model(c.element)
646
- assert_other_values(c.element, [])
647
- end
648
-
649
- def test_in_cmd_in_array_after_second_string_value
650
- c = build_context TestMM, <<-END
651
- TestNode text: a {
652
- TestNode nums: 3 {
653
- TestNode strings: ["a,b", "c,d"|
654
- END
655
- assert_context c, :prefix => "\"c,d\"", :feature => "strings", :in_array => true, :in_block => false, :after_label => true
656
- assert_simple_model(c.element)
657
- assert_equal(["a,b"], c.element.strings)
658
- end
659
-
660
- def test_in_cmd_in_array_after_second_string_value2
661
- c = build_context TestMM, <<-END
662
- TestNode text: a {
663
- TestNode nums: 3 {
664
- TestNode strings: ["a,b", "c,d" |
665
- END
666
- assert_context c, :prefix => "", :feature => "strings", :in_array => true, :in_block => false, :problem => :missing_comma, :after_label => true
667
- assert_simple_model(c.element)
668
- assert_equal(["a,b", "c,d"], c.element.strings)
669
- end
670
-
671
- def test_in_cmd_in_array_after_string_array
672
- c = build_context TestMM, <<-END
673
- TestNode text: a {
674
- TestNode nums: 3 {
675
- TestNode strings: ["a,b", "c,d"]|
676
- END
677
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false, :problem => :missing_comma
678
- assert_simple_model(c.element)
679
- assert_equal(["a,b", "c,d"], c.element.strings)
680
- end
681
-
682
- def test_in_cmd_in_array_value
683
- c = build_context TestMM, <<-END
684
- TestNode text: a {
685
- TestNode nums: 3 {
686
- TestNode others: [/d|ummy, text: x
687
- END
688
- assert_context c, :prefix => "/d", :feature => "others", :in_array => true, :in_block => false, :after_label => true
689
- assert_simple_model(c.element)
690
- assert_other_values(c.element, [])
691
- end
692
-
693
- def test_in_cmd_in_array_value_no_ws
694
- c = build_context TestMM, <<-END
695
- TestNode text: a {
696
- TestNode nums: 3 {
697
- TestNode others:[/d|ummy, text: x
698
- END
699
- assert_context c, :prefix => "/d", :feature => "others", :in_array => true, :in_block => false, :after_label => true
700
- assert_simple_model(c.element)
701
- assert_other_values(c.element, [])
702
- end
703
-
704
- def test_in_cmd_after_array_value
705
- c = build_context TestMM, <<-END
706
- TestNode text: a {
707
- TestNode nums: 3 {
708
- TestNode others: [/dummy,| text: x
709
- END
710
- assert_context c, :prefix => "", :feature => "others", :in_array => true, :in_block => false, :after_label => true
711
- assert_simple_model(c.element)
712
- assert_other_values(c.element, ["/dummy"])
713
- end
714
-
715
- def test_in_cmd_after_array_value_no_ws
716
- c = build_context TestMM, <<-END
717
- TestNode text: a {
718
- TestNode nums: 3 {
719
- TestNode others:[/dummy,| text: x
720
- END
721
- assert_context c, :prefix => "", :feature => "others", :in_array => true, :in_block => false, :after_label => true
722
- assert_simple_model(c.element)
723
- assert_other_values(c.element, ["/dummy"])
724
- end
725
-
726
- def test_in_cmd_in_second_array_value
727
- c = build_context TestMM, <<-END
728
- TestNode text: a {
729
- TestNode nums: 3 {
730
- TestNode others: [/dummy, /dom|my
731
- END
732
- assert_context c, :prefix => "/dom", :feature => "others", :in_array => true, :in_block => false, :after_label => true
733
- assert_simple_model(c.element)
734
- assert_other_values(c.element, ["/dummy"])
735
- end
736
-
737
- def test_in_cmd_in_second_array_value_no_ws
738
- c = build_context TestMM, <<-END
739
- TestNode text: a {
740
- TestNode nums: 3 {
741
- TestNode others: [/dummy,/dom|my
742
- END
743
- assert_context c, :prefix => "/dom", :feature => "others", :in_array => true, :in_block => false, :after_label => true
744
- assert_simple_model(c.element)
745
- assert_other_values(c.element, ["/dummy"])
746
- end
747
-
748
- def test_in_cmd_in_second_array_value_no_ws2
749
- c = build_context TestMM, <<-END
750
- TestNode text: a {
751
- TestNode nums: 3 {
752
- TestNode others:[/dummy,/dom|my
753
- END
754
- assert_context c, :prefix => "/dom", :feature => "others", :in_array => true, :in_block => false, :after_label => true
755
- assert_simple_model(c.element)
756
- assert_other_values(c.element, ["/dummy"])
757
- end
758
-
759
- def test_in_cmd_after_array
760
- c = build_context TestMM, <<-END
761
- TestNode text: a {
762
- TestNode nums: 3 {
763
- TestNode others: [/dummy, /dommy], |
764
- END
765
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
766
- assert_simple_model(c.element)
767
- assert_other_values(c.element, ["/dummy", "/dommy"])
768
- end
769
-
770
- def test_in_cmd_after_array_no_ws
771
- c = build_context TestMM, <<-END
772
- TestNode text: a {
773
- TestNode nums: 3 {
774
- TestNode others:[/dummy,/dommy],|
775
- END
776
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => false
777
- assert_simple_model(c.element)
778
- assert_other_values(c.element, ["/dummy", "/dommy"])
779
- end
780
-
781
- def test_in_cmd_after_array2
782
- c = build_context TestMM, <<-END
783
- TestNode text: a {
784
- TestNode nums: 3 {
785
- TestNode others: [/dummy, /dommy], nums: |
786
- END
787
- assert_context c, :prefix => "", :feature => "nums", :in_array => false, :in_block => false, :after_label => true
788
- assert_simple_model(c.element)
789
- assert_other_values(c.element, ["/dummy", "/dommy"])
790
- end
791
-
792
- def test_in_cmd_after_array2_no_ws
793
- c = build_context TestMM, <<-END
794
- TestNode text: a {
795
- TestNode nums: 3 {
796
- TestNode others:[/dummy,/dommy],nums:|
797
- END
798
- assert_context c, :prefix => "", :feature => "nums", :in_array => false, :in_block => false, :after_label => true
799
- assert_simple_model(c.element)
800
- assert_other_values(c.element, ["/dummy", "/dommy"])
801
- end
802
-
803
- def test_in_cmd_boolean_value
804
- c = build_context TestMM, <<-END
805
- TestNode text: a {
806
- TestNode nums: 3 {
807
- TestNode boolean: t|
808
- END
809
- assert_context c, :prefix => "t", :feature => "boolean", :in_array => false, :in_block => false, :after_label => true
810
- assert_simple_model(c.element)
811
- end
812
-
813
- def test_below_single_label
814
- c = build_context TestMM, <<-END
815
- TestNode text: a {
816
- TestNode nums: 3 {
817
- TestNode others: /dummy {
818
- childs:
819
- |
820
- END
821
- assert_context c, :prefix => "", :feature => "childs", :in_array => false, :in_block => true, :after_label => true
822
- assert_simple_model(c.element)
823
- assert_other_values(c.element, ["/dummy"])
824
- end
825
-
826
- def test_below_single_label_started_command
827
- c = build_context TestMM, <<-END
828
- TestNode text: a {
829
- TestNode nums: 3 {
830
- TestNode others: /dummy {
831
- childs:
832
- Tes|
833
- END
834
- assert_context c, :prefix => "Tes", :feature => "childs", :in_array => false, :in_block => true, :after_label => true
835
- assert_simple_model(c.element)
836
- assert_other_values(c.element, ["/dummy"])
837
- end
838
-
839
- def test_below_single_label_after_command
840
- c = build_context TestMM, <<-END
841
- TestNode text: a {
842
- TestNode nums: 3 {
843
- TestNode others: /dummy {
844
- childs:
845
- TestNode |
846
- END
847
- assert_context c, :prefix => "", :feature => "unlabled", :in_array => false, :in_block => false
848
- assert_equal [3], c.element.parent.parent.nums
849
- end
850
-
851
- def test_below_multi_label
852
- c = build_context TestMM, <<-END
853
- TestNode text: a {
854
- TestNode nums: 3 {
855
- TestNode others: /dummy {
856
- childs: [
857
- |
858
- END
859
- assert_context c, :prefix => "", :feature => "childs", :in_array => true, :in_block => true, :after_label => true
860
- assert_simple_model(c.element)
861
- assert_other_values(c.element, ["/dummy"])
862
- end
863
-
864
- def test_below_multi_label_started_command
865
- c = build_context TestMM, <<-END
866
- TestNode text: a {
867
- TestNode nums: 3 {
868
- TestNode others: /dummy {
869
- childs: [
870
- Tes|
871
- END
872
- assert_context c, :prefix => "Tes", :feature => "childs", :in_array => true, :in_block => true, :after_label => true
873
- assert_simple_model(c.element)
874
- assert_other_values(c.element, ["/dummy"])
875
- end
876
-
877
- def test_below_multi_label_after_command
878
- c = build_context TestMM, <<-END
879
- TestNode text: a {
880
- TestNode nums: 3 {
881
- TestNode others: /dummy {
882
- childs: [
883
- TestNode |
884
- END
885
- assert_context c, :prefix => "", :feature => "unlabled", :in_array => false, :in_block => false
886
- assert_equal [3], c.element.parent.parent.nums
887
- end
888
-
889
- def test_in_new_line
890
- c = build_context TestMM, <<-END
891
- TestNode text: a {
892
- TestNode nums: 3 {
893
- TestNode others: /dummy {
894
- |
895
- END
896
- assert_context c, :prefix => "", :feature => nil, :in_array => false, :in_block => true
897
- assert_simple_model(c.element)
898
- assert_other_values(c.element, ["/dummy"])
899
- end
900
-
901
- def test_in_new_line_started_command
902
- c = build_context TestMM, <<-END
903
- TestNode text: a {
904
- TestNode nums: 3 {
905
- TestNode others: /dummy {
906
- Tes|
907
- END
908
- assert_context c, :prefix => "Tes", :feature => nil, :in_array => false, :in_block => true
909
- assert_simple_model(c.element)
910
- assert_other_values(c.element, ["/dummy"])
911
- end
912
-
913
- def assert_context(c, options)
914
- assert_equal(options[:prefix], c.prefix)
915
- assert_equal(options[:in_array], c.position.in_array)
916
- assert_equal(options[:in_block], c.position.in_block)
917
- assert_equal((options[:after_label] || false), c.position.after_label)
918
- assert_equal(options[:problem], c.problem)
919
- if options[:feature]
920
- assert_equal(options[:feature], c.feature.name)
921
- else
922
- assert_nil(c.feature)
923
- end
924
- end
925
-
926
- def assert_simple_model(c)
927
- assert c.is_a?(TestMM::TestNode)
928
- assert c.parent.is_a?(TestMM::TestNode)
929
- assert_equal [3], c.parent.nums
930
- assert c.parent.parent.is_a?(TestMM::TestNode)
931
- assert_equal "a", c.parent.parent.text
932
- end
933
-
934
- def assert_other_values(c, values)
935
- assert_equal values, c.others.collect{|v| v.targetIdentifier}
936
- end
937
-
938
- def build_context(mm, text)
939
- context_lines = text.split("\n")
940
- pos_in_line = context_lines.last.index("|")
941
- context_lines.last.sub!("|", "")
942
- lang = RText::Language.new(mm.ecore,
943
- :root_classes => mm.ecore.eAllClasses,
944
- :unlabled_arguments => lambda {|c| ["unlabled", "unlabled_array"]})
945
- RText::ContextBuilder.build_context(lang, context_lines, pos_in_line)
946
- end
947
-
948
- end
949
-