rtext 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,288 +1,287 @@
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/link_detector'
8
-
9
- class LinkDetectorTest < MiniTest::Test
10
-
11
- module TestMM
12
- extend RGen::MetamodelBuilder::ModuleExtension
13
- class TestNode2 < RGen::MetamodelBuilder::MMBase
14
- has_attr 'name', String
15
- end
16
- class TestNode < RGen::MetamodelBuilder::MMBase
17
- has_attr 'name', String
18
- has_attr 'id', Integer
19
- has_one 'related', TestNode
20
- has_many 'others', TestNode
21
- contains_many 'children', TestNode2, 'parent'
22
- end
23
- end
24
-
25
- def test_before_command
26
- ld = build_link_desc TestMM, <<-END
27
- |TestNode SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
28
- END
29
- assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => true, :value => "TestNode", :scol => 1, :ecol => 8
30
- end
31
-
32
- def test_in_command
33
- ld = build_link_desc TestMM, <<-END
34
- Test|Node SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
35
- END
36
- assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => true, :value => "TestNode", :scol => 1, :ecol => 8
37
- end
38
-
39
- def test_end_of_command
40
- ld = build_link_desc TestMM, <<-END
41
- TestNod|e SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
42
- END
43
- assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => true, :value => "TestNode", :scol => 1, :ecol => 8
44
- end
45
-
46
- def test_after_command
47
- ld = build_link_desc TestMM, <<-END
48
- TestNode| SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
49
- END
50
- assert_nil ld
51
- end
52
-
53
- def test_in_name
54
- ld = build_link_desc TestMM, <<-END
55
- TestNode So|meNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
56
- END
57
- assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => false, :value => "SomeNode", :scol => 10, :ecol => 17
58
- end
59
-
60
- def test_in_name_with_quotes
61
- ld = build_link_desc TestMM, <<-END
62
- TestNode "So|meNode", id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
63
- END
64
- assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => false, :value => "SomeNode", :scol => 10, :ecol => 19
65
- end
66
-
67
- def test_after_comma
68
- ld = build_link_desc TestMM, <<-END
69
- TestNode SomeNode,| id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
70
- END
71
- assert_nil ld
72
- end
73
-
74
- def test_after_label
75
- ld = build_link_desc TestMM, <<-END
76
- TestNode SomeNode, id:| 1234, related: /Other/Node, others: [/NodeA, /Node/B]
77
- END
78
- assert_nil ld
79
- end
80
-
81
- def test_beginning_of_labled_argument
82
- ld = build_link_desc TestMM, <<-END
83
- TestNode SomeNode, id: |1234, related: /Other/Node, others: [/NodeA, /Node/B]
84
- END
85
- assert_link_desc ld, :element => "TestNode", :feature => "id", :index => 0, :backward => false, :value => 1234, :scol => 24, :ecol => 27
86
- end
87
-
88
- def test_in_labled_argument
89
- ld = build_link_desc TestMM, <<-END
90
- TestNode SomeNode, id: 123|4, related: /Other/Node, others: [/NodeA, /Node/B]
91
- END
92
- assert_link_desc ld, :element => "TestNode", :feature => "id", :index => 0, :backward => false, :value => 1234, :scol => 24, :ecol => 27
93
- end
94
-
95
- def test_after_labled_argument
96
- ld = build_link_desc TestMM, <<-END
97
- TestNode SomeNode, id: 1234|, related: /Other/Node, others: [/NodeA, /Node/B]
98
- END
99
- assert_nil ld
100
- end
101
-
102
- def test_in_label
103
- ld = build_link_desc TestMM, <<-END
104
- TestNode SomeNode, id: 1234, re|lated: /Other/Node, others: [/NodeA, /Node/B]
105
- END
106
- assert_nil ld
107
- end
108
-
109
- def test_in_reference
110
- ld = build_link_desc TestMM, <<-END
111
- TestNode SomeNode, id: 1234, related: /O|ther/Node, others: [/NodeA, /Node/B]
112
- END
113
- assert_link_desc ld, :element => "TestNode", :feature => "related", :index => 0, :backward => false, :value => "/Other/Node", :scol => 39, :ecol => 49
114
- end
115
-
116
- def test_before_array
117
- ld = build_link_desc TestMM, <<-END
118
- TestNode SomeNode, id: 1234, related: /Other/Node, others: |[/NodeA, /Node/B]
119
- END
120
- assert_nil ld
121
- end
122
-
123
- def test_ref_in_array
124
- ld = build_link_desc TestMM, <<-END
125
- TestNode SomeNode, id: 1234, related: /Other/Node, others: [|/NodeA, /Node/B]
126
- END
127
- assert_link_desc ld, :element => "TestNode", :feature => "others", :index => 0, :backward => false, :value => "/NodeA", :scol => 61, :ecol => 66
128
- end
129
-
130
- def test_second_ref_in_array
131
- ld = build_link_desc TestMM, <<-END
132
- TestNode SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/|B]
133
- END
134
- assert_link_desc ld, :element => "TestNode", :feature => "others", :index => 1, :backward => false, :value => "/Node/B", :scol => 69, :ecol => 75
135
- end
136
-
137
- def test_backward_ref_name_in_command
138
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
139
- |TestNode SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
140
- END
141
- )
142
- assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => false, :value => "TestNode", :scol => 1, :ecol => 8
143
- end
144
-
145
- def test_backward_ref_name_in_name
146
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
147
- TestNode Som|eNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
148
- END
149
- )
150
- assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => true, :value => "SomeNode", :scol => 10, :ecol => 17
151
- end
152
-
153
- def test_backward_ref_name_with_quotes
154
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
155
- TestNode "Som|eNode", id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
156
- END
157
- )
158
- assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => true, :value => "SomeNode", :scol => 10, :ecol => 19
159
- end
160
-
161
- def test_backward_ref_id_in_id
162
- ld = build_link_desc(TestMM, {:backward_ref => "id"}, <<-END
163
- TestNode SomeNode, id: |1234, related: /Other/Node, others: [/NodeA, /Node/B]
164
- END
165
- )
166
- assert_link_desc ld, :element => "TestNode", :feature => "id", :index => 0, :backward => true, :value => 1234, :scol => 24, :ecol => 27
167
- end
168
-
169
- def test_command_only
170
- ld = build_link_desc(TestMM, <<-END
171
- Tes|tNode
172
- END
173
- )
174
- assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => true, :value => "TestNode", :scol => 1, :ecol => 8
175
- end
176
-
177
- def test_command_and_name_only
178
- ld = build_link_desc(TestMM, <<-END
179
- TestNode |SomeNode
180
- END
181
- )
182
- assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => false, :value => "SomeNode", :scol => 10, :ecol => 17
183
- end
184
-
185
- def test_command_and_name_only_backward_ref_name
186
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
187
- TestNode |SomeNode
188
- END
189
- )
190
- assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => true, :value => "SomeNode", :scol => 10, :ecol => 17
191
- end
192
-
193
- def test_command_and_name_curly_no_ws
194
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
195
- TestNode Some|Node{
196
- END
197
- )
198
- assert_link_desc ld, :element => "TestNode", :element_name => "SomeNode", :feature => "name", :index => 0, :backward => true, :value => "SomeNode", :scol => 10, :ecol => 17
199
- end
200
-
201
- def test_child_within_command
202
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
203
- TestNode SomeNode {
204
- Test|Node2 SomeOtherNode
205
- END
206
- )
207
- assert_link_desc ld, :element => "TestNode2", :feature => nil, :backward => false, :value => "TestNode2", :scol => 3, :ecol => 11
208
- end
209
-
210
- def test_child_with_label_after_command
211
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
212
- TestNode SomeNode {
213
- children:
214
- TestNode2 |SomeOtherNode
215
- END
216
- )
217
- assert_link_desc ld, :element => "TestNode2", :feature => "name", :index => 0, :backward => true, :value => "SomeOtherNode", :scol => 15, :ecol => 27
218
- end
219
-
220
- def test_child_with_label_within_command
221
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
222
- TestNode SomeNode {
223
- children:
224
- Test|Node2 SomeOtherNode
225
- END
226
- )
227
- assert_link_desc ld, :element => "TestNode2", :feature => nil, :backward => false, :value => "TestNode2", :scol => 5, :ecol => 13
228
- end
229
-
230
- def test_child_with_label_within_command_square_brackets
231
- ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
232
- TestNode SomeNode {
233
- children: [
234
- Test|Node2 SomeOtherNode
235
- END
236
- )
237
- assert_link_desc ld, :element => "TestNode2", :feature => nil, :backward => false, :value => "TestNode2", :scol => 5, :ecol => 13
238
- end
239
-
240
- def build_link_desc(mm, text, text2=nil)
241
- if text.is_a?(Hash)
242
- options = text
243
- context_lines = text2.split("\n")
244
- else
245
- options = {}
246
- context_lines = text.split("\n")
247
- end
248
- pos_in_line = context_lines.last.index("|")+1
249
- context_lines.last.sub!("|", "")
250
- lang = RText::Language.new(mm.ecore,
251
- :unlabled_arguments => proc {|c| ["name"]},
252
- :backward_ref_attribute => proc {|c|
253
- if options[:backward_ref]
254
- options[:backward_ref]
255
- else
256
- nil
257
- end
258
- })
259
- RText::LinkDetector.new(lang).detect(context_lines, pos_in_line)
260
- end
261
-
262
- def assert_link_desc(ld, options)
263
- if options[:element]
264
- assert_equal options[:element], ld.element.class.ecore.name
265
- else
266
- assert_nil ld.element
267
- end
268
- if options[:element_name]
269
- assert_equal options[:element_name], ld.element.name
270
- end
271
- if options[:feature]
272
- assert_equal options[:feature], ld.feature.name
273
- else
274
- assert_nil ld.feature
275
- end
276
- if options[:index]
277
- assert_equal options[:index], ld.index
278
- else
279
- assert_nil ld.index
280
- end
281
- assert_equal options[:backward], ld.backward
282
- assert_equal options[:value], ld.value
283
- assert_equal options[:scol], ld.scol
284
- assert_equal options[:ecol], ld.ecol
285
- end
286
-
287
- end
288
-
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/link_detector'
7
+
8
+ class LinkDetectorTest < MiniTest::Test
9
+
10
+ module TestMM
11
+ extend RGen::MetamodelBuilder::ModuleExtension
12
+ class TestNode2 < RGen::MetamodelBuilder::MMBase
13
+ has_attr 'name', String
14
+ end
15
+ class TestNode < RGen::MetamodelBuilder::MMBase
16
+ has_attr 'name', String
17
+ has_attr 'id', Integer
18
+ has_one 'related', TestNode
19
+ has_many 'others', TestNode
20
+ contains_many 'children', TestNode2, 'parent'
21
+ end
22
+ end
23
+
24
+ def test_before_command
25
+ ld = build_link_desc TestMM, <<-END
26
+ |TestNode SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
27
+ END
28
+ assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => true, :value => "TestNode", :scol => 1, :ecol => 8
29
+ end
30
+
31
+ def test_in_command
32
+ ld = build_link_desc TestMM, <<-END
33
+ Test|Node SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
34
+ END
35
+ assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => true, :value => "TestNode", :scol => 1, :ecol => 8
36
+ end
37
+
38
+ def test_end_of_command
39
+ ld = build_link_desc TestMM, <<-END
40
+ TestNod|e SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
41
+ END
42
+ assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => true, :value => "TestNode", :scol => 1, :ecol => 8
43
+ end
44
+
45
+ def test_after_command
46
+ ld = build_link_desc TestMM, <<-END
47
+ TestNode| SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
48
+ END
49
+ assert_nil ld
50
+ end
51
+
52
+ def test_in_name
53
+ ld = build_link_desc TestMM, <<-END
54
+ TestNode So|meNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
55
+ END
56
+ assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => false, :value => "SomeNode", :scol => 10, :ecol => 17
57
+ end
58
+
59
+ def test_in_name_with_quotes
60
+ ld = build_link_desc TestMM, <<-END
61
+ TestNode "So|meNode", id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
62
+ END
63
+ assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => false, :value => "SomeNode", :scol => 10, :ecol => 19
64
+ end
65
+
66
+ def test_after_comma
67
+ ld = build_link_desc TestMM, <<-END
68
+ TestNode SomeNode,| id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
69
+ END
70
+ assert_nil ld
71
+ end
72
+
73
+ def test_after_label
74
+ ld = build_link_desc TestMM, <<-END
75
+ TestNode SomeNode, id:| 1234, related: /Other/Node, others: [/NodeA, /Node/B]
76
+ END
77
+ assert_nil ld
78
+ end
79
+
80
+ def test_beginning_of_labled_argument
81
+ ld = build_link_desc TestMM, <<-END
82
+ TestNode SomeNode, id: |1234, related: /Other/Node, others: [/NodeA, /Node/B]
83
+ END
84
+ assert_link_desc ld, :element => "TestNode", :feature => "id", :index => 0, :backward => false, :value => 1234, :scol => 24, :ecol => 27
85
+ end
86
+
87
+ def test_in_labled_argument
88
+ ld = build_link_desc TestMM, <<-END
89
+ TestNode SomeNode, id: 123|4, related: /Other/Node, others: [/NodeA, /Node/B]
90
+ END
91
+ assert_link_desc ld, :element => "TestNode", :feature => "id", :index => 0, :backward => false, :value => 1234, :scol => 24, :ecol => 27
92
+ end
93
+
94
+ def test_after_labled_argument
95
+ ld = build_link_desc TestMM, <<-END
96
+ TestNode SomeNode, id: 1234|, related: /Other/Node, others: [/NodeA, /Node/B]
97
+ END
98
+ assert_nil ld
99
+ end
100
+
101
+ def test_in_label
102
+ ld = build_link_desc TestMM, <<-END
103
+ TestNode SomeNode, id: 1234, re|lated: /Other/Node, others: [/NodeA, /Node/B]
104
+ END
105
+ assert_nil ld
106
+ end
107
+
108
+ def test_in_reference
109
+ ld = build_link_desc TestMM, <<-END
110
+ TestNode SomeNode, id: 1234, related: /O|ther/Node, others: [/NodeA, /Node/B]
111
+ END
112
+ assert_link_desc ld, :element => "TestNode", :feature => "related", :index => 0, :backward => false, :value => "/Other/Node", :scol => 39, :ecol => 49
113
+ end
114
+
115
+ def test_before_array
116
+ ld = build_link_desc TestMM, <<-END
117
+ TestNode SomeNode, id: 1234, related: /Other/Node, others: |[/NodeA, /Node/B]
118
+ END
119
+ assert_nil ld
120
+ end
121
+
122
+ def test_ref_in_array
123
+ ld = build_link_desc TestMM, <<-END
124
+ TestNode SomeNode, id: 1234, related: /Other/Node, others: [|/NodeA, /Node/B]
125
+ END
126
+ assert_link_desc ld, :element => "TestNode", :feature => "others", :index => 0, :backward => false, :value => "/NodeA", :scol => 61, :ecol => 66
127
+ end
128
+
129
+ def test_second_ref_in_array
130
+ ld = build_link_desc TestMM, <<-END
131
+ TestNode SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/|B]
132
+ END
133
+ assert_link_desc ld, :element => "TestNode", :feature => "others", :index => 1, :backward => false, :value => "/Node/B", :scol => 69, :ecol => 75
134
+ end
135
+
136
+ def test_backward_ref_name_in_command
137
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
138
+ |TestNode SomeNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
139
+ END
140
+ )
141
+ assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => false, :value => "TestNode", :scol => 1, :ecol => 8
142
+ end
143
+
144
+ def test_backward_ref_name_in_name
145
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
146
+ TestNode Som|eNode, id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
147
+ END
148
+ )
149
+ assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => true, :value => "SomeNode", :scol => 10, :ecol => 17
150
+ end
151
+
152
+ def test_backward_ref_name_with_quotes
153
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
154
+ TestNode "Som|eNode", id: 1234, related: /Other/Node, others: [/NodeA, /Node/B]
155
+ END
156
+ )
157
+ assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => true, :value => "SomeNode", :scol => 10, :ecol => 19
158
+ end
159
+
160
+ def test_backward_ref_id_in_id
161
+ ld = build_link_desc(TestMM, {:backward_ref => "id"}, <<-END
162
+ TestNode SomeNode, id: |1234, related: /Other/Node, others: [/NodeA, /Node/B]
163
+ END
164
+ )
165
+ assert_link_desc ld, :element => "TestNode", :feature => "id", :index => 0, :backward => true, :value => 1234, :scol => 24, :ecol => 27
166
+ end
167
+
168
+ def test_command_only
169
+ ld = build_link_desc(TestMM, <<-END
170
+ Tes|tNode
171
+ END
172
+ )
173
+ assert_link_desc ld, :element => "TestNode", :feature => nil, :backward => true, :value => "TestNode", :scol => 1, :ecol => 8
174
+ end
175
+
176
+ def test_command_and_name_only
177
+ ld = build_link_desc(TestMM, <<-END
178
+ TestNode |SomeNode
179
+ END
180
+ )
181
+ assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => false, :value => "SomeNode", :scol => 10, :ecol => 17
182
+ end
183
+
184
+ def test_command_and_name_only_backward_ref_name
185
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
186
+ TestNode |SomeNode
187
+ END
188
+ )
189
+ assert_link_desc ld, :element => "TestNode", :feature => "name", :index => 0, :backward => true, :value => "SomeNode", :scol => 10, :ecol => 17
190
+ end
191
+
192
+ def test_command_and_name_curly_no_ws
193
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
194
+ TestNode Some|Node{
195
+ END
196
+ )
197
+ assert_link_desc ld, :element => "TestNode", :element_name => "SomeNode", :feature => "name", :index => 0, :backward => true, :value => "SomeNode", :scol => 10, :ecol => 17
198
+ end
199
+
200
+ def test_child_within_command
201
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
202
+ TestNode SomeNode {
203
+ Test|Node2 SomeOtherNode
204
+ END
205
+ )
206
+ assert_link_desc ld, :element => "TestNode2", :feature => nil, :backward => false, :value => "TestNode2", :scol => 3, :ecol => 11
207
+ end
208
+
209
+ def test_child_with_label_after_command
210
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
211
+ TestNode SomeNode {
212
+ children:
213
+ TestNode2 |SomeOtherNode
214
+ END
215
+ )
216
+ assert_link_desc ld, :element => "TestNode2", :feature => "name", :index => 0, :backward => true, :value => "SomeOtherNode", :scol => 15, :ecol => 27
217
+ end
218
+
219
+ def test_child_with_label_within_command
220
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
221
+ TestNode SomeNode {
222
+ children:
223
+ Test|Node2 SomeOtherNode
224
+ END
225
+ )
226
+ assert_link_desc ld, :element => "TestNode2", :feature => nil, :backward => false, :value => "TestNode2", :scol => 5, :ecol => 13
227
+ end
228
+
229
+ def test_child_with_label_within_command_square_brackets
230
+ ld = build_link_desc(TestMM, {:backward_ref => "name"}, <<-END
231
+ TestNode SomeNode {
232
+ children: [
233
+ Test|Node2 SomeOtherNode
234
+ END
235
+ )
236
+ assert_link_desc ld, :element => "TestNode2", :feature => nil, :backward => false, :value => "TestNode2", :scol => 5, :ecol => 13
237
+ end
238
+
239
+ def build_link_desc(mm, text, text2=nil)
240
+ if text.is_a?(Hash)
241
+ options = text
242
+ context_lines = text2.split("\n")
243
+ else
244
+ options = {}
245
+ context_lines = text.split("\n")
246
+ end
247
+ pos_in_line = context_lines.last.index("|")+1
248
+ context_lines.last.sub!("|", "")
249
+ lang = RText::Language.new(mm.ecore,
250
+ :unlabled_arguments => proc {|c| ["name"]},
251
+ :backward_ref_attribute => proc {|c|
252
+ if options[:backward_ref]
253
+ options[:backward_ref]
254
+ else
255
+ nil
256
+ end
257
+ })
258
+ RText::LinkDetector.new(lang).detect(context_lines, pos_in_line)
259
+ end
260
+
261
+ def assert_link_desc(ld, options)
262
+ if options[:element]
263
+ assert_equal options[:element], ld.element.class.ecore.name
264
+ else
265
+ assert_nil ld.element
266
+ end
267
+ if options[:element_name]
268
+ assert_equal options[:element_name], ld.element.name
269
+ end
270
+ if options[:feature]
271
+ assert_equal options[:feature], ld.feature.name
272
+ else
273
+ assert_nil ld.feature
274
+ end
275
+ if options[:index]
276
+ assert_equal options[:index], ld.index
277
+ else
278
+ assert_nil ld.index
279
+ end
280
+ assert_equal options[:backward], ld.backward
281
+ assert_equal options[:value], ld.value
282
+ assert_equal options[:scol], ld.scol
283
+ assert_equal options[:ecol], ld.ecol
284
+ end
285
+
286
+ end
287
+