rtext 0.8.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +116 -89
- data/Project.yaml +15 -0
- data/RText_Protocol +47 -4
- data/lib/rtext/context_builder.rb +49 -8
- data/lib/rtext/default_completer.rb +212 -163
- data/lib/rtext/default_service_provider.rb +3 -3
- data/lib/rtext/frontend/connector.rb +130 -56
- data/lib/rtext/instantiator.rb +8 -4
- data/lib/rtext/language.rb +5 -5
- data/lib/rtext/serializer.rb +3 -3
- data/lib/rtext/service.rb +281 -253
- data/lib/rtext/tokenizer.rb +1 -1
- metadata +32 -44
- data/Rakefile +0 -46
- data/test/completer_test.rb +0 -606
- data/test/context_builder_test.rb +0 -948
- data/test/frontend/context_test.rb +0 -301
- data/test/instantiator_test.rb +0 -1735
- data/test/integration/backend.out +0 -13
- data/test/integration/crash_on_request_editor.rb +0 -12
- data/test/integration/ecore_editor.rb +0 -50
- data/test/integration/frontend.log +0 -40502
- data/test/integration/model/invalid_encoding.invenc +0 -2
- data/test/integration/model/test.crash_on_request +0 -18
- data/test/integration/model/test.crashing_backend +0 -18
- data/test/integration/model/test.dont_open_socket +0 -0
- data/test/integration/model/test.invalid_cmd_line +0 -0
- data/test/integration/model/test.not_in_rtext +0 -0
- data/test/integration/model/test_large_with_errors.ect3 +0 -43523
- data/test/integration/model/test_metamodel.ect +0 -24
- data/test/integration/model/test_metamodel2.ect +0 -5
- data/test/integration/model/test_metamodel3.ect4 +0 -7
- data/test/integration/model/test_metamodel_error.ect2 +0 -3
- data/test/integration/model/test_metamodel_ok.ect2 +0 -18
- data/test/integration/test.rb +0 -966
- data/test/link_detector_test.rb +0 -287
- data/test/message_helper_test.rb +0 -118
- data/test/rtext_test.rb +0 -11
- data/test/serializer_test.rb +0 -1004
- data/test/tokenizer_test.rb +0 -173
data/test/link_detector_test.rb
DELETED
@@ -1,287 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rgen/metamodel_builder'
|
5
|
-
require 'rtext/language'
|
6
|
-
require 'rtext/link_detector'
|
7
|
-
|
8
|
-
class LinkDetectorTest < Test::Unit::TestCase
|
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
|
-
|
data/test/message_helper_test.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rtext/message_helper'
|
5
|
-
|
6
|
-
class MessageHelperTest < Test::Unit::TestCase
|
7
|
-
include RText::MessageHelper
|
8
|
-
|
9
|
-
def test_serialize
|
10
|
-
str = serialize_message({"key" => 1})
|
11
|
-
assert_equal '9{"key":1}', str
|
12
|
-
str = serialize_message({"key" => true})
|
13
|
-
assert_equal '12{"key":true}', str
|
14
|
-
str = serialize_message({"key" => "value"})
|
15
|
-
assert_equal '15{"key":"value"}', str
|
16
|
-
str = serialize_message({"key" => {"nested" => "value"}})
|
17
|
-
assert_equal '26{"key":{"nested":"value"}}', str
|
18
|
-
str = serialize_message({"key" => ["value1", "value2"]})
|
19
|
-
assert_equal '27{"key":["value1","value2"]}', str
|
20
|
-
|
21
|
-
# a iso-8859-1 '�'
|
22
|
-
str = serialize_message({"key" => "umlaut\xe4".force_encoding("binary")})
|
23
|
-
assert_equal '19{"key":"umlaut%e4"}', str
|
24
|
-
str = serialize_message({"key" => "umlaut\xe4".force_encoding("iso-8859-1")})
|
25
|
-
assert_equal '19{"key":"umlaut%e4"}', str
|
26
|
-
str = serialize_message({"key" => "umlaut\xe4".force_encoding("cp850")})
|
27
|
-
assert_equal '19{"key":"umlaut%e4"}', str
|
28
|
-
str = serialize_message({"key" => "umlaut\xe4".force_encoding("utf-8")})
|
29
|
-
assert_equal '19{"key":"umlaut%e4"}', str
|
30
|
-
|
31
|
-
# a utf-8 '�'
|
32
|
-
str = serialize_message({"key" => "umlaut\xc3\xa4".force_encoding("binary")})
|
33
|
-
assert_equal '22{"key":"umlaut%c3%a4"}', str
|
34
|
-
str = serialize_message({"key" => "umlaut\xc3\xa4".force_encoding("iso-8859-1")})
|
35
|
-
assert_equal '22{"key":"umlaut%c3%a4"}', str
|
36
|
-
str = serialize_message({"key" => "umlaut\xc3\xa4".force_encoding("cp850")})
|
37
|
-
assert_equal '22{"key":"umlaut%c3%a4"}', str
|
38
|
-
str = serialize_message({"key" => "umlaut\xc3\xa4".force_encoding("utf-8")})
|
39
|
-
assert_equal '22{"key":"umlaut%c3%a4"}', str
|
40
|
-
|
41
|
-
# %
|
42
|
-
str = serialize_message({"key" => "%"})
|
43
|
-
assert_equal '13{"key":"%25"}', str
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_extract
|
47
|
-
# specified length too short
|
48
|
-
assert_raise JSON::ParserError do
|
49
|
-
extract_message('8{"key":1}')
|
50
|
-
end
|
51
|
-
# specified length too long
|
52
|
-
assert_raise JSON::ParserError do
|
53
|
-
extract_message('10{"key":1}x')
|
54
|
-
end
|
55
|
-
# message data shorter than length specifie, waits for more data
|
56
|
-
assert_nothing_raised do
|
57
|
-
extract_message('10{"key":1}')
|
58
|
-
end
|
59
|
-
|
60
|
-
obj = extract_message('9{"key":1}')
|
61
|
-
assert_equal({"key" => 1}, obj)
|
62
|
-
obj = extract_message('12{"key":true}')
|
63
|
-
assert_equal({"key" => true}, obj)
|
64
|
-
obj = extract_message('15{"key":"value"}')
|
65
|
-
assert_equal({"key" => "value"}, obj)
|
66
|
-
obj = extract_message('26{"key":{"nested":"value"}}')
|
67
|
-
assert_equal({"key" => {"nested" => "value"}}, obj)
|
68
|
-
obj = extract_message('27{"key":["value1","value2"]}')
|
69
|
-
assert_equal({"key" => ["value1", "value2"]}, obj)
|
70
|
-
|
71
|
-
# a iso-8859-1 '�'
|
72
|
-
obj = extract_message('19{"key":"umlaut%e4"}'.force_encoding("binary"))
|
73
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
74
|
-
assert_equal "umlaut\xe4".force_encoding("ascii-8bit"), obj["key"]
|
75
|
-
obj = extract_message('19{"key":"umlaut%e4"}'.force_encoding("utf-8"))
|
76
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
77
|
-
assert_equal "umlaut\xe4".force_encoding("ascii-8bit"), obj["key"]
|
78
|
-
|
79
|
-
# a utf-8 '�'
|
80
|
-
obj = extract_message('22{"key":"umlaut%c3%a4"}'.force_encoding("binary"))
|
81
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
82
|
-
assert_equal "umlaut\xc3\xa4".force_encoding("ascii-8bit"), obj["key"]
|
83
|
-
obj = extract_message('22{"key":"umlaut%c3%a4"}'.force_encoding("utf-8"))
|
84
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
85
|
-
assert_equal "umlaut\xc3\xa4".force_encoding("ascii-8bit"), obj["key"]
|
86
|
-
|
87
|
-
# %
|
88
|
-
obj = extract_message('13{"key":"%25"}')
|
89
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
90
|
-
assert_equal "%", obj["key"]
|
91
|
-
|
92
|
-
# invalid escape sequence
|
93
|
-
obj = extract_message('11{"key":"%"}')
|
94
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
95
|
-
assert_equal "%", obj["key"]
|
96
|
-
obj = extract_message('13{"key":"%xx"}')
|
97
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
98
|
-
assert_equal "%xx", obj["key"]
|
99
|
-
obj = extract_message('14{"key":"%%25"}')
|
100
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
101
|
-
assert_equal "%%", obj["key"]
|
102
|
-
|
103
|
-
# invalid characters (protocol should use 7-bit ascii only)
|
104
|
-
obj = extract_message(%Q(14{"key":"\xe4345"}).force_encoding("binary"))
|
105
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
106
|
-
assert_equal "?345", obj["key"]
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_roundtrip
|
110
|
-
value = (0..255).collect{|b| b.chr("binary")}.join
|
111
|
-
str = serialize_message({"key" => value})
|
112
|
-
obj = extract_message(str)
|
113
|
-
assert_equal "ASCII-8BIT", obj["key"].encoding.name
|
114
|
-
assert_equal (0..255).collect{|i| i}, obj["key"].bytes.to_a
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
data/test/rtext_test.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
2
|
-
|
3
|
-
require 'serializer_test'
|
4
|
-
require 'instantiator_test'
|
5
|
-
require 'context_builder_test'
|
6
|
-
require 'completer_test'
|
7
|
-
require 'tokenizer_test'
|
8
|
-
require 'link_detector_test'
|
9
|
-
require 'integration/test'
|
10
|
-
require 'message_helper_test'
|
11
|
-
require 'frontend/context_test'
|