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