rtype-native 0.5.1 → 0.6.0
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 +4 -4
- data/README.md +34 -67
- data/ext/rtype/c/rtype.c +35 -43
- data/ext/rtype/c/rtype.h +2 -1
- data/spec/rtype_spec.rb +22 -51
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef5c1668d43c941a152f041fab3d0009125ece57
|
4
|
+
data.tar.gz: b369a523c7a2c18980c498b6513e29d8ed152283
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dfc53545e477221f5de7e7f554ddbbc9b2ecda043edd7b4d1ca6d754c83e8fc04112bc5cb4795135c69541f5935aca796e4a64813bab0db8c1ba91a3bbd0ff7
|
7
|
+
data.tar.gz: a5b5840dff0ddf0837a80ee73a0f97818c78c3101d4426160561f23cb45c5a38e0146da6f370ed603c08b1a1061fb6cf322b4de904d070be5793ddc73cf934f9
|
data/README.md
CHANGED
@@ -37,9 +37,8 @@ Test::invert(state: 0)
|
|
37
37
|
- If Java extension is used, otherwise it is not required
|
38
38
|
|
39
39
|
## Features
|
40
|
-
-
|
41
|
-
-
|
42
|
-
- [Type checking for array elements](#array)
|
40
|
+
- Provides type checking for arguments and return
|
41
|
+
- Supports type checking for [keyword argument](#keyword-argument)
|
43
42
|
- [Type checking for hash elements](#hash)
|
44
43
|
- [Duck typing](#duck-typing)
|
45
44
|
- Custom type behavior
|
@@ -81,28 +80,23 @@ then, Rtype use it. (Do not `require 'rtype-java'`)
|
|
81
80
|
|
82
81
|
### Supported Type Behaviors
|
83
82
|
- `Module`
|
84
|
-
- Value must be an instance of
|
83
|
+
- Value must be an instance of the module/class or one of its superclasses
|
85
84
|
- `Any` : An alias for `BasicObject` (means Any Object)
|
86
85
|
- `Boolean` : `true` or `false`
|
87
86
|
- `Symbol`
|
88
|
-
- Value must have(respond to) a method with
|
87
|
+
- Value must have(respond to) a method with the name
|
89
88
|
- `Regexp`
|
90
|
-
- Value must match
|
89
|
+
- Value must match the regexp pattern
|
91
90
|
- `Range`
|
92
|
-
- Value must be included in
|
93
|
-
- `Array`
|
94
|
-
- Value
|
95
|
-
- Each of value's elements must be valid
|
96
|
-
- Value's length must be equal to the array's length
|
97
|
-
- Of course, nested array works
|
98
|
-
- Example: [Array](#array)
|
99
|
-
- This can be used as a tuple
|
91
|
+
- Value must be included in the range
|
92
|
+
- `Array`
|
93
|
+
- Value can be any type in the array
|
100
94
|
- `Hash`
|
101
95
|
- Value must be an hash
|
102
96
|
- Each of value’s elements must be valid
|
103
97
|
- Value's key list must be equal to the hash's key list
|
104
98
|
- **String** key is **different** from **symbol** key
|
105
|
-
- vs Keyword arguments
|
99
|
+
- vs Keyword arguments (e.g.)
|
106
100
|
- `[{}]` is **not** hash type argument. it is keyword argument because its position is last
|
107
101
|
- `[{}, {}]` is empty hash type argument (first) and one empty keyword argument (second)
|
108
102
|
- `[{}, {}, {}]` is two empty hash type argument (first, second) and empty keyword argument (last)
|
@@ -110,44 +104,31 @@ then, Rtype use it. (Do not `require 'rtype-java'`)
|
|
110
104
|
- Of course, nested hash works
|
111
105
|
- Example: [Hash](#hash)
|
112
106
|
- `Proc`
|
113
|
-
- Value must return a truthy value for
|
107
|
+
- Value must return a truthy value for the proc
|
114
108
|
- `true`
|
115
109
|
- Value must be **truthy**
|
116
110
|
- `false`
|
117
111
|
- Value must be **falsy**
|
118
112
|
- `nil`
|
119
|
-
-
|
113
|
+
- Value must be nil
|
120
114
|
- Special Behaviors
|
121
115
|
- `Rtype::and(*types)` : Ensure value is valid for all the types
|
122
|
-
- `Rtype::and(*types)`
|
123
|
-
- `
|
124
|
-
- `
|
125
|
-
|
126
|
-
|
127
|
-
- `Rtype::or(*types)` : Ensure value is valid for at least one of the types
|
128
|
-
- `Rtype::or(*types)`
|
129
|
-
- `Rtype::Behavior::Or[*types]`
|
130
|
-
- `include Rtype::Behavior; Or[...]`
|
131
|
-
- `obj.or(*others)` (core extension)
|
132
|
-
|
116
|
+
- `Rtype::and(*types)`, `Rtype::Behavior::And[*types]`, `include Rtype::Behavior; And[...]`
|
117
|
+
- `Array#comb`
|
118
|
+
- `Object#and(*others)`
|
119
|
+
|
133
120
|
- `Rtype::xor(*types)` : Ensure value is valid for only one of the types
|
134
|
-
- `Rtype::xor(*types)`
|
135
|
-
- `
|
136
|
-
- `include Rtype::Behavior; Xor[...]`
|
137
|
-
- `obj.xor(*others)` (core extension)
|
121
|
+
- `Rtype::xor(*types)`, `Rtype::Behavior::Xor[*types]`, `include Rtype::Behavior; Xor[...]`
|
122
|
+
- `Object#xor(*others)`
|
138
123
|
|
139
124
|
- `Rtype::not(*types)` : Ensure value is not valid for all the types
|
140
|
-
- `Rtype::not(*types)`
|
141
|
-
- `
|
142
|
-
- `include Rtype::Behavior; Not[...]`
|
143
|
-
- `obj.not` (core extension)
|
125
|
+
- `Rtype::not(*types)`, `Rtype::Behavior::Not[*types]`, `include Rtype::Behavior; Not[...]`
|
126
|
+
- `Object#not`
|
144
127
|
|
145
128
|
- `Rtype::nilable(type)` : Ensure value can be nil
|
146
|
-
- `Rtype::nilable(type)`
|
147
|
-
- `
|
148
|
-
- `
|
149
|
-
- `obj.nilable` (core extension)
|
150
|
-
- `obj.or_nil` (core extension)
|
129
|
+
- `Rtype::nilable(type)`, `Rtype::Behavior::Nilable[type]`, `include Rtype::Behavior; Nilable[...]`
|
130
|
+
- `Object#nilable`
|
131
|
+
- `Object#or_nil`
|
151
132
|
|
152
133
|
- You can create custom behavior by extending `Rtype::Behavior::Base`
|
153
134
|
|
@@ -224,33 +205,19 @@ Duck.new.says("2") # duck: quack quack
|
|
224
205
|
```
|
225
206
|
|
226
207
|
#### Array
|
227
|
-
This can be used as a tuple.
|
228
|
-
|
229
208
|
```ruby
|
230
|
-
rtype :
|
231
|
-
def
|
232
|
-
|
209
|
+
rtype :ruby!, [[String, Integer]] => Any
|
210
|
+
def ruby!(arg)
|
211
|
+
puts "ruby!"
|
233
212
|
end
|
234
213
|
|
235
|
-
func
|
236
|
-
|
237
|
-
# Expected [1, "str"] to be an array with 2 elements:
|
238
|
-
# - [0] index : Expected 1 to be a Numeric
|
239
|
-
# - [1] index : Expected "str" to be a Numeric
|
240
|
-
|
241
|
-
func [1, 2, 3]
|
242
|
-
# (Rtype::ArgumentTypeError) for 1st argument:
|
243
|
-
# Expected [1, 2, 3] to be an array with 2 elements:
|
244
|
-
# - [0] index : Expected 1 to be a Numeric
|
245
|
-
# - [1] index : Expected 2 to be a Numeric
|
214
|
+
func("str") # ruby!
|
215
|
+
func(123) # ruby!
|
246
216
|
|
247
|
-
func
|
217
|
+
func(nil)
|
248
218
|
# (Rtype::ArgumentTypeError) for 1st argument:
|
249
|
-
# Expected
|
250
|
-
#
|
251
|
-
# - [1] index : Expected nil to be a Numeric
|
252
|
-
|
253
|
-
func [1, 2] # Your location is (1, 2). I will look for you. I will find you
|
219
|
+
# Expected nil to be a String
|
220
|
+
# OR Expected nil to be a Integer
|
254
221
|
```
|
255
222
|
|
256
223
|
#### Hash
|
@@ -316,7 +283,7 @@ Example.new.value
|
|
316
283
|
require 'rtype'
|
317
284
|
|
318
285
|
class Example
|
319
|
-
rtype [String
|
286
|
+
rtype [[String, :func].comb] => Any
|
320
287
|
# also works:
|
321
288
|
# rtype [Rtype::and(String, :func)] => Any
|
322
289
|
def and_test(arg)
|
@@ -349,12 +316,12 @@ module Game
|
|
349
316
|
ENEMY = [
|
350
317
|
:name,
|
351
318
|
:level
|
352
|
-
]
|
319
|
+
].comb
|
353
320
|
|
354
321
|
class Player < Entity
|
355
322
|
include Rtype::Behavior
|
356
323
|
|
357
|
-
rtype [
|
324
|
+
rtype [ENEMY] => Any
|
358
325
|
def attacks(enemy)
|
359
326
|
"Player attacks '#{enemy.name}' (level #{enemy.level})!"
|
360
327
|
end
|
@@ -565,4 +532,4 @@ Sputnik Gugja (sputnikgugja@gmail.com)
|
|
565
532
|
## License
|
566
533
|
MIT license (@ Sputnik Gugja)
|
567
534
|
|
568
|
-
See `LICENSE` file.
|
535
|
+
See `LICENSE` file.
|
data/ext/rtype/c/rtype.c
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
#include "rtype.h"
|
2
2
|
|
3
3
|
VALUE rb_mRtype, rb_mRtypeBehavior, rb_cRtypeBehaviorBase, rb_eRtypeArgumentTypeError, rb_eRtypeTypeSignatureError, rb_eRtypeReturnTypeError;
|
4
|
-
static ID id_to_s, id_keys, id_eqeq, id_include, id_valid, id_call;
|
4
|
+
static ID id_to_s, id_keys, id_eqeq, id_include, id_valid, id_call, id_key;
|
5
5
|
|
6
6
|
VALUE
|
7
7
|
rb_rtype_valid(VALUE self, VALUE expected, VALUE value) {
|
8
|
+
long i;
|
9
|
+
VALUE e_keys;
|
10
|
+
VALUE v_keys;
|
11
|
+
|
8
12
|
switch(TYPE(expected)) {
|
9
13
|
case T_MODULE:
|
10
14
|
case T_CLASS:
|
@@ -17,13 +21,12 @@ rb_rtype_valid(VALUE self, VALUE expected, VALUE value) {
|
|
17
21
|
if( !RB_TYPE_P(value, T_HASH) ) {
|
18
22
|
return Qfalse;
|
19
23
|
}
|
20
|
-
|
21
|
-
|
24
|
+
e_keys = rb_funcall(expected, id_keys, 0);
|
25
|
+
v_keys = rb_funcall(value, id_keys, 0);
|
22
26
|
if( !RTEST(rb_funcall(e_keys, id_eqeq, 1, v_keys)) ) {
|
23
27
|
return Qfalse;
|
24
28
|
}
|
25
|
-
|
26
|
-
long i;
|
29
|
+
|
27
30
|
for(i = 0; i < RARRAY_LEN(e_keys); i++) {
|
28
31
|
VALUE e_k = rb_ary_entry(e_keys, i);
|
29
32
|
VALUE e_v = rb_hash_aref(expected, e_k);
|
@@ -33,29 +36,20 @@ rb_rtype_valid(VALUE self, VALUE expected, VALUE value) {
|
|
33
36
|
}
|
34
37
|
return Qtrue;
|
35
38
|
case T_ARRAY:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}
|
42
|
-
else {
|
43
|
-
// 'for' loop initial declarations are only allowed in c99 mode
|
44
|
-
long i;
|
45
|
-
for(i = 0; i < RARRAY_LEN(expected); i++) {
|
46
|
-
VALUE e = rb_ary_entry(expected, i);
|
47
|
-
VALUE v = rb_ary_entry(value, i);
|
48
|
-
VALUE valid = rb_rtype_valid(self, e, v);
|
49
|
-
if(valid == Qfalse) {
|
50
|
-
return Qfalse;
|
51
|
-
}
|
39
|
+
for(i = 0; i < RARRAY_LEN(expected); i++) {
|
40
|
+
VALUE e = rb_ary_entry(expected, i);
|
41
|
+
VALUE valid = rb_rtype_valid(self, e, value);
|
42
|
+
if(valid == Qtrue) {
|
43
|
+
return Qtrue;
|
52
44
|
}
|
53
|
-
return Qtrue;
|
54
45
|
}
|
46
|
+
return Qfalse;
|
55
47
|
case T_TRUE:
|
56
48
|
return RTEST(value) ? Qtrue : Qfalse;
|
57
49
|
case T_FALSE:
|
58
50
|
return !RTEST(value) ? Qtrue : Qfalse;
|
51
|
+
case T_NIL:
|
52
|
+
return value == Qnil;
|
59
53
|
default:
|
60
54
|
if(rb_obj_is_kind_of(expected, rb_cRange)) {
|
61
55
|
return rb_funcall(expected, id_include, 1, value);
|
@@ -78,14 +72,17 @@ VALUE
|
|
78
72
|
rb_rtype_assert_arguments_type(VALUE self, VALUE expected_args, VALUE args) {
|
79
73
|
// 'for' loop initial declarations are only allowed in c99 mode
|
80
74
|
long i;
|
75
|
+
long e_len = RARRAY_LEN(expected_args);
|
81
76
|
for(i = 0; i < RARRAY_LEN(args); i++) {
|
82
|
-
VALUE e
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
77
|
+
VALUE e, v;
|
78
|
+
if(i >= e_len) {
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
e = rb_ary_entry(expected_args, i);
|
82
|
+
v = rb_ary_entry(args, i);
|
83
|
+
if( !RTEST(rb_rtype_valid(self, e, v)) ) {
|
84
|
+
VALUE msg = rb_funcall(rb_mRtype, rb_intern("arg_type_error_message"), 3, LONG2FIX(i), e, v);
|
85
|
+
rb_raise(rb_eRtypeArgumentTypeError, "%s", StringValueCStr(msg));
|
89
86
|
}
|
90
87
|
}
|
91
88
|
return Qnil;
|
@@ -93,8 +90,8 @@ rb_rtype_assert_arguments_type(VALUE self, VALUE expected_args, VALUE args) {
|
|
93
90
|
|
94
91
|
static int
|
95
92
|
kwargs_do_each(VALUE key, VALUE val, VALUE in) {
|
96
|
-
|
97
|
-
|
93
|
+
if( RTEST(rb_funcall(in, id_key, 1, key)) ) {
|
94
|
+
VALUE expected = rb_hash_aref(in, key);
|
98
95
|
if( !RTEST(rb_rtype_valid((VALUE) NULL, expected, val)) ) {
|
99
96
|
VALUE msg = rb_funcall(rb_mRtype, rb_intern("kwarg_type_error_message"), 3, key, expected, val);
|
100
97
|
rb_raise(rb_eRtypeArgumentTypeError, "%s", StringValueCStr(msg));
|
@@ -112,17 +109,9 @@ rb_rtype_assert_arguments_type_with_keywords(VALUE self, VALUE expected_args, VA
|
|
112
109
|
|
113
110
|
VALUE
|
114
111
|
rb_rtype_assert_return_type(VALUE self, VALUE expected, VALUE result) {
|
115
|
-
if(expected
|
116
|
-
|
117
|
-
|
118
|
-
rb_raise(rb_eRtypeReturnTypeError, "for return:\n%s", StringValueCStr(msg));
|
119
|
-
}
|
120
|
-
}
|
121
|
-
else {
|
122
|
-
if( !RTEST(rb_rtype_valid(self, expected, result)) ) {
|
123
|
-
VALUE msg = rb_funcall(rb_mRtype, rb_intern("type_error_message"), 2, expected, result);
|
124
|
-
rb_raise(rb_eRtypeReturnTypeError, "for return:\n%s", StringValueCStr(msg));
|
125
|
-
}
|
112
|
+
if( !RTEST(rb_rtype_valid(self, expected, result)) ) {
|
113
|
+
VALUE msg = rb_funcall(rb_mRtype, rb_intern("type_error_message"), 2, expected, result);
|
114
|
+
rb_raise(rb_eRtypeReturnTypeError, "for return:\n%s", StringValueCStr(msg));
|
126
115
|
}
|
127
116
|
return Qnil;
|
128
117
|
}
|
@@ -134,6 +123,8 @@ void Init_rtype_native(void) {
|
|
134
123
|
rb_eRtypeArgumentTypeError = rb_define_class_under(rb_mRtype, "ArgumentTypeError", rb_eArgError);
|
135
124
|
rb_eRtypeTypeSignatureError = rb_define_class_under(rb_mRtype, "TypeSignatureError", rb_eArgError);
|
136
125
|
rb_eRtypeReturnTypeError = rb_define_class_under(rb_mRtype, "ReturnTypeError", rb_eStandardError);
|
126
|
+
|
127
|
+
rb_define_const(rb_mRtype, "NATIVE_EXT_VERSION", rb_str_new2(RTYPE_NATIVE_EXT_VERSION));
|
137
128
|
|
138
129
|
id_to_s = rb_intern("to_s");
|
139
130
|
id_keys = rb_intern("keys");
|
@@ -141,9 +132,10 @@ void Init_rtype_native(void) {
|
|
141
132
|
id_include = rb_intern("include?");
|
142
133
|
id_valid = rb_intern("valid?");
|
143
134
|
id_call = rb_intern("call");
|
135
|
+
id_key = rb_intern("key?");
|
144
136
|
|
145
137
|
rb_define_method(rb_mRtype, "valid?", rb_rtype_valid, 2);
|
146
138
|
rb_define_method(rb_mRtype, "assert_arguments_type", rb_rtype_assert_arguments_type, 2);
|
147
139
|
rb_define_method(rb_mRtype, "assert_arguments_type_with_keywords", rb_rtype_assert_arguments_type_with_keywords, 4);
|
148
140
|
rb_define_method(rb_mRtype, "assert_return_type", rb_rtype_assert_return_type, 2);
|
149
|
-
}
|
141
|
+
}
|
data/ext/rtype/c/rtype.h
CHANGED
data/spec/rtype_spec.rb
CHANGED
@@ -237,31 +237,30 @@ describe Rtype do
|
|
237
237
|
|
238
238
|
describe 'Array' do
|
239
239
|
it "is right" do
|
240
|
-
klass.send :rtype, :return_arg, [[:to_i
|
241
|
-
instance.return_arg(
|
240
|
+
klass.send :rtype, :return_arg, [[:to_i]] => Any
|
241
|
+
instance.return_arg(123)
|
242
242
|
|
243
|
-
klass.send :rtype, :
|
244
|
-
instance.
|
243
|
+
klass.send :rtype, :return_arg, [[String, Integer]] => Any
|
244
|
+
instance.return_arg("str")
|
245
|
+
instance.return_arg(123)
|
246
|
+
|
247
|
+
klass.send :rtype, :return_arg, [] => [String, Integer]
|
248
|
+
instance.return_arg("str")
|
249
|
+
instance.return_arg(123)
|
245
250
|
end
|
246
251
|
it "is wrong args" do
|
247
|
-
klass.send :rtype, :return_arg, [[
|
248
|
-
expect {
|
249
|
-
instance.return_arg([123, [true]])
|
250
|
-
}.to raise_error Rtype::ArgumentTypeError
|
252
|
+
klass.send :rtype, :return_arg, [[String, Integer]] => Any
|
251
253
|
expect {
|
252
|
-
instance.return_arg(
|
254
|
+
instance.return_arg(nil)
|
253
255
|
}.to raise_error Rtype::ArgumentTypeError
|
254
256
|
|
255
|
-
klass.send :rtype, :
|
257
|
+
klass.send :rtype, :return_arg, [[String]] => Any
|
256
258
|
expect {
|
257
|
-
instance.
|
258
|
-
}.to raise_error Rtype::ArgumentTypeError
|
259
|
-
expect {
|
260
|
-
instance.two_args([123], 123)
|
259
|
+
instance.return_arg(123)
|
261
260
|
}.to raise_error Rtype::ArgumentTypeError
|
262
261
|
end
|
263
262
|
it "is wrong result" do
|
264
|
-
klass.send :rtype, :return_arg, [Any] => [
|
263
|
+
klass.send :rtype, :return_arg, [Any] => [String, Integer]
|
265
264
|
expect {instance.return_arg(true)}.to raise_error Rtype::ReturnTypeError
|
266
265
|
end
|
267
266
|
end
|
@@ -335,17 +334,19 @@ describe Rtype do
|
|
335
334
|
end
|
336
335
|
|
337
336
|
describe 'nil' do
|
338
|
-
it "
|
337
|
+
it "for return" do
|
339
338
|
klass.send :rtype, :return_nil, [] => nil
|
340
339
|
instance.return_nil(123)
|
341
340
|
|
342
341
|
klass.send :rtype, :return_arg, [] => nil
|
343
342
|
expect {instance.return_arg(123)}.to raise_error Rtype::ReturnTypeError
|
344
343
|
end
|
345
|
-
it "
|
344
|
+
it "for args" do
|
345
|
+
klass.send :rtype, :return_arg, [nil] => Any
|
346
|
+
instance.return_arg(nil)
|
346
347
|
expect {
|
347
|
-
|
348
|
-
}.to raise_error Rtype::
|
348
|
+
instance.return_arg(123)
|
349
|
+
}.to raise_error Rtype::ArgumentTypeError
|
349
350
|
end
|
350
351
|
end
|
351
352
|
|
@@ -370,29 +371,6 @@ describe Rtype do
|
|
370
371
|
end
|
371
372
|
end
|
372
373
|
|
373
|
-
describe 'Rtype::Behavior::Or' do
|
374
|
-
it 'module singleton method' do
|
375
|
-
klass.send :rtype, :return_nil, [Rtype::or(Integer, String)] => nil
|
376
|
-
instance.return_nil(123)
|
377
|
-
instance.return_nil("abc")
|
378
|
-
expect {instance.return_nil(nil)}.to raise_error Rtype::ArgumentTypeError
|
379
|
-
end
|
380
|
-
|
381
|
-
it 'class singleton [] method' do
|
382
|
-
klass.send :rtype, :return_nil, [ Rtype::Behavior::Or[Integer, String] ] => nil
|
383
|
-
instance.return_nil(123)
|
384
|
-
instance.return_nil("abc")
|
385
|
-
expect {instance.return_nil(nil)}.to raise_error Rtype::ArgumentTypeError
|
386
|
-
end
|
387
|
-
|
388
|
-
it 'core extension method' do
|
389
|
-
klass.send :rtype, :return_nil, [ Integer.or(String) ] => nil
|
390
|
-
instance.return_nil(123)
|
391
|
-
instance.return_nil("abc")
|
392
|
-
expect {instance.return_nil(nil)}.to raise_error Rtype::ArgumentTypeError
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
374
|
describe 'Rtype::Behavior::Nilable' do
|
397
375
|
it 'module singleton method' do
|
398
376
|
klass.send :rtype, :return_nil, [Rtype::nilable(Integer)] => nil
|
@@ -480,13 +458,6 @@ describe Rtype do
|
|
480
458
|
expect {instance.sum(1, 2.0)}.to raise_error Rtype::ArgumentTypeError
|
481
459
|
end
|
482
460
|
|
483
|
-
it 'two array' do
|
484
|
-
klass.send :rtype, :sum, [[Integer], [Integer]] => Any
|
485
|
-
instance.sum([1], [2])
|
486
|
-
expect {instance.sum([1], 2)}.to raise_error Rtype::ArgumentTypeError
|
487
|
-
expect {instance.sum([1], ["str"])}.to raise_error Rtype::ArgumentTypeError
|
488
|
-
end
|
489
|
-
|
490
461
|
it 'two hash' do
|
491
462
|
klass.send :rtype, :two_args, [{k: Integer}, {k: Integer}, {}] => Any
|
492
463
|
instance.two_args({k: 123}, {k: 456}, {})
|
@@ -564,9 +535,9 @@ describe Rtype do
|
|
564
535
|
instance.return_arg("str")
|
565
536
|
end
|
566
537
|
|
567
|
-
it 'Array
|
538
|
+
it 'Array' do
|
568
539
|
klass.send :rtype, :return_arg, [] => [Integer, Float]
|
569
|
-
expect {instance.return_arg(
|
540
|
+
expect {instance.return_arg("str")}.to raise_error Rtype::ReturnTypeError
|
570
541
|
end
|
571
542
|
end
|
572
543
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtype-native
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sputnik Gugja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rtype
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|