rtext 0.5.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +29 -0
- data/MIT-LICENSE +1 -1
- data/RText_Protocol +102 -51
- data/Rakefile +1 -1
- data/lib/rtext/context_builder.rb +8 -1
- data/lib/rtext/default_completer.rb +163 -0
- data/lib/rtext/default_loader.rb +28 -20
- data/lib/rtext/default_resolver.rb +42 -0
- data/lib/rtext/default_service_provider.rb +49 -21
- data/lib/rtext/frontend/connector.rb +2 -1
- data/lib/rtext/instantiator.rb +38 -16
- data/lib/rtext/json_interface.rb +31 -0
- data/lib/rtext/language.rb +24 -4
- data/lib/rtext/message_helper.rb +35 -25
- data/lib/rtext/parser.rb +27 -45
- data/lib/rtext/serializer.rb +13 -5
- data/lib/rtext/service.rb +27 -18
- data/lib/rtext/tokenizer.rb +18 -2
- data/test/completer_test.rb +35 -18
- data/test/context_builder_test.rb +7 -7
- data/test/instantiator_test.rb +116 -48
- data/test/integration/backend.out +13 -10
- data/test/integration/frontend.log +7664 -0
- data/test/integration/test.rb +6 -0
- data/test/message_helper_test.rb +4 -4
- data/test/serializer_test.rb +101 -3
- data/test/tokenizer_test.rb +33 -1
- metadata +7 -5
- data/lib/rtext/completer.rb +0 -128
@@ -108,7 +108,7 @@ def test_root_after_unlabled
|
|
108
108
|
c = build_context TestMM, <<-END
|
109
109
|
TestNode "bla"|
|
110
110
|
END
|
111
|
-
assert_context c, :prefix => "bla", :feature => "unlabled", :in_array => false, :in_block => false
|
111
|
+
assert_context c, :prefix => "\"bla\"", :feature => "unlabled", :in_array => false, :in_block => false
|
112
112
|
assert(c.element.is_a?(TestMM::TestNode))
|
113
113
|
assert_nil(c.element.unlabled)
|
114
114
|
end
|
@@ -117,7 +117,7 @@ def test_root_after_unlabled_string_with_comma
|
|
117
117
|
c = build_context TestMM, <<-END
|
118
118
|
TestNode "a,b"|
|
119
119
|
END
|
120
|
-
assert_context c, :prefix => "a,b", :feature => "unlabled", :in_array => false, :in_block => false
|
120
|
+
assert_context c, :prefix => "\"a,b\"", :feature => "unlabled", :in_array => false, :in_block => false
|
121
121
|
assert(c.element.is_a?(TestMM::TestNode))
|
122
122
|
assert_nil(c.element.unlabled)
|
123
123
|
end
|
@@ -126,7 +126,7 @@ def test_root_after_unlabled_string_with_quoted_quote
|
|
126
126
|
c = build_context TestMM, <<-END
|
127
127
|
TestNode "a,\\"b"|
|
128
128
|
END
|
129
|
-
assert_context c, :prefix => "a
|
129
|
+
assert_context c, :prefix => "\"a,\\\"b\"", :feature => "unlabled", :in_array => false, :in_block => false
|
130
130
|
assert(c.element.is_a?(TestMM::TestNode))
|
131
131
|
assert_nil(c.element.unlabled)
|
132
132
|
end
|
@@ -218,7 +218,7 @@ def test_root_unlabled_array_first_value_quoted
|
|
218
218
|
c = build_context TestMM, <<-END
|
219
219
|
TestNode "bla", ["a"|
|
220
220
|
END
|
221
|
-
assert_context c, :prefix => "a", :feature => "unlabled_array", :in_array => true, :in_block => false
|
221
|
+
assert_context c, :prefix => "\"a\"", :feature => "unlabled_array", :in_array => true, :in_block => false
|
222
222
|
assert(c.element.is_a?(TestMM::TestNode))
|
223
223
|
assert_equal("bla", c.element.unlabled)
|
224
224
|
assert_equal([], c.element.unlabled_array)
|
@@ -270,7 +270,7 @@ def test_root_unlabled_array_second_value_quoted
|
|
270
270
|
c = build_context TestMM, <<-END
|
271
271
|
TestNode "bla", ["a", "b"|
|
272
272
|
END
|
273
|
-
assert_context c, :prefix => "b", :feature => "unlabled_array", :in_array => true, :in_block => false
|
273
|
+
assert_context c, :prefix => "\"b\"", :feature => "unlabled_array", :in_array => true, :in_block => false
|
274
274
|
assert(c.element.is_a?(TestMM::TestNode))
|
275
275
|
assert_equal("bla", c.element.unlabled)
|
276
276
|
assert_equal(["a"], c.element.unlabled_array)
|
@@ -330,7 +330,7 @@ def test_root_labled_string_value
|
|
330
330
|
c = build_context TestMM, <<-END
|
331
331
|
TestNode text: "a,b"|
|
332
332
|
END
|
333
|
-
assert_context c, :prefix => "a,b", :feature => "text", :in_array => false, :in_block => false, :after_label => true
|
333
|
+
assert_context c, :prefix => "\"a,b\"", :feature => "text", :in_array => false, :in_block => false, :after_label => true
|
334
334
|
assert(c.element.is_a?(TestMM::TestNode))
|
335
335
|
assert_nil(c.element.text)
|
336
336
|
end
|
@@ -643,7 +643,7 @@ def test_in_cmd_in_array_after_second_string_value
|
|
643
643
|
TestNode nums: 3 {
|
644
644
|
TestNode strings: ["a,b", "c,d"|
|
645
645
|
END
|
646
|
-
assert_context c, :prefix => "c,d", :feature => "strings", :in_array => true, :in_block => false, :after_label => true
|
646
|
+
assert_context c, :prefix => "\"c,d\"", :feature => "strings", :in_array => true, :in_block => false, :after_label => true
|
647
647
|
assert_simple_model(c.element)
|
648
648
|
assert_equal(["a,b"], c.element.strings)
|
649
649
|
end
|
data/test/instantiator_test.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
3
3
|
|
4
4
|
require 'test/unit'
|
5
|
+
require 'bigdecimal'
|
5
6
|
require 'rgen/environment'
|
6
7
|
require 'rgen/metamodel_builder'
|
7
8
|
require 'rtext/instantiator'
|
@@ -42,12 +43,13 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
42
43
|
TestNode.contains_one 'singleChild2b', TestNode2, 'parentB'
|
43
44
|
end
|
44
45
|
|
45
|
-
module
|
46
|
+
module TestMMLinenoFilenameFragment
|
46
47
|
extend RGen::MetamodelBuilder::ModuleExtension
|
47
48
|
class TestNode < RGen::MetamodelBuilder::MMBase
|
48
49
|
has_attr 'text', String
|
49
50
|
has_attr 'lineno', Integer
|
50
51
|
has_attr 'filename', String
|
52
|
+
has_attr 'fragmentr', String
|
51
53
|
contains_many 'childs', TestNode, 'parent'
|
52
54
|
end
|
53
55
|
end
|
@@ -174,7 +176,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
174
176
|
TestNode text: "node3"
|
175
177
|
}
|
176
178
|
TestNode text: "node4"
|
177
|
-
),
|
179
|
+
), TestMMLinenoFilenameFragment, :line_number_attribute => "lineno")
|
178
180
|
assert_no_problems(problems)
|
179
181
|
assert_equal 2, env.find(:text => "node1").first.lineno
|
180
182
|
assert_equal 3, env.find(:text => "node2").first.lineno
|
@@ -182,6 +184,14 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
182
184
|
assert_equal 8, env.find(:text => "node4").first.lineno
|
183
185
|
end
|
184
186
|
|
187
|
+
def test_missing_line_number_setter
|
188
|
+
env, problems = instantiate(%Q(
|
189
|
+
TestNode text: A
|
190
|
+
), TestMMLinenoFilenameFragment, :line_number_attribute => "wrong_attribute_name")
|
191
|
+
assert_no_problems(problems)
|
192
|
+
assert_nil env.elements.first.lineno
|
193
|
+
end
|
194
|
+
|
185
195
|
def test_root_elements
|
186
196
|
root_elements = []
|
187
197
|
env, problems = instantiate(%Q(
|
@@ -205,10 +215,33 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
205
215
|
def test_file_name_setter
|
206
216
|
env, problems = instantiate(%Q(
|
207
217
|
TestNode text: A
|
208
|
-
),
|
218
|
+
), TestMMLinenoFilenameFragment, :file_name => "some_file", :file_name_attribute => "filename")
|
209
219
|
assert_equal "some_file", env.elements.first.filename
|
210
220
|
end
|
211
221
|
|
222
|
+
def test_missing_file_name_setter
|
223
|
+
env, problems = instantiate(%Q(
|
224
|
+
TestNode text: A
|
225
|
+
), TestMMLinenoFilenameFragment, :file_name => "some_file", :file_name_attribute => "wrong_attribute_name")
|
226
|
+
assert_nil env.elements.first.filename
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_fragment_ref_setter
|
230
|
+
the_ref = "is a string here but would normally be an RGen fragment"
|
231
|
+
env, problems = instantiate(%Q(
|
232
|
+
TestNode text: A
|
233
|
+
), TestMMLinenoFilenameFragment, :fragment_ref => the_ref, :fragment_ref_attribute => "fragmentr")
|
234
|
+
assert_equal the_ref.object_id, env.elements.first.fragmentr.object_id
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_missing_fragment_ref_setter
|
238
|
+
the_ref = "is a string here but would normally be an RGen fragment"
|
239
|
+
env, problems = instantiate(%Q(
|
240
|
+
TestNode text: A
|
241
|
+
), TestMMLinenoFilenameFragment, :fragment_ref => the_ref, :fragment_ref_attribute => "wrong_attribute_name")
|
242
|
+
assert_nil env.elements.first.fragmentr
|
243
|
+
end
|
244
|
+
|
212
245
|
#
|
213
246
|
# children with role
|
214
247
|
#
|
@@ -375,6 +408,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
375
408
|
]
|
376
409
|
assert_equal ref_targets, env.find(:text => "root").first.childs.collect{|c| c.related.targetIdentifier}
|
377
410
|
assert_equal ref_targets, unresolved_refs.collect{|ur| ur.proxy.targetIdentifier}
|
411
|
+
assert unresolved_refs.all?{|ur| ur.feature_name == "related"}
|
378
412
|
end
|
379
413
|
|
380
414
|
def test_references_many
|
@@ -502,28 +536,28 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
502
536
|
env, problems = instantiate(%Q(
|
503
537
|
TestNode text: "some text" {
|
504
538
|
), TestMM)
|
505
|
-
assert_problems([/unexpected end of file, expected \}/i], problems)
|
539
|
+
assert_problems([[/unexpected end of file, expected \}/i, 2]], problems)
|
506
540
|
end
|
507
541
|
|
508
542
|
def test_unknown_command
|
509
543
|
env, problems = instantiate(%Q(
|
510
544
|
NotDefined
|
511
545
|
), TestMM)
|
512
|
-
assert_problems([/unknown command 'NotDefined'/i], problems)
|
546
|
+
assert_problems([[/unknown command 'NotDefined'/i, 2]], problems)
|
513
547
|
end
|
514
548
|
|
515
549
|
def test_unknown_command_abstract
|
516
550
|
env, problems = instantiate(%Q(
|
517
551
|
TestNode
|
518
552
|
), TestMMAbstract)
|
519
|
-
assert_problems([/unknown command 'TestNode'/i], problems)
|
553
|
+
assert_problems([[/unknown command 'TestNode'/i, 2]], problems)
|
520
554
|
end
|
521
555
|
|
522
556
|
def test_unexpected_unlabled_argument
|
523
557
|
env, problems = instantiate(%Q(
|
524
558
|
TestNode "more text"
|
525
559
|
), TestMM)
|
526
|
-
assert_problems([/unexpected unlabled argument, 0 unlabled arguments expected/i], problems)
|
560
|
+
assert_problems([[/unexpected unlabled argument, 0 unlabled arguments expected/i, 2]], problems)
|
527
561
|
end
|
528
562
|
|
529
563
|
def test_unknown_child_role
|
@@ -533,7 +567,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
533
567
|
TestNode
|
534
568
|
}
|
535
569
|
), TestMM)
|
536
|
-
assert_problems([/unknown child role 'notdefined'/i], problems)
|
570
|
+
assert_problems([[/unknown child role 'notdefined'/i, 3]], problems)
|
537
571
|
end
|
538
572
|
|
539
573
|
def test_not_a_child_role
|
@@ -546,8 +580,8 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
546
580
|
}
|
547
581
|
), TestMM)
|
548
582
|
assert_problems([
|
549
|
-
/role 'text' can not take child elements/i,
|
550
|
-
/role 'others' can not take child elements/i
|
583
|
+
[/role 'text' can not take child elements/i, 3],
|
584
|
+
[/role 'others' can not take child elements/i, 5]
|
551
585
|
], problems)
|
552
586
|
end
|
553
587
|
|
@@ -561,7 +595,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
561
595
|
}
|
562
596
|
), TestMM2)
|
563
597
|
assert_problems([
|
564
|
-
/only one child allowed in role 'singleChild'/i,
|
598
|
+
[/only one child allowed in role 'singleChild'/i, 5]
|
565
599
|
], problems)
|
566
600
|
end
|
567
601
|
|
@@ -570,12 +604,14 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
570
604
|
TestNode {
|
571
605
|
singleChild:
|
572
606
|
TestNode
|
607
|
+
singleChild: [
|
608
|
+
]
|
573
609
|
singleChild:
|
574
610
|
TestNode
|
575
611
|
}
|
576
612
|
), TestMM2)
|
577
613
|
assert_problems([
|
578
|
-
/only one child allowed in role 'singleChild'/i,
|
614
|
+
[/only one child allowed in role 'singleChild'/i, 8]
|
579
615
|
], problems)
|
580
616
|
end
|
581
617
|
|
@@ -587,7 +623,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
587
623
|
}
|
588
624
|
), TestMM2)
|
589
625
|
assert_problems([
|
590
|
-
/role 'singleChild' can not take a TestNode2, expected TestNode/i,
|
626
|
+
[/role 'singleChild' can not take a TestNode2, expected TestNode/i, 4]
|
591
627
|
], problems)
|
592
628
|
end
|
593
629
|
|
@@ -598,7 +634,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
598
634
|
}
|
599
635
|
), TestMM2)
|
600
636
|
assert_problems([
|
601
|
-
/unexpected \}, expected identifier/i
|
637
|
+
[/unexpected \}, expected identifier/i, 4]
|
602
638
|
], problems)
|
603
639
|
end
|
604
640
|
|
@@ -609,7 +645,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
609
645
|
}
|
610
646
|
), TestMM2)
|
611
647
|
assert_problems([
|
612
|
-
/command 'TestNode3' can not be used in this context/i,
|
648
|
+
[/command 'TestNode3' can not be used in this context/i, 3]
|
613
649
|
], problems)
|
614
650
|
end
|
615
651
|
|
@@ -620,7 +656,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
620
656
|
}
|
621
657
|
), TestMM2)
|
622
658
|
assert_problems([
|
623
|
-
/role of element is ambiguous, use a role label/i,
|
659
|
+
[/role of element is ambiguous, use a role label/i, 3]
|
624
660
|
], problems)
|
625
661
|
end
|
626
662
|
|
@@ -641,7 +677,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
641
677
|
}
|
642
678
|
), TestMM2)
|
643
679
|
assert_problems([
|
644
|
-
/only one child allowed in role 'singleChild'/i,
|
680
|
+
[/only one child allowed in role 'singleChild'/i, 4]
|
645
681
|
], problems)
|
646
682
|
end
|
647
683
|
|
@@ -649,35 +685,35 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
649
685
|
env, problems = instantiate(%Q(
|
650
686
|
TestNode unknown: "some text"
|
651
687
|
), TestMM)
|
652
|
-
assert_problems([/unknown argument 'unknown'/i], problems)
|
688
|
+
assert_problems([[/unknown argument 'unknown'/i, 2]], problems)
|
653
689
|
end
|
654
690
|
|
655
691
|
def test_attribute_in_child_reference
|
656
692
|
env, problems = instantiate(%Q(
|
657
693
|
TestNode singleChild: "some text"
|
658
694
|
), TestMM2)
|
659
|
-
assert_problems([/argument 'singleChild' can only take child elements/i], problems)
|
695
|
+
assert_problems([[/argument 'singleChild' can only take child elements/i, 2]], problems)
|
660
696
|
end
|
661
697
|
|
662
698
|
def test_arguments_duplicate
|
663
699
|
env, problems = instantiate(%Q(
|
664
700
|
TestNode text: "some text", text: "more text"
|
665
701
|
), TestMM)
|
666
|
-
assert_problems([/argument 'text' already defined/i], problems)
|
702
|
+
assert_problems([[/argument 'text' already defined/i, 2]], problems)
|
667
703
|
end
|
668
704
|
|
669
705
|
def test_unlabled_arguments_duplicate
|
670
706
|
env, problems = instantiate(%Q(
|
671
707
|
TestNode text: "some text", "more text"
|
672
708
|
), TestMM, :unlabled_arguments => proc {|c| ["text"]})
|
673
|
-
assert_problems([/argument 'text' already defined/i], problems)
|
709
|
+
assert_problems([[/argument 'text' already defined/i, 2]], problems)
|
674
710
|
end
|
675
711
|
|
676
712
|
def test_multiple_arguments_in_non_many_attribute
|
677
713
|
env, problems = instantiate(%Q(
|
678
714
|
TestNode text: ["text1", "text2"]
|
679
715
|
), TestMM)
|
680
|
-
assert_problems([/argument 'text' can take only one value/i], problems)
|
716
|
+
assert_problems([[/argument 'text' can take only one value/i, 2]], problems)
|
681
717
|
end
|
682
718
|
|
683
719
|
def test_wrong_argument_type
|
@@ -693,15 +729,15 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
693
729
|
TestNode related: 1
|
694
730
|
), TestMM)
|
695
731
|
assert_problems([
|
696
|
-
/argument 'text' can not take a integer, expected string/i,
|
697
|
-
/argument 'integer' can not take a string, expected integer/i,
|
698
|
-
/argument 'integer' can not take a boolean, expected integer/i,
|
699
|
-
/argument 'integer' can not take a float, expected integer/i,
|
700
|
-
/argument 'integer' can not take a identifier, expected integer/i,
|
701
|
-
/argument 'integer' can not take a reference, expected integer/i,
|
702
|
-
/argument 'enum' can not take a integer, expected identifier/i,
|
703
|
-
/argument 'enum' can not take value x, expected A, B/i,
|
704
|
-
/argument 'related' can not take a integer, expected reference, identifier/i
|
732
|
+
[/argument 'text' can not take a integer, expected string/i, 2],
|
733
|
+
[/argument 'integer' can not take a string, expected integer/i, 3],
|
734
|
+
[/argument 'integer' can not take a boolean, expected integer/i, 4],
|
735
|
+
[/argument 'integer' can not take a float, expected integer/i, 5],
|
736
|
+
[/argument 'integer' can not take a identifier, expected integer/i, 6],
|
737
|
+
[/argument 'integer' can not take a reference, expected integer/i, 7],
|
738
|
+
[/argument 'enum' can not take a integer, expected identifier/i, 8],
|
739
|
+
[/argument 'enum' can not take value x, expected A, B/i, 9],
|
740
|
+
[/argument 'related' can not take a integer, expected reference, identifier/i, 10]
|
705
741
|
], problems)
|
706
742
|
end
|
707
743
|
|
@@ -710,14 +746,14 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
710
746
|
TestNode
|
711
747
|
}
|
712
748
|
), TestMM)
|
713
|
-
assert_problems([/unexpected \}, expected identifier/i], problems)
|
749
|
+
assert_problems([[/unexpected \}, expected identifier/i, 3]], problems)
|
714
750
|
end
|
715
751
|
|
716
752
|
def test_invalid_root
|
717
753
|
env, problems = instantiate(%Q(
|
718
754
|
NonRootClass
|
719
755
|
), TestMMNonRootClass)
|
720
|
-
assert_problems([/command 'NonRootClass' can not be used on root level/i], problems)
|
756
|
+
assert_problems([[/command 'NonRootClass' can not be used on root level/i, 2]], problems)
|
721
757
|
end
|
722
758
|
|
723
759
|
#
|
@@ -763,7 +799,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
763
799
|
assert_equal [1], root_elements[0].nums
|
764
800
|
assert_equal "bla", root_elements[0].text
|
765
801
|
assert_problems([
|
766
|
-
/unexpected label .*, expected ,/i,
|
802
|
+
[/unexpected label .*, expected ,/i, 2],
|
767
803
|
], problems)
|
768
804
|
end
|
769
805
|
|
@@ -775,8 +811,8 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
775
811
|
assert_equal 1, root_elements.size
|
776
812
|
assert_equal [1], root_elements[0].nums
|
777
813
|
assert_problems([
|
778
|
-
/unexpected string 'bla', expected ,/i,
|
779
|
-
/unexpected unlabled argument/i
|
814
|
+
[/unexpected string 'bla', expected ,/i, 2],
|
815
|
+
[/unexpected unlabled argument/i, 2]
|
780
816
|
], problems)
|
781
817
|
end
|
782
818
|
|
@@ -917,12 +953,12 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
917
953
|
assert_equal [1], root_elements[0].nums
|
918
954
|
assert_equal "bla", root_elements[1].text
|
919
955
|
assert_equal [1], root_elements[1].nums
|
956
|
+
assert_equal "bla", root_elements[2].text
|
920
957
|
assert_equal [1, 3], root_elements[3].nums
|
921
958
|
assert_problems([
|
922
959
|
[/parse error on token '\*'/i, 2],
|
923
960
|
[/parse error on token '\*'/i, 3],
|
924
|
-
[/parse error on token '\?
|
925
|
-
[/unexpected unlabled argument/i, 4],
|
961
|
+
[/parse error on token '\?'/i, 4],
|
926
962
|
[/parse error on token '\*'/i, 5],
|
927
963
|
], problems)
|
928
964
|
end
|
@@ -975,7 +1011,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
975
1011
|
], problems)
|
976
1012
|
end
|
977
1013
|
|
978
|
-
def
|
1014
|
+
def test_unclosed_child_bracket
|
979
1015
|
root_elements = []
|
980
1016
|
env, problems = instantiate(%Q(
|
981
1017
|
TestNode {
|
@@ -1195,7 +1231,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1195
1231
|
), TestMM, :comment_handler => proc {|c,k,e,env|
|
1196
1232
|
false
|
1197
1233
|
})
|
1198
|
-
assert_problems([/element can not take this comment
|
1234
|
+
assert_problems([[/element can not take this comment/, 3]], problems)
|
1199
1235
|
end
|
1200
1236
|
|
1201
1237
|
def test_comment_handler_comment_not_allowed_unassociated
|
@@ -1204,7 +1240,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1204
1240
|
), TestMM, :comment_handler => proc {|c,k,e,env|
|
1205
1241
|
false
|
1206
1242
|
})
|
1207
|
-
assert_problems([/Unassociated comment not allowed
|
1243
|
+
assert_problems([[/Unassociated comment not allowed/, 2]], problems)
|
1208
1244
|
end
|
1209
1245
|
|
1210
1246
|
#
|
@@ -1216,7 +1252,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1216
1252
|
@annotation
|
1217
1253
|
TestNode
|
1218
1254
|
), TestMM)
|
1219
|
-
assert_problems([/annotation not allowed/i], problems)
|
1255
|
+
assert_problems([[/annotation not allowed/i, 3]], problems)
|
1220
1256
|
end
|
1221
1257
|
|
1222
1258
|
def test_annotation_not_allowed
|
@@ -1226,7 +1262,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1226
1262
|
), TestMM, :annotation_handler => proc {|a,e,env|
|
1227
1263
|
false
|
1228
1264
|
})
|
1229
|
-
assert_problems([/annotation not allowed/i], problems)
|
1265
|
+
assert_problems([[/annotation not allowed/i, 3]], problems)
|
1230
1266
|
end
|
1231
1267
|
|
1232
1268
|
def test_annotation_in_wrong_places
|
@@ -1308,16 +1344,20 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1308
1344
|
TestNode text: <%a%>b%>
|
1309
1345
|
), TestMM, :enable_generics => true)
|
1310
1346
|
assert_problems([
|
1311
|
-
[/parse error on token '<
|
1347
|
+
[/parse error on token '<'/i, 2],
|
1348
|
+
[/unexpected unlabled argument/i, 2],
|
1312
1349
|
[/parse error on token '>'/i, 3],
|
1313
1350
|
[/unexpected identifier 'b'/i, 5],
|
1314
1351
|
[/parse error on token '>'/i, 5],
|
1315
1352
|
[/unexpected unlabled argument/i, 5],
|
1316
|
-
[/parse error on token '
|
1317
|
-
[/
|
1353
|
+
[/parse error on token '<'/i, 6],
|
1354
|
+
[/unexpected unlabled argument/i, 6],
|
1355
|
+
[/parse error on token '<'/i, 7],
|
1356
|
+
[/unexpected unlabled argument/i, 7],
|
1357
|
+
[/parse error on token '%'/i, 7],
|
1318
1358
|
[/unexpected identifier 'b'/i, 8],
|
1319
1359
|
[/unexpected unlabled argument/i, 8],
|
1320
|
-
[/parse error on token '
|
1360
|
+
[/parse error on token '%'/i, 8],
|
1321
1361
|
], problems)
|
1322
1362
|
end
|
1323
1363
|
|
@@ -1413,11 +1453,19 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1413
1453
|
TestNode float: 1.23
|
1414
1454
|
TestNode float: 1.23e-08
|
1415
1455
|
TestNode float: 1.23e+10
|
1456
|
+
TestNode float: 1234567890.123456789
|
1416
1457
|
), TestMM)
|
1417
1458
|
assert_no_problems(problems)
|
1418
1459
|
assert_equal 1.23, env.elements[0].float
|
1419
1460
|
assert_equal 1.23e-08, env.elements[1].float
|
1420
1461
|
assert_equal 1.23e+10, env.elements[2].float
|
1462
|
+
if rgen_with_bigdecimal?
|
1463
|
+
assert env.elements[3].float.is_a?(BigDecimal)
|
1464
|
+
assert_equal "1234567890.123456789", env.elements[3].float.to_s("F")
|
1465
|
+
else
|
1466
|
+
assert env.elements[3].float.is_a?(Float)
|
1467
|
+
assert_equal "1234567890.1234567", env.elements[3].float.to_s
|
1468
|
+
end
|
1421
1469
|
end
|
1422
1470
|
|
1423
1471
|
def test_boolean
|
@@ -1444,6 +1492,17 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1444
1492
|
assert_equal [:A, :B, :'non-word*chars', :'2you'], env.find(:text => "root").first.childs.collect{|c| c.enum}
|
1445
1493
|
end
|
1446
1494
|
|
1495
|
+
def test_with_bom
|
1496
|
+
env, problems = instantiate(%Q(\xEF\xBB\xBF
|
1497
|
+
TestNode text: "some text", nums: [1,2] {
|
1498
|
+
TestNode text: "child"
|
1499
|
+
TestNode text: "child2"
|
1500
|
+
}
|
1501
|
+
), TestMM)
|
1502
|
+
assert_no_problems(problems)
|
1503
|
+
assert_model_simple(env, :with_nums)
|
1504
|
+
end
|
1505
|
+
|
1447
1506
|
#
|
1448
1507
|
# conflicts with builtins
|
1449
1508
|
#
|
@@ -1475,7 +1534,7 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1475
1534
|
input.force_encoding("binary")
|
1476
1535
|
env, problems = instantiate(input, TestMM)
|
1477
1536
|
assert_no_problems(problems)
|
1478
|
-
assert_match env.elements.first.text
|
1537
|
+
assert_match /AE Umlaut: /, env.elements.first.text
|
1479
1538
|
end
|
1480
1539
|
|
1481
1540
|
private
|
@@ -1527,6 +1586,15 @@ class InstantiatorTest < Test::Unit::TestCase
|
|
1527
1586
|
end
|
1528
1587
|
end
|
1529
1588
|
|
1589
|
+
def rgen_with_bigdecimal?
|
1590
|
+
begin
|
1591
|
+
TestMM::TestNode.new.float = BigDecimal.new("0.0")
|
1592
|
+
rescue StandardError
|
1593
|
+
return false
|
1594
|
+
end
|
1595
|
+
true
|
1596
|
+
end
|
1597
|
+
|
1530
1598
|
end
|
1531
1599
|
|
1532
1600
|
|