rtype-legacy-java 0.0.4-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +9 -0
- data/README.md +475 -0
- data/Rakefile +12 -0
- data/benchmark/benchmark.rb +104 -0
- data/ext/rtype/legacy/rtype_legacy_java.jar +0 -0
- data/spec/rtype_legacy_spec.rb +971 -0
- data/spec/spec_helper.rb +14 -0
- metadata +97 -0
@@ -0,0 +1,971 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Rtype::Legacy do
|
4
|
+
let(:klass) do
|
5
|
+
Class.new do
|
6
|
+
attr_accessor :value
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@value = 123
|
10
|
+
end
|
11
|
+
|
12
|
+
def return_arg(obj)
|
13
|
+
obj
|
14
|
+
end
|
15
|
+
|
16
|
+
def two_args(a, b)
|
17
|
+
end
|
18
|
+
|
19
|
+
def three_args(a, b, c)
|
20
|
+
end
|
21
|
+
|
22
|
+
def return_nil(obj)
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def sum(a, b)
|
27
|
+
a + b
|
28
|
+
end
|
29
|
+
|
30
|
+
public
|
31
|
+
def public_func
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
def protected_func
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def private_func
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:instance) do
|
45
|
+
klass.new
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'Kernel#rtype' do
|
49
|
+
context "with annotation mode" do
|
50
|
+
it "works with instance method" do
|
51
|
+
class AnnotationTest
|
52
|
+
rtype [String] => Any
|
53
|
+
def test(str)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
expect {
|
57
|
+
AnnotationTest.new.test(123)
|
58
|
+
}.to raise_error Rtype::ArgumentTypeError
|
59
|
+
end
|
60
|
+
it "works with class method" do
|
61
|
+
class AnnotationTest
|
62
|
+
rtype [String] => Any
|
63
|
+
def self.class_method_test(str)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
expect {
|
67
|
+
AnnotationTest::class_method_test(123)
|
68
|
+
}.to raise_error Rtype::ArgumentTypeError
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "outside of module" do
|
73
|
+
it "doesn't work" do
|
74
|
+
expect {
|
75
|
+
rtype :test_args, [String] => Any
|
76
|
+
def test_args(str)
|
77
|
+
end
|
78
|
+
}.to raise_error RuntimeError
|
79
|
+
|
80
|
+
expect {
|
81
|
+
rtype [String] => Any
|
82
|
+
def test_args2(str)
|
83
|
+
end
|
84
|
+
}.to raise_error RuntimeError
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "in module" do
|
89
|
+
class TestClass
|
90
|
+
rtype :test_args, [String] => Any
|
91
|
+
def test_args(str)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
expect {TestClass.new.test_args 123}.to raise_error Rtype::ArgumentTypeError
|
96
|
+
|
97
|
+
class TestClass
|
98
|
+
rtype :test_return, [] => String
|
99
|
+
def test_return
|
100
|
+
369
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
expect {TestClass.new.test_return}.to raise_error Rtype::ReturnTypeError
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it "Kernel#rtype_self" do
|
109
|
+
class TestClass
|
110
|
+
rtype_self :static_test_args, [String] => Any
|
111
|
+
def self.static_test_args(str)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
expect {TestClass::static_test_args 123}.to raise_error Rtype::ArgumentTypeError
|
116
|
+
|
117
|
+
class TestClass
|
118
|
+
rtype_self :static_test_return, [] => String
|
119
|
+
def self.static_test_return
|
120
|
+
369
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
expect {TestClass::static_test_return}.to raise_error Rtype::ReturnTypeError
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'Kernel#rtype_accessor' do
|
128
|
+
class TestClass
|
129
|
+
rtype_accessor :value, :value2, String
|
130
|
+
|
131
|
+
def initialize
|
132
|
+
@value = 123
|
133
|
+
@value2 = 123
|
134
|
+
end
|
135
|
+
end
|
136
|
+
expect {TestClass.new.value = 123}.to raise_error Rtype::ArgumentTypeError
|
137
|
+
expect {TestClass.new.value}.to raise_error Rtype::ReturnTypeError
|
138
|
+
expect {TestClass.new.value2 = 123}.to raise_error Rtype::ArgumentTypeError
|
139
|
+
expect {TestClass.new.value2}.to raise_error Rtype::ReturnTypeError
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'Kernel#rtype_accessor_self' do
|
143
|
+
class TestClass
|
144
|
+
@@value = 123
|
145
|
+
@@value2 = 123
|
146
|
+
|
147
|
+
rtype_accessor_self :value, :value2, String
|
148
|
+
end
|
149
|
+
expect {TestClass::value = 123}.to raise_error Rtype::ArgumentTypeError
|
150
|
+
expect {TestClass::value}.to raise_error Rtype::ReturnTypeError
|
151
|
+
expect {TestClass::value2 = 123}.to raise_error Rtype::ArgumentTypeError
|
152
|
+
expect {TestClass::value2}.to raise_error Rtype::ReturnTypeError
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'Kernel#rtype_reader' do
|
156
|
+
class ReaderTestClass
|
157
|
+
rtype_reader :value, :value2, String
|
158
|
+
|
159
|
+
def initialize
|
160
|
+
@value = 123
|
161
|
+
@value2 = 123
|
162
|
+
end
|
163
|
+
end
|
164
|
+
expect {ReaderTestClass.new.value}.to raise_error Rtype::ReturnTypeError
|
165
|
+
expect {ReaderTestClass.new.value2}.to raise_error Rtype::ReturnTypeError
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'Kernel#rtype_reader_self' do
|
169
|
+
class ReaderTestClass
|
170
|
+
@@value = 123
|
171
|
+
@@value2 = 123
|
172
|
+
rtype_reader_self :value, :value2, String
|
173
|
+
end
|
174
|
+
expect {ReaderTestClass::value}.to raise_error Rtype::ReturnTypeError
|
175
|
+
expect {ReaderTestClass::value2}.to raise_error Rtype::ReturnTypeError
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'Kernel#rtype_writer' do
|
179
|
+
class WriterTestClass
|
180
|
+
rtype_writer :value, :value2, String
|
181
|
+
|
182
|
+
def initialize
|
183
|
+
@value = 123
|
184
|
+
@value2 = 123
|
185
|
+
end
|
186
|
+
end
|
187
|
+
expect {WriterTestClass.new.value = 123}.to raise_error Rtype::ArgumentTypeError
|
188
|
+
expect {WriterTestClass.new.value2 = 123}.to raise_error Rtype::ArgumentTypeError
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'Kernel#rtype_writer_self' do
|
192
|
+
class WriterTestClass
|
193
|
+
@@value = 123
|
194
|
+
@@value2 = 123
|
195
|
+
rtype_writer_self :value, :value2, String
|
196
|
+
end
|
197
|
+
expect {WriterTestClass::value = 123}.to raise_error Rtype::ArgumentTypeError
|
198
|
+
expect {WriterTestClass::value2 = 123}.to raise_error Rtype::ArgumentTypeError
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'Kernel#float_accessor' do
|
202
|
+
class FloatAccessorTestClass
|
203
|
+
float_accessor :float, :int
|
204
|
+
|
205
|
+
def initialize
|
206
|
+
@float = 10.0
|
207
|
+
@int = 10
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
float_accessor_test = FloatAccessorTestClass.new
|
212
|
+
|
213
|
+
float_accessor_test.float
|
214
|
+
expect {float_accessor_test.int}.to raise_error Rtype::ReturnTypeError
|
215
|
+
float_accessor_test.float = 5.0
|
216
|
+
float_accessor_test.float = 5
|
217
|
+
expect(float_accessor_test.float).to eql(5.0) # be(expected) => passes if actual.eql?(expected)
|
218
|
+
expect(float_accessor_test.float).not_to eql(5)
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'Kernel#bool_accessor' do
|
222
|
+
class BoolAccessorTestClass
|
223
|
+
bool_accessor :state, :invalid_var
|
224
|
+
|
225
|
+
def initialize
|
226
|
+
@state = false
|
227
|
+
@invalid_var = 123
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
bool_accessor_test = BoolAccessorTestClass.new
|
232
|
+
|
233
|
+
bool_accessor_test.state?
|
234
|
+
expect {bool_accessor_test.state}.to raise_error NoMethodError
|
235
|
+
expect(bool_accessor_test.state?).to eql(false)
|
236
|
+
bool_accessor_test.state = true
|
237
|
+
expect(bool_accessor_test.state?).to eql(true)
|
238
|
+
expect {bool_accessor_test.state = 123}.to raise_error Rtype::ArgumentTypeError
|
239
|
+
expect {bool_accessor_test.invalid_var?}.to raise_error Rtype::ReturnTypeError
|
240
|
+
end
|
241
|
+
|
242
|
+
describe 'Test type behaviors' do
|
243
|
+
describe 'Module' do
|
244
|
+
it "is right" do
|
245
|
+
klass.send :rtype, :return_arg, [String] => Any
|
246
|
+
instance.return_arg("This is a string!")
|
247
|
+
end
|
248
|
+
it "is wrong" do
|
249
|
+
klass.send :rtype, :return_arg, [String] => Any
|
250
|
+
expect {instance.return_arg(123)}.to raise_error Rtype::ArgumentTypeError
|
251
|
+
end
|
252
|
+
it "is wrong result" do
|
253
|
+
klass.send :rtype, :return_nil, [Any] => String
|
254
|
+
expect {instance.return_nil("This is a string!")}.to raise_error Rtype::ReturnTypeError
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
describe 'Symbol' do
|
259
|
+
it "is right" do
|
260
|
+
klass.send :rtype, :return_arg, [:to_i] => Any
|
261
|
+
instance.return_arg(123)
|
262
|
+
end
|
263
|
+
it "is wrong args" do
|
264
|
+
klass.send :rtype, :return_arg, [:to_i] => Any
|
265
|
+
expect {instance.return_arg(true)}.to raise_error Rtype::ArgumentTypeError
|
266
|
+
end
|
267
|
+
it "is wrong result" do
|
268
|
+
klass.send :rtype, :return_nil, [Any] => :odd?
|
269
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ReturnTypeError
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
describe 'Regexp' do
|
274
|
+
it "is right" do
|
275
|
+
klass.send :rtype, :return_arg, [/cuba/] => Any
|
276
|
+
instance.return_arg("cuba")
|
277
|
+
end
|
278
|
+
it "is wrong args" do
|
279
|
+
klass.send :rtype, :return_arg, [/cuba/] => Any
|
280
|
+
expect {instance.return_arg("brazil")}.to raise_error Rtype::ArgumentTypeError
|
281
|
+
end
|
282
|
+
it "is wrong result" do
|
283
|
+
klass.send :rtype, :return_nil, [Any] => /cuba/
|
284
|
+
expect {instance.return_nil("cuba")}.to raise_error Rtype::ReturnTypeError
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
describe 'Range' do
|
289
|
+
it "is right" do
|
290
|
+
klass.send :rtype, :return_arg, [1..10] => Any
|
291
|
+
instance.return_arg(5)
|
292
|
+
end
|
293
|
+
it "is wrong args" do
|
294
|
+
klass.send :rtype, :return_arg, [1..10] => Any
|
295
|
+
expect {
|
296
|
+
instance.return_arg(1001)
|
297
|
+
}.to raise_error Rtype::ArgumentTypeError
|
298
|
+
end
|
299
|
+
it "is wrong result" do
|
300
|
+
klass.send :rtype, :return_nil, [Any] => 1..10
|
301
|
+
expect {
|
302
|
+
instance.return_nil(5)
|
303
|
+
}.to raise_error Rtype::ReturnTypeError
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe 'Array' do
|
308
|
+
it "is right" do
|
309
|
+
klass.send :rtype, :return_arg, [[:to_i]] => Any
|
310
|
+
instance.return_arg(123)
|
311
|
+
|
312
|
+
klass.send :rtype, :return_arg, [[String, Integer]] => Any
|
313
|
+
instance.return_arg("str")
|
314
|
+
instance.return_arg(123)
|
315
|
+
|
316
|
+
klass.send :rtype, :return_arg, [] => [String, Integer]
|
317
|
+
instance.return_arg("str")
|
318
|
+
instance.return_arg(123)
|
319
|
+
end
|
320
|
+
it "is wrong args" do
|
321
|
+
klass.send :rtype, :return_arg, [[String, Integer]] => Any
|
322
|
+
expect {
|
323
|
+
instance.return_arg(nil)
|
324
|
+
}.to raise_error Rtype::ArgumentTypeError
|
325
|
+
|
326
|
+
klass.send :rtype, :return_arg, [[String]] => Any
|
327
|
+
expect {
|
328
|
+
instance.return_arg(123)
|
329
|
+
}.to raise_error Rtype::ArgumentTypeError
|
330
|
+
end
|
331
|
+
it "is wrong result" do
|
332
|
+
klass.send :rtype, :return_arg, [Any] => [String, Integer]
|
333
|
+
expect {instance.return_arg(true)}.to raise_error Rtype::ReturnTypeError
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
describe 'Hash' do
|
338
|
+
it "is right" do
|
339
|
+
klass.send :rtype, :return_arg, [{k: Integer}, {}] => Any
|
340
|
+
instance.return_arg({k: 123})
|
341
|
+
end
|
342
|
+
it "is wrong args" do
|
343
|
+
klass.send :rtype, :return_arg, [{k: Integer}, {}] => Any
|
344
|
+
expect {
|
345
|
+
instance.return_arg({k: "str"})
|
346
|
+
}.to raise_error Rtype::ArgumentTypeError
|
347
|
+
end
|
348
|
+
it "is wrong result" do
|
349
|
+
klass.send :rtype, :return_arg, [Any] => {k: Integer}
|
350
|
+
expect { instance.return_arg({k: "str"}) }.to raise_error Rtype::ReturnTypeError
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
describe 'Proc' do
|
355
|
+
it "is right" do
|
356
|
+
klass.send :rtype, :return_arg, [->(arg){!arg.nil?}] => Any
|
357
|
+
instance.return_arg(123)
|
358
|
+
end
|
359
|
+
it "is wrong args" do
|
360
|
+
klass.send :rtype, :return_arg, [->(arg){!arg.nil?}] => Any
|
361
|
+
expect {instance.return_arg(nil)}.to raise_error Rtype::ArgumentTypeError
|
362
|
+
end
|
363
|
+
it "is wrong result" do
|
364
|
+
klass.send :rtype, :return_nil, [Any] => ->(arg){!arg.nil?}
|
365
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ReturnTypeError
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe 'true' do
|
370
|
+
it "is right" do
|
371
|
+
klass.send :rtype, :return_arg, [true] => Any
|
372
|
+
instance.return_arg(true)
|
373
|
+
instance.return_arg(123)
|
374
|
+
end
|
375
|
+
it "is wrong args" do
|
376
|
+
klass.send :rtype, :return_arg, [true] => Any
|
377
|
+
expect {instance.return_arg(false)}.to raise_error Rtype::ArgumentTypeError
|
378
|
+
expect {instance.return_arg(nil)}.to raise_error Rtype::ArgumentTypeError
|
379
|
+
end
|
380
|
+
it "is wrong result" do
|
381
|
+
klass.send :rtype, :return_arg, [Any] => true
|
382
|
+
expect {instance.return_arg(false)}.to raise_error Rtype::ReturnTypeError
|
383
|
+
expect {instance.return_arg(nil)}.to raise_error Rtype::ReturnTypeError
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
describe 'false' do
|
388
|
+
it "is right" do
|
389
|
+
klass.send :rtype, :return_arg, [false] => Any
|
390
|
+
instance.return_arg(false)
|
391
|
+
instance.return_arg(nil)
|
392
|
+
end
|
393
|
+
it "is wrong args" do
|
394
|
+
klass.send :rtype, :return_arg, [false] => Any
|
395
|
+
expect {instance.return_arg(true)}.to raise_error Rtype::ArgumentTypeError
|
396
|
+
expect {instance.return_arg(123)}.to raise_error Rtype::ArgumentTypeError
|
397
|
+
end
|
398
|
+
it "is wrong result" do
|
399
|
+
klass.send :rtype, :return_arg, [Any] => false
|
400
|
+
expect {instance.return_arg(true)}.to raise_error Rtype::ReturnTypeError
|
401
|
+
expect {instance.return_arg(123)}.to raise_error Rtype::ReturnTypeError
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
describe 'nil' do
|
406
|
+
it "for return" do
|
407
|
+
klass.send :rtype, :return_nil, [] => nil
|
408
|
+
instance.return_nil(123)
|
409
|
+
|
410
|
+
klass.send :rtype, :return_arg, [] => nil
|
411
|
+
expect {instance.return_arg(123)}.to raise_error Rtype::ReturnTypeError
|
412
|
+
end
|
413
|
+
it "for args" do
|
414
|
+
klass.send :rtype, :return_arg, [nil] => Any
|
415
|
+
instance.return_arg(nil)
|
416
|
+
expect {
|
417
|
+
instance.return_arg(123)
|
418
|
+
}.to raise_error Rtype::ArgumentTypeError
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
describe 'Special type behaviors' do
|
423
|
+
describe 'Rtype::Behavior::And' do
|
424
|
+
it 'module singleton method' do
|
425
|
+
klass.send :rtype, :return_nil, [Rtype::and(:to_i, :chars)] => nil
|
426
|
+
instance.return_nil("Hello")
|
427
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
428
|
+
end
|
429
|
+
|
430
|
+
it 'class singleton [] method' do
|
431
|
+
klass.send :rtype, :return_nil, [ Rtype::Behavior::And[:to_i, :chars] ] => nil
|
432
|
+
instance.return_nil("Hello")
|
433
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
434
|
+
end
|
435
|
+
|
436
|
+
it 'core extension method' do
|
437
|
+
klass.send :rtype, :return_nil, [ :to_i.and(:chars) ] => nil
|
438
|
+
instance.return_nil("Hello")
|
439
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
describe 'Rtype::Behavior::Nilable' do
|
444
|
+
it 'module singleton method' do
|
445
|
+
klass.send :rtype, :return_nil, [Rtype::nilable(Integer)] => nil
|
446
|
+
instance.return_nil(nil)
|
447
|
+
instance.return_nil(123)
|
448
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
449
|
+
end
|
450
|
+
|
451
|
+
it 'class singleton [] method' do
|
452
|
+
klass.send :rtype, :return_nil, [ Rtype::Behavior::Nilable[Integer] ] => nil
|
453
|
+
instance.return_nil(nil)
|
454
|
+
instance.return_nil(123)
|
455
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
456
|
+
end
|
457
|
+
|
458
|
+
it 'core extension method :nilable' do
|
459
|
+
klass.send :rtype, :return_nil, [Integer.nilable] => nil
|
460
|
+
instance.return_nil(nil)
|
461
|
+
instance.return_nil(123)
|
462
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
463
|
+
end
|
464
|
+
|
465
|
+
it 'core extension method :or_nil' do
|
466
|
+
klass.send :rtype, :return_nil, [Integer.or_nil] => nil
|
467
|
+
instance.return_nil(nil)
|
468
|
+
instance.return_nil(123)
|
469
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
describe 'Rtype::Behavior::Not' do
|
474
|
+
it 'module singleton method' do
|
475
|
+
klass.send :rtype, :return_nil, [Rtype::not(String)] => nil
|
476
|
+
instance.return_nil(123)
|
477
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
478
|
+
end
|
479
|
+
|
480
|
+
it 'class singleton [] method' do
|
481
|
+
klass.send :rtype, :return_nil, [ Rtype::Behavior::Not[String] ] => nil
|
482
|
+
instance.return_nil(123)
|
483
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
484
|
+
end
|
485
|
+
|
486
|
+
it 'core extension method' do
|
487
|
+
klass.send :rtype, :return_nil, [ String.not ] => nil
|
488
|
+
instance.return_nil(123)
|
489
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
493
|
+
describe 'Rtype::Behavior::Xor' do
|
494
|
+
it 'module singleton method' do
|
495
|
+
klass.send :rtype, :return_nil, [Rtype::xor(:to_i, String)] => nil
|
496
|
+
instance.return_nil(123)
|
497
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
498
|
+
end
|
499
|
+
|
500
|
+
it 'class singleton [] method' do
|
501
|
+
klass.send :rtype, :return_nil, [ Rtype::Behavior::Xor[:to_i, String] ] => nil
|
502
|
+
instance.return_nil(123)
|
503
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
504
|
+
end
|
505
|
+
|
506
|
+
it 'core extension method' do
|
507
|
+
klass.send :rtype, :return_nil, [ :to_i.xor(String) ] => nil
|
508
|
+
instance.return_nil(123)
|
509
|
+
expect {instance.return_nil("abc")}.to raise_error Rtype::ArgumentTypeError
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
513
|
+
describe 'Rtype::Behavior::TypedArray' do
|
514
|
+
it 'class singleton [] method' do
|
515
|
+
klass.send :rtype, :return_nil, [ Rtype::Behavior::TypedArray[Integer] ] => nil
|
516
|
+
instance.return_nil([123])
|
517
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
518
|
+
expect {instance.return_nil([1.0])}.to raise_error Rtype::ArgumentTypeError
|
519
|
+
end
|
520
|
+
|
521
|
+
it 'core extension method (Array::of)' do
|
522
|
+
klass.send :rtype, :return_nil, [ Array.of(Integer) ] => nil
|
523
|
+
instance.return_nil([123])
|
524
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
525
|
+
expect {instance.return_nil([1.0])}.to raise_error Rtype::ArgumentTypeError
|
526
|
+
end
|
527
|
+
|
528
|
+
it 'complicated type sig' do
|
529
|
+
klass.send :rtype, :return_nil, [ Array.of(:to_i.and(:chars)) ] => nil
|
530
|
+
instance.return_nil(["hello"])
|
531
|
+
expect {instance.return_nil("hello")}.to raise_error Rtype::ArgumentTypeError
|
532
|
+
expect {instance.return_nil([123])}.to raise_error Rtype::ArgumentTypeError
|
533
|
+
end
|
534
|
+
|
535
|
+
it 'allows empty array' do
|
536
|
+
klass.send :rtype, :return_nil, [ Array.of(Integer) ] => nil
|
537
|
+
instance.return_nil([])
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
describe 'Rtype::Behavior::TypedSet' do
|
542
|
+
it 'class singleton [] method' do
|
543
|
+
klass.send :rtype, :return_nil, [ Rtype::Behavior::TypedSet[Integer] ] => nil
|
544
|
+
instance.return_nil( Set.new([123]) )
|
545
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
546
|
+
expect { instance.return_nil(Set.new([1.0])) }.to raise_error Rtype::ArgumentTypeError
|
547
|
+
end
|
548
|
+
|
549
|
+
it 'core extension method (Set::of)' do
|
550
|
+
klass.send :rtype, :return_nil, [ Set.of(Integer) ] => nil
|
551
|
+
instance.return_nil( Set.new([123]) )
|
552
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
553
|
+
expect { instance.return_nil(Set.new([1.0])) }.to raise_error Rtype::ArgumentTypeError
|
554
|
+
end
|
555
|
+
|
556
|
+
it 'complicated type sig' do
|
557
|
+
klass.send :rtype, :return_nil, [ Set.of(:to_i.and(:chars)) ] => nil
|
558
|
+
instance.return_nil( Set.new(["hello"]) )
|
559
|
+
expect {instance.return_nil("hello")}.to raise_error Rtype::ArgumentTypeError
|
560
|
+
expect { instance.return_nil(Set.new([123])) }.to raise_error Rtype::ArgumentTypeError
|
561
|
+
end
|
562
|
+
|
563
|
+
it 'allows empty set' do
|
564
|
+
klass.send :rtype, :return_nil, [ Set.of(Integer) ] => nil
|
565
|
+
instance.return_nil(Set.new)
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
describe 'Rtype::Behavior::TypedHash' do
|
570
|
+
it 'class singleton [] method' do
|
571
|
+
klass.send :rtype, :return_nil, [ Rtype::Behavior::TypedHash[Symbol, Integer] ] => nil
|
572
|
+
instance.return_nil( {key: 123} )
|
573
|
+
expect {instance.return_nil(:key)}.to raise_error Rtype::ArgumentTypeError
|
574
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
575
|
+
expect {instance.return_nil( {"key" => 123} )}.to raise_error Rtype::ArgumentTypeError
|
576
|
+
end
|
577
|
+
|
578
|
+
it 'core extension method (Hash::of)' do
|
579
|
+
klass.send :rtype, :return_nil, [ Hash.of(Symbol, Integer) ] => nil
|
580
|
+
instance.return_nil( {key: 123} )
|
581
|
+
expect {instance.return_nil(:key)}.to raise_error Rtype::ArgumentTypeError
|
582
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
583
|
+
expect {instance.return_nil( {"key" => 123} )}.to raise_error Rtype::ArgumentTypeError
|
584
|
+
end
|
585
|
+
|
586
|
+
it 'complicated type sig' do
|
587
|
+
klass.send :rtype, :return_nil, [ Hash.of(:to_i.and(:chars), :to_i.and(:chars)) ] => nil
|
588
|
+
instance.return_nil( {"key" => "val"} )
|
589
|
+
expect {instance.return_nil("hello")}.to raise_error Rtype::ArgumentTypeError
|
590
|
+
expect {instance.return_nil( {key: "val"} )}.to raise_error Rtype::ArgumentTypeError
|
591
|
+
expect {instance.return_nil( {"key" => :val} )}.to raise_error Rtype::ArgumentTypeError
|
592
|
+
end
|
593
|
+
|
594
|
+
it 'allows empty hash' do
|
595
|
+
klass.send :rtype, :return_nil, [ Hash.of(Symbol, Integer) ] => nil
|
596
|
+
instance.return_nil({})
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
describe 'Numeric check' do
|
601
|
+
it 'Num (Numeric)' do
|
602
|
+
klass.send :rtype, :return_nil, [Num >= 0] => Any
|
603
|
+
expect { instance.return_nil("hello") }.to raise_error Rtype::ArgumentTypeError
|
604
|
+
expect { instance.return_nil(-1) }.to raise_error Rtype::ArgumentTypeError
|
605
|
+
instance.return_nil(2)
|
606
|
+
instance.return_nil(2.0)
|
607
|
+
|
608
|
+
klass.send :rtype, :return_nil, [Num > 0] => Any
|
609
|
+
expect { instance.return_nil("non numeric") }.to raise_error Rtype::ArgumentTypeError
|
610
|
+
expect { instance.return_nil(0) }.to raise_error Rtype::ArgumentTypeError
|
611
|
+
|
612
|
+
klass.send :rtype, :return_nil, [Num < 0] => Any
|
613
|
+
expect { instance.return_nil("non numeric") }.to raise_error Rtype::ArgumentTypeError
|
614
|
+
expect { instance.return_nil(0) }.to raise_error Rtype::ArgumentTypeError
|
615
|
+
|
616
|
+
klass.send :rtype, :return_nil, [Num <= 0] => Any
|
617
|
+
expect { instance.return_nil("non numeric") }.to raise_error Rtype::ArgumentTypeError
|
618
|
+
expect { instance.return_nil(1) }.to raise_error Rtype::ArgumentTypeError
|
619
|
+
end
|
620
|
+
|
621
|
+
it 'Int (Integer)' do
|
622
|
+
klass.send :rtype, :return_nil, [Int >= 0] => Any
|
623
|
+
expect { instance.return_nil("hello") }.to raise_error Rtype::ArgumentTypeError
|
624
|
+
expect { instance.return_nil(1.0) }.to raise_error Rtype::ArgumentTypeError
|
625
|
+
expect { instance.return_nil(-1) }.to raise_error Rtype::ArgumentTypeError
|
626
|
+
instance.return_nil(2)
|
627
|
+
|
628
|
+
klass.send :rtype, :return_nil, [Int > 0] => Any
|
629
|
+
expect { instance.return_nil(1.0) }.to raise_error Rtype::ArgumentTypeError
|
630
|
+
expect { instance.return_nil(0) }.to raise_error Rtype::ArgumentTypeError
|
631
|
+
|
632
|
+
klass.send :rtype, :return_nil, [Int < 0] => Any
|
633
|
+
expect { instance.return_nil(-1.0) }.to raise_error Rtype::ArgumentTypeError
|
634
|
+
expect { instance.return_nil(0) }.to raise_error Rtype::ArgumentTypeError
|
635
|
+
|
636
|
+
klass.send :rtype, :return_nil, [Int <= 0] => Any
|
637
|
+
expect { instance.return_nil(0.0) }.to raise_error Rtype::ArgumentTypeError
|
638
|
+
expect { instance.return_nil(1) }.to raise_error Rtype::ArgumentTypeError
|
639
|
+
end
|
640
|
+
|
641
|
+
it 'Flo (Float)' do
|
642
|
+
klass.send :rtype, :return_nil, [Flo >= 0] => Any
|
643
|
+
expect { instance.return_nil("hello") }.to raise_error Rtype::ArgumentTypeError
|
644
|
+
expect { instance.return_nil(1) }.to raise_error Rtype::ArgumentTypeError
|
645
|
+
expect { instance.return_nil(-1.0) }.to raise_error Rtype::ArgumentTypeError
|
646
|
+
instance.return_nil(2.0)
|
647
|
+
|
648
|
+
klass.send :rtype, :return_nil, [Flo > 0] => Any
|
649
|
+
expect { instance.return_nil(1) }.to raise_error Rtype::ArgumentTypeError
|
650
|
+
expect { instance.return_nil(0.0) }.to raise_error Rtype::ArgumentTypeError
|
651
|
+
|
652
|
+
klass.send :rtype, :return_nil, [Flo < 0] => Any
|
653
|
+
expect { instance.return_nil(-1) }.to raise_error Rtype::ArgumentTypeError
|
654
|
+
expect { instance.return_nil(0.0) }.to raise_error Rtype::ArgumentTypeError
|
655
|
+
|
656
|
+
klass.send :rtype, :return_nil, [Flo <= 0] => Any
|
657
|
+
expect { instance.return_nil(0) }.to raise_error Rtype::ArgumentTypeError
|
658
|
+
expect { instance.return_nil(1.0) }.to raise_error Rtype::ArgumentTypeError
|
659
|
+
end
|
660
|
+
end
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
describe 'Signature' do
|
665
|
+
describe 'check arguments' do
|
666
|
+
it 'nothing' do
|
667
|
+
klass.send :rtype, :sum, [] => Any
|
668
|
+
instance.sum(1, 2)
|
669
|
+
instance.sum(1, 2.0)
|
670
|
+
instance.sum(1.0, 2.0)
|
671
|
+
instance.sum("a", "b")
|
672
|
+
end
|
673
|
+
|
674
|
+
it 'two' do
|
675
|
+
klass.send :rtype, :sum, [Integer, Integer] => Any
|
676
|
+
expect {instance.sum(1, 2.0)}.to raise_error Rtype::ArgumentTypeError
|
677
|
+
end
|
678
|
+
|
679
|
+
it 'two hash' do
|
680
|
+
klass.send :rtype, :two_args, [{k: Integer}, {k: Integer}, {}] => Any
|
681
|
+
instance.two_args({k: 123}, {k: 456})
|
682
|
+
expect {
|
683
|
+
instance.two_args({k: 123}, {})
|
684
|
+
}.to raise_error Rtype::ArgumentTypeError
|
685
|
+
expect {
|
686
|
+
instance.two_args({k: 123}, 456)
|
687
|
+
}.to raise_error Rtype::ArgumentTypeError
|
688
|
+
expect {
|
689
|
+
instance.two_args({k: 123}, {k: "str"})
|
690
|
+
}.to raise_error Rtype::ArgumentTypeError
|
691
|
+
end
|
692
|
+
|
693
|
+
context 'when hash is not last element' do
|
694
|
+
it 'is hash-type argument, not keyword argument' do
|
695
|
+
klass.send :rtype, :return_arg, [{a: String}, {}] => Any
|
696
|
+
expect {
|
697
|
+
instance.return_arg({a: 123})
|
698
|
+
}.to raise_error Rtype::ArgumentTypeError
|
699
|
+
end
|
700
|
+
end
|
701
|
+
end
|
702
|
+
|
703
|
+
describe 'check return' do
|
704
|
+
it 'Any' do
|
705
|
+
klass.send :rtype, :return_arg, [] => Any
|
706
|
+
instance.return_arg("str")
|
707
|
+
end
|
708
|
+
|
709
|
+
it 'Array' do
|
710
|
+
klass.send :rtype, :return_arg, [] => [Integer, Float]
|
711
|
+
expect {instance.return_arg("str")}.to raise_error Rtype::ReturnTypeError
|
712
|
+
end
|
713
|
+
end
|
714
|
+
|
715
|
+
it 'check arguments and return value' do
|
716
|
+
klass.send :rtype, :return_nil, [Float] => nil
|
717
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ArgumentTypeError
|
718
|
+
klass.send :rtype, :return_nil, [Integer] => Integer
|
719
|
+
expect {instance.return_nil(123)}.to raise_error Rtype::ReturnTypeError
|
720
|
+
end
|
721
|
+
|
722
|
+
describe 'wrong case' do
|
723
|
+
describe 'invalid type signature' do
|
724
|
+
it 'invalid arguments type signature' do
|
725
|
+
expect {
|
726
|
+
klass.send :rtype, :return_arg, Any => nil
|
727
|
+
}.to raise_error Rtype::TypeSignatureError
|
728
|
+
end
|
729
|
+
it 'invalid return type signature' do
|
730
|
+
expect {
|
731
|
+
klass.send :rtype, :return_arg, [] => 123
|
732
|
+
}.to raise_error Rtype::TypeSignatureError
|
733
|
+
end
|
734
|
+
|
735
|
+
it 'invalid type behavior in arguments' do
|
736
|
+
expect {
|
737
|
+
klass.send :rtype, :return_arg, [123] => Any
|
738
|
+
}.to raise_error Rtype::TypeSignatureError
|
739
|
+
expect {
|
740
|
+
klass.send :rtype, :return_arg, ["abc"] => Any
|
741
|
+
}.to raise_error Rtype::TypeSignatureError
|
742
|
+
end
|
743
|
+
|
744
|
+
it 'invalid type behavior in return' do
|
745
|
+
expect {
|
746
|
+
klass.send :rtype, :return_arg, [] => 123
|
747
|
+
}.to raise_error Rtype::TypeSignatureError
|
748
|
+
expect {
|
749
|
+
klass.send :rtype, :return_arg, [] => "abc"
|
750
|
+
}.to raise_error Rtype::TypeSignatureError
|
751
|
+
end
|
752
|
+
|
753
|
+
context "with annotation mode" do
|
754
|
+
it 'works' do
|
755
|
+
expect {
|
756
|
+
class AnnotationTest
|
757
|
+
rtype [String, 123] => Any
|
758
|
+
def invalid_test(arg)
|
759
|
+
end
|
760
|
+
end
|
761
|
+
}.to raise_error Rtype::TypeSignatureError
|
762
|
+
end
|
763
|
+
end
|
764
|
+
end
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
describe "Implementation" do
|
769
|
+
it 'can be called before method definition' do
|
770
|
+
class TestClass
|
771
|
+
rtype :method_def, [Integer] => Any
|
772
|
+
def method_def(i)
|
773
|
+
end
|
774
|
+
end
|
775
|
+
expect {
|
776
|
+
TestClass.new.method_def("abc")
|
777
|
+
}.to raise_error Rtype::ArgumentTypeError
|
778
|
+
end
|
779
|
+
|
780
|
+
it 'can be called after method definition' do
|
781
|
+
class TestClass
|
782
|
+
def method_def_2(i)
|
783
|
+
end
|
784
|
+
rtype :method_def_2, [Integer] => Any
|
785
|
+
end
|
786
|
+
expect {
|
787
|
+
TestClass.new.method_def_2("abc")
|
788
|
+
}.to raise_error Rtype::ArgumentTypeError
|
789
|
+
end
|
790
|
+
|
791
|
+
it 'method name can be both symbol and string' do
|
792
|
+
class TestClass
|
793
|
+
rtype 'method_def_3', [Integer] => Any
|
794
|
+
def method_def_3(i)
|
795
|
+
end
|
796
|
+
rtype :method_def_4, [Integer] => Any
|
797
|
+
def method_def_4(i)
|
798
|
+
end
|
799
|
+
end
|
800
|
+
expect {
|
801
|
+
TestClass.new.method_def_3("abc")
|
802
|
+
}.to raise_error Rtype::ArgumentTypeError
|
803
|
+
expect {
|
804
|
+
TestClass.new.method_def_4("abc")
|
805
|
+
}.to raise_error Rtype::ArgumentTypeError
|
806
|
+
end
|
807
|
+
|
808
|
+
describe 'method visibility works' do
|
809
|
+
it 'protected' do
|
810
|
+
klass.send :rtype, :protected_func, [] => Any
|
811
|
+
expect {instance.protected_func}.to raise_error NoMethodError
|
812
|
+
end
|
813
|
+
it 'private' do
|
814
|
+
klass.send :rtype, :private_func, [] => Any
|
815
|
+
expect {instance.private_func}.to raise_error NoMethodError
|
816
|
+
end
|
817
|
+
it 'public' do
|
818
|
+
klass.send :rtype, :public_func, [] => Any
|
819
|
+
instance.public_func
|
820
|
+
end
|
821
|
+
end
|
822
|
+
|
823
|
+
context 'with empty argument signature' do
|
824
|
+
it 'accept any arguments' do
|
825
|
+
klass.send :rtype, :three_args, [] => Any
|
826
|
+
instance.three_args("abc", 123, 456)
|
827
|
+
end
|
828
|
+
end
|
829
|
+
|
830
|
+
context 'when args length is more than arg signature length' do
|
831
|
+
it 'type checking ignore rest args' do
|
832
|
+
klass.send :rtype, :three_args, [String] => Any
|
833
|
+
instance.three_args("abc", 123, 456)
|
834
|
+
end
|
835
|
+
end
|
836
|
+
|
837
|
+
context 'when hash type argument contain a key not configured to rtype' do
|
838
|
+
it 'raises error' do
|
839
|
+
klass.send :rtype, :return_arg, [{a: String}, {}] => Any
|
840
|
+
expect {
|
841
|
+
instance.return_arg({a: "str", b: "str"})
|
842
|
+
}.to raise_error Rtype::ArgumentTypeError
|
843
|
+
end
|
844
|
+
end
|
845
|
+
|
846
|
+
it "One rtype annotation affect only one method" do
|
847
|
+
class AnnotationTest
|
848
|
+
rtype [String] => Any
|
849
|
+
def one(str)
|
850
|
+
end
|
851
|
+
|
852
|
+
def two(str)
|
853
|
+
end
|
854
|
+
end
|
855
|
+
expect {
|
856
|
+
AnnotationTest.new.one(123)
|
857
|
+
}.to raise_error Rtype::ArgumentTypeError
|
858
|
+
AnnotationTest.new.two(123)
|
859
|
+
end
|
860
|
+
|
861
|
+
it "One rtype annotation affect only one method, regardless of instance method or class method" do
|
862
|
+
class AnnotationTest2
|
863
|
+
rtype [String] => Any
|
864
|
+
def self.static_one(str)
|
865
|
+
end
|
866
|
+
|
867
|
+
def inst_one(str)
|
868
|
+
end
|
869
|
+
|
870
|
+
def self.static_two(str)
|
871
|
+
end
|
872
|
+
end
|
873
|
+
expect {
|
874
|
+
AnnotationTest2::static_one(123)
|
875
|
+
}.to raise_error Rtype::ArgumentTypeError
|
876
|
+
AnnotationTest2.new.inst_one(123)
|
877
|
+
AnnotationTest2::static_two(123)
|
878
|
+
end
|
879
|
+
|
880
|
+
context 'when rtype signature duplicated' do
|
881
|
+
it 'the latest have priority' do
|
882
|
+
class PriorityTest1
|
883
|
+
rtype :test_priority, [String] => Any
|
884
|
+
def test_priority(arg)
|
885
|
+
end
|
886
|
+
rtype :test_priority, [Integer] => Any
|
887
|
+
end
|
888
|
+
|
889
|
+
PriorityTest1.new.test_priority(1)
|
890
|
+
expect { PriorityTest1.new.test_priority("str") }.to raise_error Rtype::ArgumentTypeError
|
891
|
+
end
|
892
|
+
|
893
|
+
it 'annotation mode have priority in contemporaneous signatures' do
|
894
|
+
class PriorityTest2
|
895
|
+
rtype :test_priority, [String] => Any
|
896
|
+
rtype [Integer] => Any
|
897
|
+
def test_priority(arg)
|
898
|
+
end
|
899
|
+
end
|
900
|
+
|
901
|
+
PriorityTest2.new.test_priority(1)
|
902
|
+
expect { PriorityTest2.new.test_priority("str") }.to raise_error Rtype::ArgumentTypeError
|
903
|
+
end
|
904
|
+
end
|
905
|
+
end
|
906
|
+
|
907
|
+
describe "Call Rtype`s static method directly" do
|
908
|
+
it 'Rtype::define_typed_method' do
|
909
|
+
Rtype::define_typed_method klass, :return_arg, {[String] => Any}, false
|
910
|
+
expect {instance.return_arg(123)}.to raise_error Rtype::ArgumentTypeError
|
911
|
+
end
|
912
|
+
|
913
|
+
it 'Rtype::define_typed_accessor' do
|
914
|
+
Rtype::define_typed_accessor klass, :value, String, false
|
915
|
+
expect { instance.value = 123 }.to raise_error Rtype::ArgumentTypeError
|
916
|
+
expect { instance.value }.to raise_error Rtype::ReturnTypeError
|
917
|
+
end
|
918
|
+
|
919
|
+
it 'Rtype::valid?' do
|
920
|
+
expect(
|
921
|
+
Rtype::valid?(String, "str")
|
922
|
+
).to be true
|
923
|
+
expect(
|
924
|
+
Rtype::valid?(Integer, "str")
|
925
|
+
).to be false
|
926
|
+
expect {
|
927
|
+
Rtype::valid?("Invalid type behavior", "Test Value")
|
928
|
+
}.to raise_error Rtype::TypeSignatureError
|
929
|
+
end
|
930
|
+
|
931
|
+
it 'Rtype::assert_arguments_type' do
|
932
|
+
expect {
|
933
|
+
Rtype::assert_arguments_type([Integer, String], [123, 123])
|
934
|
+
}.to raise_error Rtype::ArgumentTypeError
|
935
|
+
end
|
936
|
+
|
937
|
+
it 'Rtype::assert_return_type' do
|
938
|
+
expect {
|
939
|
+
Rtype::assert_return_type nil, "No nil"
|
940
|
+
}.to raise_error Rtype::ReturnTypeError
|
941
|
+
end
|
942
|
+
|
943
|
+
it 'Rtype::assert_valid_type_sig' do
|
944
|
+
Rtype::assert_valid_type_sig([Integer, String] => Any)
|
945
|
+
expect {
|
946
|
+
Rtype::assert_valid_type_sig([Integer, String])
|
947
|
+
}.to raise_error Rtype::TypeSignatureError
|
948
|
+
end
|
949
|
+
|
950
|
+
it 'Rtype::assert_valid_arguments_type_sig' do
|
951
|
+
Rtype::assert_valid_arguments_type_sig([Integer, String])
|
952
|
+
expect {
|
953
|
+
Rtype::assert_valid_arguments_type_sig("[Integer, String]")
|
954
|
+
}.to raise_error Rtype::TypeSignatureError
|
955
|
+
end
|
956
|
+
|
957
|
+
it 'Rtype::assert_valid_argument_type_sig_element' do
|
958
|
+
Rtype::assert_valid_argument_type_sig_element(Integer)
|
959
|
+
expect {
|
960
|
+
Rtype::assert_valid_argument_type_sig_element("Integer")
|
961
|
+
}.to raise_error Rtype::TypeSignatureError
|
962
|
+
end
|
963
|
+
|
964
|
+
it 'Rtype::assert_valid_return_type_sig' do
|
965
|
+
Rtype::assert_valid_return_type_sig(Integer)
|
966
|
+
expect {
|
967
|
+
Rtype::assert_valid_return_type_sig("Integer")
|
968
|
+
}.to raise_error Rtype::TypeSignatureError
|
969
|
+
end
|
970
|
+
end
|
971
|
+
end
|