rubype 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c0f2d837a9a63da1544d73541bc6b6ef5e60958
4
- data.tar.gz: c875157ae021117e74ec28014d313e4a5fd72f1b
3
+ metadata.gz: d752aa79376b7981146f2f8b9f6ef94f8fc74b20
4
+ data.tar.gz: de61c2ff8105a604256f0d89c1e6c65285a94ddf
5
5
  SHA512:
6
- metadata.gz: ae15d7157d172321c3b31982bbbb83611f4e163a8278b27c7b96971b7be6d0ee1244d6d4fc8591ccd28549f1e5842929ea8cb274a69f01d0a425c586eeebd292
7
- data.tar.gz: b7fe02373c1ce6a849ca232ad5f0139da7cf2f5655ce3d81e065e5abc0f04c7e6a0c0e9b789102076c6d6df1e028d2773ce79fd707e0e9c504e8644cbdcf1832
6
+ metadata.gz: 08e2f22b13c8138246daf7c94417b73be722c55310aee0e21d0a6799d8c36673ef5b598f3b73dd8b32cb9aa1f4a1d81afcb8e5065e44e6bda52d7af47cc7cec8
7
+ data.tar.gz: 5792a3bc311e89a8ca0b5b5333819ce335969bda6f2c35d4ce64054d818070a03693af4340ee9d2597c840da97c0c0699ccfb86960afdd383fc47574df22d00a
data/.travis.yml CHANGED
@@ -1,7 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.2
3
+ - 2.2.0
4
+ - 2.1.5
4
5
  - 2.0.0
5
- - 1.9.3
6
+ - rbx-2
7
+ - ruby-head
8
+ # - jruby-head
6
9
  notifications:
7
10
  email: false
data/README.md CHANGED
@@ -1,17 +1,19 @@
1
1
  # Ruby + Type = Rubype
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/rubype.svg)](http://badge.fury.io/rb/rubype) [![Build Status](https://travis-ci.org/gogotanaka/Rubype.svg?branch=develop)](https://travis-ci.org/gogotanaka/Rubype) [![Dependency Status](https://gemnasium.com/gogotanaka/Rubype.svg)](https://gemnasium.com/gogotanaka/Rubype) [![Code Climate](https://codeclimate.com/github/gogotanaka/Rubype/badges/gpa.svg)](https://codeclimate.com/github/gogotanaka/Rubype)
4
+
3
5
  ```rb
4
6
  # Assert class of both args is Numeric and class of return is String
5
7
  def sum(x, y)
6
8
  (x + y).to_s
7
9
  end
8
- typesig sum: [Numeric, Numeric => String]
10
+ typesig :sum, [Numeric, Numeric] => String
9
11
 
10
12
  # Assert first arg has method #to_i
11
13
  def sum(x, y)
12
14
  x.to_i + y
13
15
  end
14
- typesig sum: [:to_i, Numeric => Numeric]
16
+ typesig :sum, [:to_i, Numeric] => Numeric
15
17
  ```
16
18
 
17
19
 
@@ -31,12 +33,12 @@ class MyClass
31
33
  def sum(x, y)
32
34
  x + y
33
35
  end
34
- typesig sum: [Numeric, Numeric => Numeric]
36
+ typesig :sum, [Numeric, Numeric] => Numeric
35
37
 
36
38
  def wrong_sum(x, y)
37
39
  'string'
38
40
  end
39
- typesig wrong_sum: [Numeric, Numeric => Numeric]
41
+ typesig :wrong_sum, [Numeric, Numeric] => Numeric
40
42
  end
41
43
 
42
44
  MyClass.new.sum(1, 2)
@@ -54,7 +56,7 @@ class MyClass
54
56
  def sum(x, y)
55
57
  x.to_i + y
56
58
  end
57
- typesig sum: [:to_i, Numeric => Numeric]
59
+ typesig :sum, [:to_i, Numeric] => Numeric
58
60
  end
59
61
 
60
62
  MyClass.new.sum('1', 2)
@@ -69,7 +71,7 @@ class People
69
71
  def marry(people)
70
72
  # Your Ruby code as usual
71
73
  end
72
- typesig marry: [People => Any]
74
+ typesig :marry, [People] => Any
73
75
  end
74
76
 
75
77
  People.new.marry(People.new)
@@ -88,7 +90,7 @@ class MyClass
88
90
  def method_with_type(x, y)
89
91
  x + y
90
92
  end
91
- typesig sum: [Numeric, Numeric => Numeric]
93
+ typesig :sum, [Numeric, Numeric] => Numeric
92
94
 
93
95
  def method_without_type(x, y)
94
96
  'string'
@@ -103,12 +105,12 @@ class MyClass
103
105
  def foo(any_obj)
104
106
  1
105
107
  end
106
- typesig foo: [Any => Numeric]
108
+ typesig :foo, [Any] => Numeric
107
109
 
108
110
  def sum(x, y)
109
111
  x.to_i + y
110
112
  end
111
- typesig sum: [:to_i, Numeric => Numeric]
113
+ typesig :sum, [:to_i, Numeric] => Numeric
112
114
  end
113
115
 
114
116
  # It's totally OK!!
@@ -142,7 +144,11 @@ Commit your changes (`git commit -am 'Add some feature'`)
142
144
 
143
145
  $ bundle exec rake test
144
146
 
145
- > 5 runs, 39 assertions, 0 failures, 0 errors, 0 skips
147
+ ......
148
+
149
+ Finished in 0.010961s, 547.3953 runs/s, 5017.7903 assertions/s.
150
+
151
+ 6 runs, 55 assertions, 0 failures, 0 errors, 0 skips
146
152
 
147
153
  Push to the branch (`git push origin my-new-feature`)
148
154
 
data/Rakefile CHANGED
@@ -5,15 +5,4 @@ Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test"
6
6
  end
7
7
 
8
- require "rake/extensiontask"
9
-
10
- Rake::ExtensionTask.new("rubype") do |ext|
11
- ext.lib_dir = "lib/rubype"
12
- end
13
-
14
- task :compile_and_test do
15
- Rake::Task['compile'].invoke
16
- Rake::Task['test'].invoke
17
- end
18
-
19
- task default: :compile_and_test
8
+ task default: :test
@@ -1,3 +1,3 @@
1
1
  module Rubype
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/rubype.rb CHANGED
@@ -6,73 +6,104 @@ FalseClass.send(:include, Boolean)
6
6
 
7
7
  class Module
8
8
  private
9
- def __rubype__
10
- prepend (@__rubype__ = Module.new) unless @__rubype__
11
- @__rubype__
12
- end
9
+ # @return [Module]
10
+ def __rubype__
11
+ prepend (@__rubype__ = Module.new) unless @__rubype__
12
+ @__rubype__
13
+ end
13
14
 
14
- # @param hash [Hash] {method_name: [ArgClass1, ArgClass2, ... ArgClassn => RtnClass]}
15
- def typesig(hash)
16
- meth = hash.keys.first
17
- *arg_types, type_pair = hash.values.first
15
+ # @param meth [Symbol]
16
+ # @param type_info_hash [Hash] { [ArgInfo_1, ArgInfo_2, ... ArgInfo_n] => RtnInfo }
17
+ # @return self
18
+ def typesig(meth, type_info_hash)
19
+ ::Rubype.send(:define_typed_method, self, meth, type_info_hash, __rubype__)
20
+ self
21
+ end
22
+ end
18
23
 
19
- __rubype__.send(:define_method, meth) do |*args, &block|
20
- ::Rubype.send(:assert_arg_type, self, meth, args, arg_types << type_pair.keys.first)
21
- rtn = super(*args, &block)
22
- ::Rubype.send(:assert_trn_type, self, meth, rtn, type_pair.values.first)
23
- rtn
24
+ class Method
25
+ def type_info
26
+ if methods_hash = Rubype.typed_method_info[owner]
27
+ methods_hash[name]
24
28
  end
25
- self
26
29
  end
27
30
  end
28
31
 
29
32
  module Rubype
30
33
  class ArgumentTypeError < ::TypeError; end
31
34
  class ReturnTypeError < ::TypeError; end
35
+ @@typed_method_info = Hash.new({})
32
36
 
33
37
  class << self
38
+ def typed_method_info
39
+ @@typed_method_info
40
+ end
41
+
34
42
  private
43
+ # @param caller [Object]
44
+ # @param type_info_hash [Hash] { [ArgInfo_1, ArgInfo_2, ... ArgInfo_n] => RtnInfo }
45
+ # @param module [Module]
46
+ def define_typed_method(meth_caller, meth, type_info_hash, __rubype__)
47
+ arg_types, rtn_type = *strip_type_info(type_info_hash)
48
+ @@typed_method_info[meth_caller][meth] = {
49
+ arg_types => rtn_type
50
+ }
51
+ __rubype__.send(:define_method, meth) do |*args, &block|
52
+ ::Rubype.send(:assert_arg_type, meth_caller, meth, args, arg_types)
53
+ rtn = super(*args, &block)
54
+ ::Rubype.send(:assert_trn_type, meth_caller, meth, rtn, rtn_type)
55
+ rtn
56
+ end
57
+ end
35
58
 
36
- # @param caller [Module]
37
- # @param meth [Symbol]
38
- # @param args [Array<Object>]
39
- # @param type_infos [Array<Class, Symbol>]
40
- def assert_arg_type(caller, meth, args, type_infos)
41
- args.each_with_index do |arg, i|
42
- case type_check(arg, type_infos[i])
43
- when :need_correct_class
44
- raise ArgumentTypeError,
45
- "Expected #{caller.class}##{meth}'s #{i+1}th argument to be #{type_infos[i]} but got #{arg.inspect} instead"
46
- when :need_correct_method
47
- raise ArgumentTypeError,
48
- "Expected #{caller.class}##{meth}'s #{i+1}th argument to have method ##{type_infos[i]} but got #{arg.inspect} instead"
59
+ # @param type_info_hash [Hash] { [ArgInfo_1, ArgInfo_2, ... ArgInfo_n] => RtnInfo }
60
+ # @return arg_types [Array<Class, Symbol>], rtn_type [Class, Symbol]
61
+ def strip_type_info(type_info_hash)
62
+ arg_types, rtn_type = type_info_hash.first
63
+ [arg_types, rtn_type]
64
+ end
65
+
66
+ # @param caller [Module]
67
+ # @param meth [Symbol]
68
+ # @param args [Array<Object>]
69
+ # @param type_infos [Array<Class, Symbol>]
70
+ def assert_arg_type(caller, meth, args, type_infos)
71
+ args.zip(type_infos).each.with_index(1) do |(arg, type_info), i|
72
+ case type_check(arg, type_info)
73
+ when :need_correct_class
74
+ raise ArgumentTypeError,
75
+ "Expected #{caller.class}##{meth}'s #{i}th argument to be #{type_info} but got #{arg.inspect} instead"
76
+ when :need_correct_method
77
+ raise ArgumentTypeError,
78
+ "Expected #{caller.class}##{meth}'s #{i}th argument to have method ##{type_info} but got #{arg.inspect} instead"
79
+ end
49
80
  end
50
81
  end
51
- end
52
82
 
53
- # @param caller [Module]
54
- # @param rtn [Object]
55
- # @param type_info [Class, Symbol]
56
- def assert_trn_type(caller, meth, rtn, type_info)
57
- case type_check(rtn, type_info)
58
- when :need_correct_class
59
- raise ReturnTypeError,
60
- "Expected #{caller.class}##{meth} to return #{type_info} but got #{rtn.inspect} instead"
61
- when :need_correct_method
62
- raise ReturnTypeError,
63
- "Expected #{caller.class}##{meth} to have method ##{type_info} but got #{rtn.inspect} instead"
83
+ # @param caller [Module]
84
+ # @param rtn [Object]
85
+ # @param type_info [Class, Symbol]
86
+ def assert_trn_type(caller, meth, rtn, type_info)
87
+ case type_check(rtn, type_info)
88
+ when :need_correct_class
89
+ raise ReturnTypeError,
90
+ "Expected #{caller.class}##{meth} to return #{type_info} but got #{rtn.inspect} instead"
91
+ when :need_correct_method
92
+ raise ReturnTypeError,
93
+ "Expected #{caller.class}##{meth} to return object which has method ##{type_info} but got #{rtn.inspect} instead"
94
+ end
64
95
  end
65
- end
66
96
 
67
- # @param obj [Object]
68
- # @param type_info [Class, Symbol]
69
- # @return [Symbol]
70
- def type_check(obj, type_info)
71
- if type_info.is_a?(Module) && !(obj.is_a?(type_info) || type_info == Any)
72
- :need_correct_class
73
- elsif type_info.is_a?(Symbol) && !(obj.respond_to?(type_info))
74
- :need_correct_method
97
+ # @param obj [Object]
98
+ # @param type_info [Class, Symbol]
99
+ # @return [Symbol]
100
+ def type_check(obj, type_info)
101
+ case type_info
102
+ when Module
103
+ :need_correct_class unless (obj.is_a?(type_info) || type_info == Any)
104
+ when Symbol
105
+ :need_correct_method unless (obj.respond_to?(type_info))
106
+ end
75
107
  end
76
- end
77
108
  end
78
109
  end
data/rubype.gemspec CHANGED
@@ -8,7 +8,6 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Rubype::VERSION
9
9
  spec.authors = ["gogotanaka"]
10
10
  spec.email = ["mail@tanakakazuki.com"]
11
- spec.extensions = ["ext/rubype/extconf.rb"]
12
11
  spec.summary = %q{Ruby with type.}
13
12
  spec.description = %q{Ruby with type.}
14
13
  spec.homepage = "http://gogotanaka.me/"
@@ -19,8 +18,9 @@ Gem::Specification.new do |spec|
19
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
19
  spec.require_paths = ["lib"]
21
20
 
22
- spec.add_development_dependency "bundler"
21
+ spec.required_ruby_version = ">= 2.0.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
23
24
  spec.add_development_dependency "rake"
24
- spec.add_development_dependency "rake-compiler"
25
25
  spec.add_development_dependency "minitest"
26
26
  end
data/test/test_rubype.rb CHANGED
@@ -14,79 +14,89 @@ class TestRubype < MiniTest::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_correct_type_by_class
17
- assert_correct_type [Numeric => Numeric], [@numeric], @numeric
18
- assert_correct_type [Numeric => Array ], [@numeric], @array
19
- assert_correct_type [Numeric => String ], [@numeric], @string
20
- assert_correct_type [Numeric => Hash ], [@numeric], @hash
21
- assert_correct_type [Numeric => Symbol ], [@numeric], @symbol
22
- assert_correct_type [Numeric => Boolean], [@numeric], true
23
- assert_correct_type [Numeric => Boolean], [@numeric], false
24
-
25
- assert_correct_type [Boolean, Numeric => Numeric], [true, @numeric], @numeric
26
- assert_correct_type [Boolean, Array => Array ], [true, @array ], @array
27
- assert_correct_type [Boolean, String => String ], [true, @string ], @string
28
- assert_correct_type [Boolean, Hash => Hash ], [true, @hash ], @hash
29
- assert_correct_type [Boolean, Symbol => Symbol ], [true, @symbol ], @symbol
17
+ assert_correct_type({ [Numeric] => Numeric }, [@numeric], @numeric)
18
+ assert_correct_type({ [Numeric] => Array }, [@numeric], @array )
19
+ assert_correct_type({ [Numeric] => String }, [@numeric], @string )
20
+ assert_correct_type({ [Numeric] => Hash }, [@numeric], @hash )
21
+ assert_correct_type({ [Numeric] => Symbol }, [@numeric], @symbol )
22
+ assert_correct_type({ [Numeric] => Boolean }, [@numeric], true )
23
+ assert_correct_type({ [Numeric] => Boolean }, [@numeric], false )
24
+
25
+ assert_correct_type({ [Boolean, Numeric] => Numeric }, [true, @numeric], @numeric)
26
+ assert_correct_type({ [Boolean, Array ] => Array }, [true, @array ], @array)
27
+ assert_correct_type({ [Boolean, String ] => String }, [true, @string ], @string)
28
+ assert_correct_type({ [Boolean, Hash ] => Hash }, [true, @hash ], @hash)
29
+ assert_correct_type({ [Boolean, Symbol ] => Symbol }, [true, @symbol ], @symbol)
30
30
  end
31
31
 
32
32
  def test_correct_type_by_sym
33
- assert_correct_type [Numeric => :to_i], [@numeric], @numeric
34
- assert_correct_type [Numeric => :to_i], [@numeric], @string
35
-
36
- assert_correct_type [Numeric => :to_s], [@numeric], @numeric
37
- assert_correct_type [Numeric => :to_s], [@numeric], @string
38
- assert_correct_type [Numeric => :to_s], [@numeric], @symbol
39
- assert_correct_type [Numeric => :to_s], [@numeric], @array
40
- assert_correct_type [Numeric => :to_s], [@numeric], @hash
33
+ assert_correct_type({ [Numeric] => :to_i }, [@numeric], @numeric)
34
+ assert_correct_type({ [Numeric] => :to_i }, [@numeric], @string)
35
+
36
+ assert_correct_type({ [Numeric] => :to_s }, [@numeric], @numeric)
37
+ assert_correct_type({ [Numeric] => :to_s }, [@numeric], @string)
38
+ assert_correct_type({ [Numeric] => :to_s }, [@numeric], @symbol)
39
+ assert_correct_type({ [Numeric] => :to_s }, [@numeric], @array)
40
+ assert_correct_type({ [Numeric] => :to_s }, [@numeric], @hash)
41
41
  end
42
42
 
43
43
  def test_wrong_return_type
44
- assert_wrong_rtn [Numeric => Numeric], [@numeric], @array
45
- assert_wrong_rtn [Numeric => Numeric], [@numeric], @string
46
- assert_wrong_rtn [Numeric => Numeric], [@numeric], @hash
47
- assert_wrong_rtn [Numeric => Numeric], [@numeric], @symbol
48
- assert_wrong_rtn [Numeric => Numeric], [@numeric], true
49
-
50
- assert_wrong_rtn [Numeric, Numeric => Numeric], [@numeric, @numeric], @array
51
- assert_wrong_rtn [Numeric, Numeric => Numeric], [@numeric, @numeric], @string
52
- assert_wrong_rtn [Numeric, Numeric => Numeric], [@numeric, @numeric], @hash
53
- assert_wrong_rtn [Numeric, Numeric => Numeric], [@numeric, @numeric], @symbol
54
- assert_wrong_rtn [Numeric, Numeric => Numeric], [@numeric, @numeric], true
55
-
56
- assert_wrong_rtn [Numeric => :to_i], [@numeric], @symbol
57
- assert_wrong_rtn [Numeric => :to_i], [@numeric], @array
58
- assert_wrong_rtn [Numeric => :to_i], [@numeric], @hash
44
+ assert_wrong_rtn({ [Numeric] => Numeric }, [@numeric], @array)
45
+ assert_wrong_rtn({ [Numeric] => Numeric }, [@numeric], @string)
46
+ assert_wrong_rtn({ [Numeric] => Numeric }, [@numeric], @hash)
47
+ assert_wrong_rtn({ [Numeric] => Numeric }, [@numeric], @symbol)
48
+ assert_wrong_rtn({ [Numeric] => Numeric }, [@numeric], true)
49
+
50
+ assert_wrong_rtn({ [Numeric, Numeric] => Numeric }, [@numeric, @numeric], @array)
51
+ assert_wrong_rtn({ [Numeric, Numeric] => Numeric }, [@numeric, @numeric], @string)
52
+ assert_wrong_rtn({ [Numeric, Numeric] => Numeric }, [@numeric, @numeric], @hash)
53
+ assert_wrong_rtn({ [Numeric, Numeric] => Numeric }, [@numeric, @numeric], @symbol)
54
+ assert_wrong_rtn({ [Numeric, Numeric] => Numeric }, [@numeric, @numeric], true)
55
+
56
+ assert_wrong_rtn({ [Numeric] => :to_i }, [@numeric], @symbol)
57
+ assert_wrong_rtn({ [Numeric] => :to_i }, [@numeric], @array)
58
+ assert_wrong_rtn({ [Numeric] => :to_i }, [@numeric], @hash)
59
59
  end
60
60
 
61
61
  def test_wrong_args_type
62
- assert_wrong_arg [Numeric => Numeric], [@array ], @numeric
63
- assert_wrong_arg [Numeric => Numeric], [@string], @numeric
64
- assert_wrong_arg [Numeric => Numeric], [@hash ], @numeric
65
- assert_wrong_arg [Numeric => Numeric], [@symbol], @numeric
66
- assert_wrong_arg [Numeric => Numeric], [true ], @numeric
67
-
68
- assert_wrong_arg [Numeric, Numeric => Numeric], [@numeric, @array ], @numeric
69
- assert_wrong_arg [Numeric, Numeric => Numeric], [@numeric, @string], @numeric
70
- assert_wrong_arg [Numeric, Numeric => Numeric], [@numeric, @hash ], @numeric
71
- assert_wrong_arg [Numeric, Numeric => Numeric], [@numeric, @symbol], @numeric
72
- assert_wrong_arg [Numeric, Numeric => Numeric], [@numeric, true ], @numeric
73
-
74
- assert_wrong_arg [Numeric => :to_i], [@array ], @numeric
75
- assert_wrong_arg [Numeric => :to_i], [@hash ], @numeric
76
- assert_wrong_arg [Numeric => :to_i], [@symbol], @numeric
77
- assert_wrong_arg [Numeric => :to_i], [true ], @numeric
62
+ assert_wrong_arg({ [Numeric] => Numeric }, [@array ], @numeric)
63
+ assert_wrong_arg({ [Numeric] => Numeric }, [@string], @numeric)
64
+ assert_wrong_arg({ [Numeric] => Numeric }, [@hash ], @numeric)
65
+ assert_wrong_arg({ [Numeric] => Numeric }, [@symbol], @numeric)
66
+ assert_wrong_arg({ [Numeric] => Numeric }, [true ], @numeric)
67
+
68
+ assert_wrong_arg({ [Numeric, Numeric] => Numeric }, [@numeric, @array ], @numeric)
69
+ assert_wrong_arg({ [Numeric, Numeric] => Numeric }, [@numeric, @string], @numeric)
70
+ assert_wrong_arg({ [Numeric, Numeric] => Numeric }, [@numeric, @hash ], @numeric)
71
+ assert_wrong_arg({ [Numeric, Numeric] => Numeric }, [@numeric, @symbol], @numeric)
72
+ assert_wrong_arg({ [Numeric, Numeric] => Numeric }, [@numeric, true ], @numeric)
73
+
74
+ assert_wrong_arg({ [Numeric] => :to_i }, [@array ], @numeric)
75
+ assert_wrong_arg({ [Numeric] => :to_i }, [@hash ], @numeric)
76
+ assert_wrong_arg({ [Numeric] => :to_i }, [@symbol], @numeric)
77
+ assert_wrong_arg({ [Numeric] => :to_i }, [true ], @numeric)
78
78
  end
79
79
 
80
80
  def test_any
81
- assert_correct_type [Any => Any], [@array ], @numeric
82
- assert_correct_type [Any => Any], [@string], @numeric
83
- assert_correct_type [Any => Any], [@hash ], @numeric
84
- assert_correct_type [Any => Any], [@symbol], @numeric
85
-
86
- assert_correct_type [Any, Any => Any], [@numeric, @array ], @numeric
87
- assert_correct_type [Any, Any => Any], [@numeric, @string], @numeric
88
- assert_correct_type [Any, Any => Any], [@numeric, @hash ], @numeric
89
- assert_correct_type [Any, Any => Any], [@numeric, @symbol], @numeric
81
+ assert_correct_type({ [Any] => Any }, [@array ], @numeric)
82
+ assert_correct_type({ [Any] => Any }, [@string], @numeric)
83
+ assert_correct_type({ [Any] => Any }, [@hash ], @numeric)
84
+ assert_correct_type({ [Any] => Any }, [@symbol], @numeric)
85
+
86
+ assert_correct_type({ [Any, Any] => Any }, [@numeric, @array ], @numeric)
87
+ assert_correct_type({ [Any, Any] => Any }, [@numeric, @string], @numeric)
88
+ assert_correct_type({ [Any, Any] => Any }, [@numeric, @hash ], @numeric)
89
+ assert_correct_type({ [Any, Any] => Any }, [@numeric, @symbol], @numeric)
90
+ end
91
+
92
+ def test_type_info
93
+ klass = Class.new.class_eval <<-RUBY_CODE
94
+ def test_mth
95
+ end
96
+ typesig :test_mth, [Numeric, Numeric] => String
97
+ RUBY_CODE
98
+
99
+ assert_equal klass.new.method(:test_mth).type_info, { [Numeric, Numeric] => String }
90
100
  end
91
101
 
92
102
  private
@@ -111,7 +121,7 @@ class TestRubype < MiniTest::Unit::TestCase
111
121
  def call(#{arg_literal(args.count)})
112
122
  #{obj_literal(val)}
113
123
  end
114
- typesig call: #{obj_literal(type_list)}
124
+ typesig :call, #{obj_literal(type_list)}
115
125
  RUBY_CODE
116
126
 
117
127
  klass.new
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.3'
20
20
  type: :development
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: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake-compiler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: minitest
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -71,8 +57,7 @@ email:
71
57
  - mail@tanakakazuki.com
72
58
  executables:
73
59
  - rubype
74
- extensions:
75
- - ext/rubype/extconf.rb
60
+ extensions: []
76
61
  extra_rdoc_files: []
77
62
  files:
78
63
  - ".gitignore"
@@ -102,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
87
  requirements:
103
88
  - - ">="
104
89
  - !ruby/object:Gem::Version
105
- version: '0'
90
+ version: 2.0.0
106
91
  required_rubygems_version: !ruby/object:Gem::Requirement
107
92
  requirements:
108
93
  - - ">="
@@ -110,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
95
  version: '0'
111
96
  requirements: []
112
97
  rubyforge_project:
113
- rubygems_version: 2.2.2
98
+ rubygems_version: 2.4.5
114
99
  signing_key:
115
100
  specification_version: 4
116
101
  summary: Ruby with type.