rdl 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -0
  3. data/CHANGES.md +35 -0
  4. data/README.md +153 -116
  5. data/bin/rdl_query +1 -1
  6. data/extras/type_tests/typetests.rb +905 -0
  7. data/lib/rdl.rb +0 -1
  8. data/lib/rdl/boot.rb +108 -77
  9. data/lib/rdl/boot_rails.rb +2 -8
  10. data/lib/rdl/config.rb +44 -17
  11. data/lib/rdl/contracts/flat.rb +1 -1
  12. data/lib/rdl/info.rb +3 -3
  13. data/lib/rdl/query.rb +11 -11
  14. data/lib/rdl/typecheck.rb +399 -136
  15. data/lib/rdl/types/finite_hash.rb +3 -2
  16. data/lib/rdl/types/generic.rb +7 -6
  17. data/lib/rdl/types/intersection.rb +3 -2
  18. data/lib/rdl/types/lexer.rex +2 -3
  19. data/lib/rdl/types/lexer.rex.rb +1 -4
  20. data/lib/rdl/types/method.rb +7 -6
  21. data/lib/rdl/types/nominal.rb +10 -1
  22. data/lib/rdl/types/parser.racc +7 -8
  23. data/lib/rdl/types/parser.tab.rb +108 -109
  24. data/lib/rdl/types/structural.rb +1 -0
  25. data/lib/rdl/types/tuple.rb +2 -2
  26. data/lib/rdl/types/type.rb +8 -8
  27. data/lib/rdl/types/type_inferencer.rb +1 -1
  28. data/lib/rdl/types/union.rb +2 -1
  29. data/lib/rdl/util.rb +28 -3
  30. data/lib/rdl/wrap.rb +216 -165
  31. data/lib/rdl_disable.rb +22 -15
  32. data/lib/types/core.rb +2 -4
  33. data/lib/types/core/_aliases.rb +14 -0
  34. data/lib/types/core/abbrev.rb +3 -0
  35. data/lib/types/core/array.rb +139 -0
  36. data/lib/types/core/base64.rb +8 -0
  37. data/lib/types/core/basic_object.rb +12 -0
  38. data/lib/types/core/benchmark.rb +9 -0
  39. data/lib/types/core/bigdecimal.rb +223 -0
  40. data/lib/types/core/bigmath.rb +10 -0
  41. data/lib/types/core/bignum.rb +214 -0
  42. data/lib/types/core/class.rb +15 -0
  43. data/lib/types/core/complex.rb +123 -0
  44. data/lib/types/core/coverage.rb +4 -0
  45. data/lib/types/core/csv.rb +3 -0
  46. data/lib/types/core/date.rb +4 -0
  47. data/lib/types/core/dir.rb +37 -0
  48. data/lib/types/core/encoding.rb +21 -0
  49. data/lib/types/core/enumerable.rb +96 -0
  50. data/lib/types/core/enumerator.rb +24 -0
  51. data/lib/types/core/exception.rb +15 -0
  52. data/lib/types/core/file.rb +125 -0
  53. data/lib/types/core/fileutils.rb +4 -0
  54. data/lib/types/core/fixnum.rb +213 -0
  55. data/lib/types/core/float.rb +199 -0
  56. data/lib/types/core/gem.rb +19 -0
  57. data/lib/types/core/hash.rb +72 -0
  58. data/lib/types/core/integer.rb +194 -0
  59. data/lib/types/core/io.rb +101 -0
  60. data/lib/types/core/kernel.rb +89 -0
  61. data/lib/types/core/marshal.rb +3 -0
  62. data/lib/types/core/matchdata.rb +24 -0
  63. data/lib/types/core/math.rb +50 -0
  64. data/lib/types/core/module.rb +81 -0
  65. data/lib/types/core/nil.rb +11 -0
  66. data/lib/types/core/numeric.rb +56 -0
  67. data/lib/types/core/object.rb +73 -0
  68. data/lib/types/core/pathname.rb +104 -0
  69. data/lib/types/core/proc.rb +12 -0
  70. data/lib/types/core/process.rb +110 -0
  71. data/lib/types/core/random.rb +13 -0
  72. data/lib/types/core/range.rb +37 -0
  73. data/lib/types/core/rational.rb +207 -0
  74. data/lib/types/core/regexp.rb +28 -0
  75. data/lib/types/core/set.rb +56 -0
  76. data/lib/types/core/string.rb +140 -0
  77. data/lib/types/core/strscan.rb +6 -0
  78. data/lib/types/core/symbol.rb +27 -0
  79. data/lib/types/core/time.rb +66 -0
  80. data/lib/types/core/uri.rb +18 -0
  81. data/lib/types/core/yaml.rb +3 -0
  82. data/lib/types/devise.rb +1 -0
  83. data/lib/types/devise/controller_helpers.rb +3 -0
  84. data/lib/types/devise/parameter_sanitizer.rb +2 -0
  85. data/lib/types/pundit.rb +2 -0
  86. data/lib/types/rails/_helpers.rb +50 -0
  87. data/lib/types/rails/abstract_controller/translation.rb +2 -0
  88. data/lib/types/rails/action_controller/base.rb +3 -0
  89. data/lib/types/rails/action_controller/instrumentation.rb +6 -0
  90. data/lib/types/rails/action_controller/metal.rb +3 -0
  91. data/lib/types/rails/action_controller/mime_responds.rb +13 -0
  92. data/lib/types/rails/action_controller/parameters.rb +3 -0
  93. data/lib/types/{rails-5.x → rails}/action_controller/strong_parameters.rb +4 -8
  94. data/lib/types/rails/action_dispatch/flashhash.rb +8 -0
  95. data/lib/types/rails/action_dispatch/routing.rb +10 -0
  96. data/lib/types/rails/action_mailer/base.rb +2 -0
  97. data/lib/types/rails/action_mailer/message_delivery.rb +2 -0
  98. data/lib/types/rails/action_view/helpers_sanitizehelper.rb +2 -0
  99. data/lib/types/rails/action_view/helpers_urlhelper.rb +5 -0
  100. data/lib/types/rails/active_model/errors.rb +14 -0
  101. data/lib/types/rails/active_model/validations.rb +2 -0
  102. data/lib/types/rails/active_record/associations.rb +208 -0
  103. data/lib/types/rails/active_record/base.rb +2 -0
  104. data/lib/types/rails/active_record/core.rb +2 -0
  105. data/lib/types/rails/active_record/finder_methods.rb +2 -0
  106. data/lib/types/rails/active_record/model_schema.rb +37 -0
  107. data/lib/types/rails/active_record/relation.rb +11 -0
  108. data/lib/types/rails/active_record/schema_types.rb +51 -0
  109. data/lib/types/rails/active_record/validations.rb +2 -0
  110. data/lib/types/rails/active_support/base.rb +2 -0
  111. data/lib/types/rails/active_support/logger.rb +3 -0
  112. data/lib/types/rails/active_support/tagged_logging.rb +2 -0
  113. data/lib/types/rails/active_support/time_with_zone.rb +13 -0
  114. data/lib/types/rails/active_support/time_zone.rb +2 -0
  115. data/lib/types/rails/fixnum.rb +2 -0
  116. data/lib/types/rails/integer.rb +2 -0
  117. data/lib/types/rails/rack/request.rb +2 -0
  118. data/lib/types/rails/string.rb +3 -0
  119. data/lib/types/rails/time.rb +1 -0
  120. data/rdl.gemspec +2 -2
  121. data/test/disabled_test_rdoc.rb +8 -8
  122. data/test/test_alias.rb +1 -0
  123. data/test/test_dsl.rb +4 -4
  124. data/test/test_generic.rb +45 -38
  125. data/test/test_intersection.rb +10 -10
  126. data/test/test_le.rb +103 -102
  127. data/test/test_member.rb +33 -33
  128. data/test/test_parser.rb +101 -96
  129. data/test/test_query.rb +84 -84
  130. data/test/test_rdl.rb +87 -52
  131. data/test/test_rdl_type.rb +26 -9
  132. data/test/test_type_contract.rb +32 -31
  133. data/test/test_typecheck.rb +802 -436
  134. data/test/test_types.rb +39 -39
  135. data/test/test_wrap.rb +3 -2
  136. metadata +91 -120
  137. data/extras/type_tests/%.rb +0 -171
  138. data/extras/type_tests/&.rb +0 -159
  139. data/extras/type_tests/**.rb +0 -222
  140. data/extras/type_tests/*.rb +0 -177
  141. data/extras/type_tests/+.rb +0 -170
  142. data/extras/type_tests/-.rb +0 -171
  143. data/extras/type_tests/1scomp.rb +0 -157
  144. data/extras/type_tests/<.rb +0 -170
  145. data/extras/type_tests/<<.rb +0 -159
  146. data/extras/type_tests/>>.rb +0 -159
  147. data/extras/type_tests/[].rb +0 -163
  148. data/extras/type_tests/^.rb +0 -159
  149. data/extras/type_tests/abs.rb +0 -155
  150. data/extras/type_tests/abs2.rb +0 -164
  151. data/extras/type_tests/angle.rb +0 -157
  152. data/extras/type_tests/arg.rb +0 -157
  153. data/extras/type_tests/bit_length.rb +0 -157
  154. data/extras/type_tests/ceil.rb +0 -157
  155. data/extras/type_tests/ceilRational.rb +0 -160
  156. data/extras/type_tests/conj.rb +0 -158
  157. data/extras/type_tests/defwhere.rb +0 -86
  158. data/extras/type_tests/denominator.rb +0 -157
  159. data/extras/type_tests/div.rb +0 -172
  160. data/extras/type_tests/divslash.rb +0 -179
  161. data/extras/type_tests/even?.rb +0 -157
  162. data/extras/type_tests/fdiv.rb +0 -244
  163. data/extras/type_tests/finite?.rb +0 -157
  164. data/extras/type_tests/floor.rb +0 -157
  165. data/extras/type_tests/floorRational.rb +0 -161
  166. data/extras/type_tests/hash.rb +0 -157
  167. data/extras/type_tests/imag.rb +0 -158
  168. data/extras/type_tests/infinite?.rb +0 -157
  169. data/extras/type_tests/modulo.rb +0 -171
  170. data/extras/type_tests/nan?.rb +0 -157
  171. data/extras/type_tests/neg.rb +0 -155
  172. data/extras/type_tests/next.rb +0 -157
  173. data/extras/type_tests/next_float.rb +0 -157
  174. data/extras/type_tests/numerator.rb +0 -157
  175. data/extras/type_tests/phase.rb +0 -157
  176. data/extras/type_tests/prev_float.rb +0 -157
  177. data/extras/type_tests/quo.rb +0 -179
  178. data/extras/type_tests/rationalize.rb +0 -157
  179. data/extras/type_tests/rationalizeArg.rb +0 -198
  180. data/extras/type_tests/real.rb +0 -157
  181. data/extras/type_tests/real?.rb +0 -157
  182. data/extras/type_tests/round.rb +0 -157
  183. data/extras/type_tests/roundArg.rb +0 -169
  184. data/extras/type_tests/size.rb +0 -157
  185. data/extras/type_tests/to_c.rb +0 -157
  186. data/extras/type_tests/to_f.rb +0 -155
  187. data/extras/type_tests/to_i.rb +0 -157
  188. data/extras/type_tests/to_r.rb +0 -157
  189. data/extras/type_tests/to_s.rb +0 -157
  190. data/extras/type_tests/truncate.rb +0 -157
  191. data/extras/type_tests/truncateArg.rb +0 -166
  192. data/extras/type_tests/type tests +0 -1
  193. data/extras/type_tests/zero?.rb +0 -155
  194. data/extras/type_tests/|.rb +0 -159
  195. data/lib/types/core-ruby-2.x/_aliases.rb +0 -15
  196. data/lib/types/core-ruby-2.x/abbrev.rb +0 -5
  197. data/lib/types/core-ruby-2.x/array.rb +0 -137
  198. data/lib/types/core-ruby-2.x/base64.rb +0 -10
  199. data/lib/types/core-ruby-2.x/basic_object.rb +0 -14
  200. data/lib/types/core-ruby-2.x/benchmark.rb +0 -11
  201. data/lib/types/core-ruby-2.x/bigdecimal.rb +0 -224
  202. data/lib/types/core-ruby-2.x/bigmath.rb +0 -12
  203. data/lib/types/core-ruby-2.x/bignum.rb +0 -214
  204. data/lib/types/core-ruby-2.x/class.rb +0 -17
  205. data/lib/types/core-ruby-2.x/complex.rb +0 -124
  206. data/lib/types/core-ruby-2.x/coverage.rb +0 -6
  207. data/lib/types/core-ruby-2.x/csv.rb +0 -5
  208. data/lib/types/core-ruby-2.x/date.rb +0 -6
  209. data/lib/types/core-ruby-2.x/dir.rb +0 -38
  210. data/lib/types/core-ruby-2.x/encoding.rb +0 -23
  211. data/lib/types/core-ruby-2.x/enumerable.rb +0 -98
  212. data/lib/types/core-ruby-2.x/enumerator.rb +0 -26
  213. data/lib/types/core-ruby-2.x/exception.rb +0 -17
  214. data/lib/types/core-ruby-2.x/file.rb +0 -126
  215. data/lib/types/core-ruby-2.x/fileutils.rb +0 -6
  216. data/lib/types/core-ruby-2.x/fixnum.rb +0 -213
  217. data/lib/types/core-ruby-2.x/float.rb +0 -199
  218. data/lib/types/core-ruby-2.x/gem.rb +0 -247
  219. data/lib/types/core-ruby-2.x/hash.rb +0 -72
  220. data/lib/types/core-ruby-2.x/integer.rb +0 -197
  221. data/lib/types/core-ruby-2.x/io.rb +0 -103
  222. data/lib/types/core-ruby-2.x/kernel.rb +0 -90
  223. data/lib/types/core-ruby-2.x/marshal.rb +0 -5
  224. data/lib/types/core-ruby-2.x/matchdata.rb +0 -26
  225. data/lib/types/core-ruby-2.x/math.rb +0 -53
  226. data/lib/types/core-ruby-2.x/module.rb +0 -83
  227. data/lib/types/core-ruby-2.x/nil.rb +0 -12
  228. data/lib/types/core-ruby-2.x/numeric.rb +0 -56
  229. data/lib/types/core-ruby-2.x/object.rb +0 -75
  230. data/lib/types/core-ruby-2.x/pathname.rb +0 -106
  231. data/lib/types/core-ruby-2.x/proc.rb +0 -16
  232. data/lib/types/core-ruby-2.x/process.rb +0 -127
  233. data/lib/types/core-ruby-2.x/random.rb +0 -17
  234. data/lib/types/core-ruby-2.x/range.rb +0 -39
  235. data/lib/types/core-ruby-2.x/rational.rb +0 -209
  236. data/lib/types/core-ruby-2.x/regexp.rb +0 -30
  237. data/lib/types/core-ruby-2.x/set.rb +0 -58
  238. data/lib/types/core-ruby-2.x/string.rb +0 -143
  239. data/lib/types/core-ruby-2.x/strscan.rb +0 -7
  240. data/lib/types/core-ruby-2.x/symbol.rb +0 -29
  241. data/lib/types/core-ruby-2.x/time.rb +0 -68
  242. data/lib/types/core-ruby-2.x/uri.rb +0 -20
  243. data/lib/types/core-ruby-2.x/yaml.rb +0 -5
  244. data/lib/types/rails-5.x/_helpers.rb +0 -52
  245. data/lib/types/rails-5.x/action_controller/mime_responds.rb +0 -11
  246. data/lib/types/rails-5.x/action_dispatch/routing.rb +0 -10
  247. data/lib/types/rails-5.x/active_model/errors.rb +0 -15
  248. data/lib/types/rails-5.x/active_model/validations.rb +0 -5
  249. data/lib/types/rails-5.x/active_record/associations.rb +0 -190
  250. data/lib/types/rails-5.x/active_record/core.rb +0 -3
  251. data/lib/types/rails-5.x/active_record/model_schema.rb +0 -39
  252. data/lib/types/rails-5.x/fixnum.rb +0 -3
@@ -1,159 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bigdecimal'
4
- require 'rdl'
5
- require 'rdl_types'
6
-
7
- MAX_FIXNUM = 2**(0.size*8-2)-1 #Largest fixnum. -2 since 1 bit used for sign, 1 bit used as int marker.
8
- MIN_FIXNUM = -(2**(0.size*8-2)) #Smallest fixnum.
9
-
10
- def test()
11
- x = gen_number(0.5,0.5,0,0,0,0,0,0)
12
- type_one = x.class.to_s
13
- y = gen_number(0.5,0.5,0,0,0,0,0,0)
14
- type_two = y.class.to_s
15
- #puts "Arg1= #{x} and type = #{type_one}"
16
- #puts "Arg2= #{y} and type = #{type_two}"
17
- operation_type = query(type_one+'#|',y)
18
- expected_type = operation_type[operation_type.index('->')+3..-1]
19
- w = x|y
20
- #puts "here"
21
- test_result = w.is_a?(Object.const_get(expected_type))
22
- if !test_result
23
- puts "Arg1= #{x} (type: #{type_one})"
24
- puts "Arg2= #{y} (type: #{type_two})"
25
- puts "Res= #{w}"
26
- puts "Expected type: #{expected_type}"
27
- puts "Received type: #{w.class}"
28
- end
29
- #puts test_result
30
- return test_result
31
- end
32
-
33
- def gen_fixnum()
34
- return Random.rand(MIN_FIXNUM..MAX_FIXNUM)
35
- end
36
-
37
- def gen_bignum()
38
- r = Random.rand()
39
- if r<0.5
40
- return Random.rand(MAX_FIXNUM+1..MAX_FIXNUM*1000)
41
- else
42
- return -1*Random.rand(MAX_FIXNUM+1..MAX_FIXNUM*1000)
43
- end
44
- end
45
-
46
- def gen_float()
47
- r = Random.rand()
48
- if r<0.5
49
- return Float::MAX*Random.rand
50
- else
51
- return -1*Float::MAX*Random.rand
52
- end
53
- end
54
-
55
- def gen_bigdec()
56
- r = Random.rand()
57
- if r<0.33
58
- return BigDecimal.new(gen_fixnum())
59
- elsif r<0.66
60
- return BigDecimal.new(gen_bignum())
61
- else
62
- return BigDecimal.new(gen_float(),0)
63
- end
64
- end
65
-
66
- def gen_complex()
67
- x = gen_number(0.2,0.2,0.1,0.05,0.05,0.3,0,0.1)
68
- #puts x
69
- y = gen_number(0.2,0.2,0.1,0.05,0.05,0.3,0,0.1)
70
- #puts y
71
- return Complex(x,y)
72
- end
73
-
74
- def gen_rational()
75
- x = gen_fixnum()
76
- y = gen_fixnum()
77
- return Rational(x,y)
78
- end
79
-
80
-
81
- def gen_number(probFixnum,probBignum,probBigDec,probInf,probNAN,probFloat,probComplex,probRational)
82
- r = Random.rand()
83
- if r<probFixnum then
84
- #Fixnum type
85
- x = gen_fixnum()
86
- elsif r<(probFixnum+probBignum)
87
- x = gen_bignum()
88
- elsif r<(probFixnum+probBignum+probBigDec)
89
- #BigDecimal type
90
- x = gen_bigdec()
91
- elsif r<(probFixnum+probBignum+probBigDec+probInf)
92
- x=Float::INFINITY
93
- elsif r<(probFixnum+probBignum+probBigDec+probInf+probNAN)
94
- x=Float::NAN
95
- elsif r<(probFixnum+probBignum+probBigDec+probInf+probNAN+probFloat)
96
- #Random Float type
97
- x = gen_float()
98
- elsif r<(probFixnum+probBignum+probBigDec+probInf+probNAN+probFloat+probComplex)
99
- x= gen_complex()
100
- elsif (probFixnum+probBignum+probBigDec+probInf+probNAN+probFloat+probComplex+probRational)
101
- x = gen_rational()
102
- end
103
- return x
104
- end
105
-
106
- def rounds(x)
107
- counter = 0
108
- for i in 0..x
109
- b= test()
110
- if (!b) then
111
- counter=counter+1
112
- end
113
-
114
- end
115
- return counter
116
- end
117
-
118
- def query(q,y)
119
- $__rdl_contract_switch.off {
120
- if q =~ /^(\w+(#|\.))?(\w+(!|\?|=)?|!|~|\+|\*\*|-|\*|\/|%|<<|>>|&|\||\^|<|<=|=>|>|==|===|!=|=~|!~|<=>|\[\]|\[\]=)$/
121
- klass = nil
122
- klass_pref = nil
123
- meth = nil
124
- if q =~ /(.+)#(.+)/
125
- klass = $1
126
- klass_pref = "#{klass}#"
127
- meth = $2.to_sym
128
- elsif q =~ /(.+)\.(.+)/
129
- klass_pref = "#{$1}."
130
- klass = RDL::Util.add_singleton_marker($1)
131
- meth = $2.to_sym
132
- else
133
- klass = self.class.to_s
134
- klass_pref = "#{klass}#"
135
- meth = q.to_sym
136
- end
137
- if RDL::Wrap.has_contracts?(klass, meth, :type)
138
- typs = RDL::Wrap.get_contracts(klass, meth, :type)
139
- typs.each { |t|
140
- #puts "#{klass_pref}#{meth}: #{t}"
141
- t_string = "#{t}"
142
- t_string =~ /\((\w*)\)(.+)/
143
-
144
- #puts y
145
- if y.is_a?(Object.const_get($1))
146
- return t_string
147
- end
148
- #return "#{t}"
149
- }
150
- nil
151
- else
152
- #puts "No type for #{klass_pref}#{meth}"
153
- end
154
- else
155
- #puts "Not implemented"
156
- end
157
- }
158
- end
159
-
@@ -1,15 +0,0 @@
1
- if defined? BigDecimal
2
- type_alias '%real', 'Fixnum or Bignum or Float or Rational or BigDecimal'
3
- type_alias '%numeric', 'Fixnum or Bignum or Float or Rational or BigDecimal or Complex'
4
- else
5
- type_alias '%real', 'Fixnum or Bignum or Float or Rational'
6
- type_alias '%numeric', 'Fixnum or Bignum or Float or Rational'
7
- end
8
- type_alias '%string', '[to_str: () -> String]'
9
- type_alias '%integer', 'Fixnum or Bignum'
10
- if defined? Pathname
11
- type_alias '%path', '%string or Pathname'
12
- else
13
- type_alias '%path', '%string'
14
- end
15
- type_alias '%open_args', '{external_encoding: ?String, internal_encoding: ?String, encoding: ?String, textmode: ?%any, binmode: ?%any, autoclose: ?%any, mode: ?String}'
@@ -1,5 +0,0 @@
1
- module Abbrev
2
- rdl_nowrap
3
-
4
- type 'self.abbrev', '(Array<String>) -> Hash<String,String>'
5
- end
@@ -1,137 +0,0 @@
1
- class Array
2
- rdl_nowrap
3
-
4
- type_params [:t], :all?
5
-
6
- type :<<, '(t) -> Array<t>'
7
- type :[], '(Range<%integer>) -> Array<t>'
8
- type :[], '(%integer or Float) -> t'
9
- type :[], '(%integer, %integer) -> Array<t>'
10
- type :&, '(Array<u>) -> Array<t>'
11
- type :*, '(%integer) -> Array<t>'
12
- type :*, '(String) -> String'
13
- type :+, '(Enumerable<u>) -> Array<u or t>'
14
- type :-, '(Array<u>) -> Array<u or t>'
15
- type :slice, '(Range<%integer>) -> Array<t>'
16
- type :slice, '(%integer) -> t'
17
- type :slice, '(%integer, %integer) -> Array<t>'
18
- type :[]=, '(%integer, t) -> t'
19
- type :[]=, '(%integer, %integer, t) -> t'
20
- #type :[]=, '(%integer, %integer, Array<t>) -> Array<t>'
21
- #type :[]=, '(Range, Array<t>) -> Array<t>'
22
- type :[]=, '(Range<%integer>, t) -> t'
23
- type :assoc, '(t) -> Array<t>'
24
- type :at, '(%integer) -> t'
25
- type :clear, '() -> Array<t>'
26
- type :map, '() {(t) -> u} -> Array<u>'
27
- type :map, '() -> Enumerator<t>'
28
- type :map!, '() {(t) -> u} -> Array<u>'
29
- type :map!, '() -> Enumerator<t>'
30
- type :collect, '() { (t) -> u } -> Array<u>'
31
- type :collect, '() -> Enumerator<t>'
32
- type :combination, '(%integer) { (Array<t>) -> %any } -> Array<t>'
33
- type :combination, '(%integer) -> Enumerator<t>'
34
- type :push, '(?t) -> Array<t>'
35
- type :compact, '() -> Array<t>'
36
- type :compact!, '() -> Array<t>'
37
- type :concat, '(Array<t>) -> Array<t>'
38
- type :count, '() -> %integer'
39
- type :count, '(t) -> %integer'
40
- type :count, '() { (t) -> %bool } -> %integer'
41
- type :cycle, '(?%integer) { (t) -> %any } -> %any'
42
- type :cycle, '(?%integer) -> Enumerator<t>'
43
- type :delete, '(u) -> t'
44
- type :delete, '(u) { () -> v } -> t or v'
45
- type :delete_at, '(%integer) -> Array<t>'
46
- type :delete_if, '() { (t) -> %bool } -> Array<t>'
47
- type :delete_if, '() -> Enumerator<t>'
48
- type :drop, '(%integer) -> Array<t>'
49
- type :drop_while, '() { (t) -> %bool } -> Array<t>'
50
- type :drop_while, '() -> Enumerator<t>'
51
- type :each, '() -> Enumerator<t>'
52
- type :each, '() { (t) -> %any } -> Array<t>'
53
- type :each_index, '() { (%integer) -> %any } -> Array<t>'
54
- type :each_index, '() -> Enumerator<t>'
55
- type :empty?, '() -> %bool'
56
- type :fetch, '(%integer) -> t'
57
- type :fetch, '(%integer, u) -> u'
58
- type :fetch, '(%integer) { (%integer) -> u } -> t or u'
59
- type :fill, '(t) -> Array<t>'
60
- type :fill, '(t, %integer, ?%integer) -> Array<t>'
61
- type :fill, '(t, Range<%integer>) -> Array<t>'
62
- type :fill, '() { (%integer) -> t } -> Array<t>'
63
- type :fill, '(%integer, ?%integer) { (%integer) -> t } -> Array<t>'
64
- type :fill, '(Range<%integer>) { (%integer) -> t } -> Array<t>'
65
- type :flatten, '() -> Array<%any>' # Can't give a more precise type
66
- type :index, '(u) -> %integer'
67
- type :index, '() { (t) -> %bool } -> %integer'
68
- type :index, '() -> Enumerator<t>'
69
- type :first, '() -> t'
70
- type :first, '(%integer) -> Array<t>'
71
- type :include?, '(u) -> %bool'
72
- type :insert, '(%integer, *t) -> Array<t>'
73
- type :inspect, '() -> String'
74
- type :join, '(?String) -> String'
75
- type :keep_if, '() { (t) -> %bool } -> Array<t>'
76
- type :last, '() -> t'
77
- type :last, '(%integer) -> Array<t>'
78
- type :member, '(u) -> %bool'
79
- type :length, '() -> Fixnum'
80
- type :permutation, '(?%integer) -> Enumerator<t>'
81
- type :permutation, '(?%integer) { (Array<t>) -> %any } -> Array<t>'
82
- type :pop, '(%integer) -> Array<t>'
83
- type :pop, '() -> t'
84
- type :product, '(*Array<u>) -> Array<Array<t or u>>'
85
- type :rassoc, '(u) -> t'
86
- type :reject, '() { (t) -> %bool } -> Array<t>'
87
- type :reject, '() -> Enumerator<t>'
88
- type :reject!, '() { (t) -> %bool } -> Array<t>'
89
- type :reject!, '() -> Enumerator<t>'
90
- type :repeated_combination, '(%integer) { (Array<t>) -> %any } -> Array<t>'
91
- type :repeated_combination, '(%integer) -> Enumerator<t>'
92
- type :repeated_permutation, '(%integer) { (Array<t>) -> %any } -> Array<t>'
93
- type :repeated_permutation, '(%integer) -> Enumerator<t>'
94
- type :reverse, '() -> Array<t>'
95
- type :reverse!, '() -> Array<t>'
96
- type :reverse_each, '() { (t) -> %any } -> Array<t>'
97
- type :reverse_each, '() -> Enumerator<t>'
98
- type :rindex, '(u) -> t'
99
- type :rindex, '() { (t) -> %bool } -> %integer'
100
- type :rindex, '() -> Enumerator<t>'
101
- type :rotate, '(?%integer) -> Array<t>'
102
- type :rotate!, '(?%integer) -> Array<t>'
103
- type :sample, '() -> t'
104
- type :sample, '(%integer) -> Array<t>'
105
- type :select, '() { (t) -> %bool } -> Array<t>'
106
- type :select, '() -> Enumerator<t>'
107
- type :select!, '() { (t) -> %bool } -> Array<t>'
108
- type :select!, '() -> Enumerator<t>'
109
- type :shift, '() -> t'
110
- type :shift, '(%integer) -> Array<t>'
111
- type :shuffle, '() -> Array<t>'
112
- type :shuffle!, '() -> Array<t>'
113
- rdl_alias :size, :length
114
- rdl_alias :slice, :[]
115
- type :slice!, '(Range<%integer>) -> Array<t>'
116
- type :slice!, '(%integer, %integer) -> Array<t>'
117
- type :slice!, '(%integer or Float) -> t'
118
- type :sort, '() -> Array<t>'
119
- type :sort, '() { (t,t) -> %integer } -> Array<t>'
120
- type :sort!, '() -> Array<t>'
121
- type :sort!, '() { (t,t) -> %integer } -> Array<t>'
122
- type :sort_by!, '() { (t) -> u } -> Array<t>'
123
- type :sort_by!, '() -> Enumerator<t>'
124
- type :take, '(%integer) -> Array<t>'
125
- type :take_while, '() { (t) ->%bool } -> Array<t>'
126
- type :take_while, '() -> Enumerator<t>'
127
- type :to_a, '() -> Array<t>'
128
- type :to_ary, '() -> Array<t>'
129
- rdl_alias :to_s, :inspect
130
- type :transpose, '() -> Array<t>'
131
- type :uniq, '() -> Array<t>'
132
- type :uniq!, '() -> Array<t>'
133
- type :unshift, '(*t) -> Array<t>'
134
- type :values_at, '(*Range<%integer> or %integer) -> Array<t>'
135
- type :zip, '(*Array<u>) -> Array<Array<t or u>>'
136
- type :|, '(Array<u>) -> Array<t or u>'
137
- end
@@ -1,10 +0,0 @@
1
- module Base64
2
- rdl_nowrap
3
-
4
- type 'self.decode64', '(String) -> String'
5
- type 'self.encode64', '(String) -> String'
6
- type 'self.strict_decode64', '(String) -> String'
7
- type 'self.strict_encode64', '(String) -> String'
8
- type 'self.urlsafe_decode64', '(String) -> String'
9
- type 'self.urlsafe_encode64', '(String) -> String'
10
- end
@@ -1,14 +0,0 @@
1
- class BasicObject
2
- rdl_nowrap
3
-
4
- type :==, '(%any other) -> %bool'
5
- type :equal?, '(%any other) -> %bool'
6
- type :!, '() -> %bool'
7
- type :!=, '(%any other) -> %bool'
8
- type :instance_eval, '(String, ?String filename, ?Fixnum lineno) -> %any'
9
- type :instance_eval, '() { () -> %any } -> %any'
10
- type :instance_exec, '(*%any args) { (*%any) -> %any } -> %any'
11
- type :__send__, '(Symbol, *%any) -> %any obj'
12
- rdl_alias :__id__, :object_id
13
- type :object_id, '() -> Fixnum'
14
- end
@@ -1,11 +0,0 @@
1
- module Benchmark
2
- rdl_nowrap
3
-
4
- type 'self.benchmark', '(String, ?Fixnum, ?String, *String) -> Array<Benchmark::Tms>'
5
- type 'self.bm', '(?Fixnum, *String) { (Benchmark::Process) -> nil} -> Array<Benchmark::Tms>'
6
- #type 'self.benchmark', '(Caption: String, Label_Width: ?Fixnum, Format: ?String, Labels: *String) -> Benchmark::Tms'
7
- #type 'self.bm', '(Label_Width: ?Fixnum, Labels: *String) { (Benchmark::Process) -> nil} -> Array<Benchmark::Tms>'
8
- type 'self.bmbm', '(?Fixnum label_width) { (Benchmark::Process) -> nil} -> Array<Benchmark::Tms>'
9
- type 'self.measure', '(?String label) -> Benchmark::Tms'
10
- type 'self.realtime', '() {(*%any) -> %any} -> Fixnum'
11
- end
@@ -1,224 +0,0 @@
1
- class BigDecimal < Numeric
2
- rdl_nowrap
3
-
4
- type :%, '(%numeric) -> BigDecimal'
5
- pre(:%) { |x| x!=0&&(if x.is_a?(Float) then x!=Float::INFINITY && !x.nan? else true end)}
6
-
7
- type :+, '(%integer) -> BigDecimal'
8
- type :+, '(Float x {{ !x.infinite? && !x.nan? }}) -> BigDecimal'
9
- type :+, '(Rational) -> BigDecimal'
10
- type :+, '(BigDecimal) -> BigDecimal'
11
- type :+, '(Complex) -> Complex'
12
- pre(:+) { |x| if x.real.is_a?(Float) then x.real!=Float::INFINITY && !(x.real.nan?) else true end}
13
-
14
- type :-, '(%integer) -> BigDecimal'
15
- type :-, '(Float x {{ !x.infinite? && !x.nan? }}) -> BigDecimal'
16
- type :-, '(Rational) -> BigDecimal'
17
- type :-, '(BigDecimal) -> BigDecimal'
18
- type :-, '(Complex) -> Complex'
19
- pre(:-) { |x| if x.real.is_a?(Float) then x.real!=Float::INFINITY && !(x.real.nan?) else true end}
20
-
21
- type :-, '() -> BigDecimal'
22
-
23
- type :*, '(%integer) -> BigDecimal'
24
- type :*, '(Float x {{ !x.infinite? && !x.nan? }}) -> BigDecimal'
25
- type :*, '(Rational) -> BigDecimal'
26
- type :*, '(BigDecimal) -> BigDecimal'
27
- type :*, '(Complex) -> Complex'
28
- pre(:*) { |x| if x.real.is_a?(Float) then (x.real!=Float::INFINITY && !(x.real.nan?)) elsif(x.imaginary.is_a?(Float)) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end}
29
-
30
- type :**, '(%integer) -> BigDecimal'
31
- type :**, '(Float) -> BigDecimal'
32
- pre(:**) { |x| x!=Float::INFINITY && !x.nan? && if(self<0) then x<=-1||x>=0 else true end}
33
- type :**, '(Rational) -> BigDecimal'
34
- pre(:**) { |x| if(self<0) then x<=-1||x>=0 else true end}
35
- type :**, '(BigDecimal) -> BigDecimal'
36
- pre(:**) { |x| x!=BigDecimal::INFINITY && if(self<0) then x<=-1||x>=0 else true end}
37
-
38
- type :/, '(%integer x {{ x!=0 }}) -> BigDecimal'
39
- type :/, '(Float x {{ x!=0 && !x.infinite? && !x.nan? }}) -> BigDecimal'
40
- type :/, '(Rational x {{ x!=0 }}) -> BigDecimal'
41
- type :/, '(BigDecimal x {{ x!=0 }}) -> BigDecimal'
42
- type :/, '(Complex x {{ x!=0 }}) -> Complex'
43
- pre(:/) { |x| if x.real.is_a?(Float) then x.real!=Float::INFINITY && !(x.real.nan?) else true end && if x.imaginary.is_a?(Float) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end && if (x.real.is_a?(Rational)) then !x.imaginary.nan? else true end}
44
-
45
- type :<, '(%integer) -> %bool'
46
- type :<, '(Float x {{ !x.nan? && !x.infinite? }}) -> %bool'
47
- type :<, '(Rational) -> %bool'
48
- type :<, '(BigDecimal) -> %bool'
49
-
50
- type :<=, '(%integer) -> %bool'
51
- type :<=, '(Float x {{ !x.nan? && !x.infinite }}) -> %bool'
52
- type :<=, '(Rational) -> %bool'
53
- type :<=, '(BigDecimal) -> %bool'
54
-
55
- type :>, '(%integer) -> %bool'
56
- type :>, '(Float x {{ !x.nan? && !x.infinite? }}) -> %bool'
57
- type :>, '(Rational) -> %bool'
58
- type :>, '(BigDecimal) -> %bool'
59
-
60
- type :>=, '(%integer) -> %bool'
61
- type :>=, '(Float x {{ !x.nan? && !x.infinite? }}) -> %bool'
62
- type :>=, '(Rational) -> %bool'
63
- type :>=, '(BigDecimal) -> %bool'
64
-
65
- type :==, '(Object) -> %bool'
66
- pre(:==) { |x| if (x.is_a?(Float)) then (!x.nan? && x!=Float::INFINITY) else true end}
67
-
68
- type :===, '(Object) -> %bool'
69
- pre(:===) { |x| if (x.is_a?(Float)) then (!x.nan? && x!=Float::INFINITY) else true end}
70
-
71
- type :<=>, '(%integer) -> Object'
72
- post(:<=>) { |r,x| r == -1 || r==0 || r==1}
73
- type :<=>, '(Float) -> Object'
74
- pre(:<=>) { |x| !x.nan? && x!=Float::INFINITY}
75
- post(:<=>) { |r,x| r == -1 || r==0 || r==1}
76
- type :<=>, '(Rational) -> Object'
77
- post(:<=>) { |r,x| r == -1 || r==0 || r==1}
78
- type :<=>, '(BigDecimal) -> Object'
79
- post(:<=>) { |r,x| r == -1 || r==0 || r==1}
80
-
81
- type :abs, '() -> BigDecimal r {{ r>=0 }}'
82
-
83
- type :abs2, '() -> BigDecimal r {{ r>=0 }}'
84
-
85
- type :angle, '() -> %numeric'
86
- post(:angle) { |r,x| r == 0 || r == Math::PI}
87
-
88
- type :arg, '() -> %numeric'
89
- post(:arg) { |r,x| r == 0 || r == Math::PI}
90
-
91
- type :ceil, '() -> %integer'
92
- pre(:ceil) { !self.ininite? && !self.nan?}
93
-
94
- type :conj, '() -> BigDecimal'
95
- type :conjugate, '() -> BigDecimal'
96
-
97
- type :denominator, '() -> %integer'
98
- pre(:denominator) { !self.ininite? && !self.nan?}
99
- post(:denominator) { |r,x| r>0}
100
-
101
- type :div, '(Fixnum x {{ x!=0 && !self.infinite? && !self.nan? }}) -> %integer'
102
- type :div, '(Bignum x {{ x!=0 && !self.infinite? && !self.nan? }}) -> %integer'
103
- type :div, '(Float x {{ x!=0 && !self.infinite? && !self.nan? && !x.infinite? && !x.nan? }}) -> %integer'
104
- type :div, '(Rational x {{ x!=0 && !self.infinite? && !self.nan? }}) -> %integer'
105
- type :div, '(BigDecimal x {{ x!=0 && !self.infinite? && !self.nan? && !x.infinite? && !x.nan? }}) -> %integer'
106
-
107
- type :divmod, '(%real) -> [%real, %real]'
108
- pre(:divmod) { |x| x!=0 && if x.is_a?(Float) then !x.nan? && x!=Float::INFINITY else true end}
109
-
110
- type :equal?, '(Object) -> %bool'
111
- type :eql?, '(Object) -> %bool'
112
-
113
- type :fdiv, '(%integer) -> Float'
114
- type :fdiv, '(Float) -> Float'
115
- type :fdiv, '(Rational) -> Float'
116
- type :fdiv, '(BigDecimal) -> BigDecimal'
117
- type :fdiv, '(Complex) -> Complex'
118
- pre(:fdiv) { |x| x!=0 && if (x.real.is_a?(BigDecimal)||x.imaginary.is_a?(BigDecimal)) then (if x.real.is_a?(Float) then (x.real!=Float::INFINITY && !(x.real.nan?)) elsif(x.imaginary.is_a?(Float)) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end) else true end && if (x.real.is_a?(Rational) && x.imaginary.is_a?(Float)) then !x.imaginary.nan? else true end}
119
-
120
- type :finite?, '() -> %bool'
121
-
122
- type :floor, '() -> %integer'
123
- pre(:floor) { !self.infinite? && !self.nan?}
124
-
125
- type :hash, '() -> %integer'
126
-
127
- type :imag, '() -> Fixnum r {{ r==0 }}'
128
- type :imaginary, '() -> Fixnum r {{ r==0 }}'
129
-
130
- type :infinite?, '() -> %bool'
131
-
132
- type :to_s, '() -> String'
133
- type :inspect, '() -> String'
134
-
135
- type :magnitude, '() -> BigDecimal r {{ r>=0 }}'
136
-
137
- type :modulo, '(%numeric) -> BigDecimal'
138
- pre(:modulo) { |x| x!=0&&(if x.is_a?(Float) then x!=Float::INFINITY && !x.nan? else true end)}
139
-
140
- type :nan?, '() -> %bool'
141
-
142
- type :numerator, '() -> %integer'
143
- pre(:numerator) { !self.infinite? && !self.nan?}
144
-
145
- type :phase, '() -> %numeric'
146
-
147
- type :quo, '(%integer x {{ x!=0 }}) -> BigDecimal'
148
- type :quo, '(Float x {{ x!=0 && !x.infinite? && !x.nan?}}) -> BigDecimal'
149
- type :quo, '(Rational x {{ x!=0 }}) -> BigDecimal'
150
- type :quo, '(BigDecimal x {{ x!=0 }}) -> BigDecimal'
151
- type :quo, '(Complex) -> Complex'
152
- pre(:quo) { |x| x!=0 && if x.real.is_a?(Float) then x.real!=Float::INFINITY && !(x.real.nan?) else true end && if x.imaginary.is_a?(Float) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end && if (x.real.is_a?(Rational)) then !x.imaginary.nan? else true end}
153
-
154
- type :real, '() -> BigDecimal'
155
-
156
- type :real?, '() -> true'
157
-
158
- type :round, '() -> %integer'
159
- pre(:round) { !self.infinite? && !self.nan?}
160
-
161
- type :round, '(Fixnum) -> BigDecimal' #Also, x must be in range [-2**31, 2**31].
162
-
163
- type :to_f, '() -> Float'
164
- pre(:to_f) { self<=Float::MAX}
165
-
166
- type :to_i, '() -> %integer'
167
- pre(:to_i) { !self.infinite? && !self.nan?}
168
- type :to_int, '() -> %integer'
169
- pre(:to_int) { !self.infinite? && !self.nan?}
170
-
171
- type :to_r, '() -> Rational'
172
- pre(:to_r) { !self.infinite? && !self.nan?}
173
-
174
- type :to_c, '() -> Complex r {{ r.imaginary == 0 }}'
175
- post(:to_c) { |r,x| r.imaginary == 0 }
176
-
177
- type :truncate, '() -> %integer'
178
-
179
- type :truncate, '(Fixnum) -> Rational' #Also, x must be in range [-2**31, 2**31].
180
-
181
- type :zero?, '() -> %bool'
182
-
183
- type :precs, '() -> [%integer, %integer]'
184
-
185
- type :split, '() -> [Fixnum, String, %integer, %integer]'
186
-
187
- type :remainder, '(%real) -> BigDecimal'
188
- pre(:remainder) { |x| if x.is_a?(Float) then !x.infinite? && !x.nan? else true end}
189
-
190
- type :fix, '() -> BigDecimal'
191
-
192
- type :frac, '() -> BigDecimal'
193
-
194
- type :power, '(%integer) -> BigDecimal'
195
- type :power, '(Float) -> BigDecimal'
196
- pre(:power) { |x| x!=Float::INFINITY && !x.nan? && if(self<0) then x<=-1||x>=0 else true end}
197
- type :power, '(Rational) -> BigDecimal'
198
- pre(:power) { |x| if(self<0) then x<=-1||x>=0 else true end}
199
- type :power, '(BigDecimal) -> BigDecimal'
200
- pre(:power) { |x| x!=BigDecimal::INFINITY && if(self<0) then x<=-1||x>=0 else true end}
201
-
202
- type :nonzero?, '() -> Object'
203
-
204
- type :exponent, '() -> %integer'
205
-
206
- type :sign, '() -> Fixnum'
207
-
208
- type :_dump, '() -> String'
209
-
210
- type :sqrt, '(Fixnum) -> BigDecimal'
211
- pre(:sqrt) { self>=0}
212
-
213
- type :add, '(%real, Fixnum) -> BigDecimal'
214
- pre(:add) { |x,y| if x.is_a?(Float) then !x.infinite? && !x.nan? else true end}
215
-
216
- type :sub, '(%real, Fixnum) -> BigDecimal'
217
- pre(:sub) { |x,y| if x.is_a?(Float) then !x.infinite? && !x.nan? else true end}
218
-
219
- type :mult, '(%real, Fixnum) -> BigDecimal'
220
- pre(:mult) { |x,y| if x.is_a?(Float) then !x.infinite? && !x.nan? else true end}
221
-
222
- type :coerce, '(%real) -> [BigDecimal, BigDecimal]'
223
- pre(:coerce) { |x| if x.is_a?(Float) then !x.nan? && !x.finite? else true end}
224
- end