rdl 2.0.1 → 2.1.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.
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,17 +0,0 @@
1
- require_relative 'range.rb'
2
-
3
- class Random
4
- rdl_nowrap
5
-
6
- type 'self.new', '(?Integer seed) -> Random' # Floats can be passed also, but just truncated to int?
7
- type 'self.new_seed', '() -> Integer'
8
- type 'self.rand', '(?Integer max) -> Numeric'
9
- type 'self.srand', '(?Integer number) -> Numeric old_seed'
10
-
11
- type :==, '(%any) -> %bool'
12
- type :bytes, '(Fixnum size) -> String'
13
- type :rand, '(?(Integer or Range<Integer>) max) -> Integer'
14
- type :rand, '(?(Float or Range<Float>) max) -> Float'
15
- pre(:rand) { |max| max > 0 }
16
- type :seed, '() -> Integer'
17
- end
@@ -1,39 +0,0 @@
1
- class Range
2
- rdl_nowrap
3
-
4
- # Range is immutable, so covariant
5
- type_params([:t], nil, variance: [:+]) { |t| t.member?(self.begin) && t.member?(self.end) } # TODO: And instantiated if t instantiated
6
-
7
- # TODO: Parse error
8
- # type 'self.new', '(begin: [<=> : (u, u) -> Fixnum], end: [<=>, (u, u) -> Fixnum], exclude_end: ?%bool) -> Range<u>'
9
- type :==, '(%any obj) -> %bool'
10
- type :===, '(%any obj) -> %bool'
11
- type :begin, '() -> t'
12
- type :bsearch, '() { (t) -> %bool } -> u or nil'
13
- type :cover?, '(%any obj) -> %bool'
14
- type :each, '() { (t) -> %any } -> self'
15
- type :each, '() -> Enumerator<t>'
16
- type :end, '() -> t'
17
- rdl_alias :eql?, :==
18
- type :exclude_end?, '() -> %bool'
19
- type :first, '() -> t'
20
- type :first, '(Fixnum n) -> Array<t>'
21
- type :hash, '() -> Fixnum'
22
- type :include?, '(%any obj) -> %bool'
23
- type :inspect, '() -> String'
24
- type :last, '() -> t'
25
- type :last, '(Fixnum n) -> Array<t>'
26
- type :max, '() -> t'
27
- type :max, '() { (t, t) -> Fixnum } -> t'
28
- type :max, '(Fixnum n) -> Array<t>'
29
- type :max, '(Fixnum n) { (t, t) -> Fixnum } -> Array<t>'
30
- rdl_alias :member?, :include
31
- type :min, '() -> t'
32
- type :min, '() { (t, t) -> Fixnum } -> t'
33
- type :min, '(Fixnum n) -> Array<t>'
34
- type :min, '(Fixnum n) { (t, t) -> Fixnum } -> Array<t>'
35
- type :size, '() -> Fixnum or nil'
36
- type :step, '(?Fixnum n) { (t) -> %any } -> self'
37
- type :step, '(?Fixnum n) -> Enumerator<t>'
38
- type :to_s, '() -> String'
39
- end
@@ -1,209 +0,0 @@
1
- class Rational < Numeric
2
- rdl_nowrap
3
-
4
- type :%, '(%integer) -> Rational'
5
- pre(:%) { |x| x!=0}
6
- type :%, '(Float) -> Float'
7
- pre(:%) { |x| x!=0&&!x.nan?}
8
- type :%, '(Rational) -> Rational'
9
- pre(:%) { |x| x!=0}
10
- type :%, '(BigDecimal) -> BigDecimal'
11
- pre(:%) { |x| x!=0&&!x.nan?}
12
-
13
- type :*, '(%integer) -> Rational'
14
- type :*, '(Float) -> Float'
15
- type :*, '(Rational) -> Rational'
16
- type :*, '(BigDecimal) -> BigDecimal'
17
- type :*, '(Complex) -> Complex'
18
- pre(:*) { |x| 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} #can't have a complex with part BigDecimal, other part infinity/NAN
19
-
20
- type :+, '(%integer) -> Rational'
21
- type :+, '(Float) -> Float'
22
- type :+, '(Rational) -> Rational'
23
- type :+, '(BigDecimal) -> BigDecimal'
24
- type :+, '(Complex) -> Complex'
25
-
26
- type :-, '(%integer) -> Rational'
27
- type :-, '(Float) -> Float'
28
- type :-, '(Rational) -> Rational'
29
- type :-, '(BigDecimal) -> BigDecimal'
30
- type :-, '(Complex) -> Complex'
31
-
32
- type :-, '() -> Rational'
33
-
34
- type :**, '(%integer) -> %numeric'
35
- type :**, '(Float) -> %numeric'
36
- type :**, '(Rational) -> %numeric'
37
- type :**, '(BigDecimal) -> BigDecimal'
38
- pre(:**) { |x| x!=BigDecimal::INFINITY && if self<0 then x<=-1||x>=0 else true end}
39
- post(:**) { |r,x| r.real?}
40
- type :**, '(Complex) -> Complex'
41
- pre(:**) { |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}
42
-
43
- type :/, '(%integer) -> Rational'
44
- pre(:/) { |x| x!=0}
45
- type :/, '(Float) -> Float'
46
- pre(:/) { |x| x!=0}
47
- type :/, '(Rational) -> Rational'
48
- pre(:/) { |x| x!=0}
49
- type :/, '(BigDecimal) -> BigDecimal'
50
- pre(:/) { |x| x!=0}
51
- type :/, '(Complex) -> Complex'
52
- pre(:/) { |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}
53
-
54
- type :<, '(%integer) -> %bool'
55
- type :<, '(Float) -> %bool'
56
- pre(:<) { |x| !x.nan?}
57
- type :<, '(Rational) -> %bool'
58
- type :<, '(BigDecimal) -> %bool'
59
- pre(:<) { |x| !x.nan?}
60
-
61
- type :<=, '(%integer) -> %bool'
62
- type :<=, '(Float) -> %bool'
63
- pre(:<=) { |x| !x.nan?}
64
- type :<=, '(Rational) -> %bool'
65
- type :<=, '(BigDecimal) -> %bool'
66
- pre(:<=) { |x| !x.nan?}
67
-
68
- type :>, '(%integer) -> %bool'
69
- type :>, '(Float) -> %bool'
70
- pre(:>) { |x| !x.nan?}
71
- type :>, '(Rational) -> %bool'
72
- type :>, '(BigDecimal) -> %bool'
73
- pre(:>) { |x| !x.nan?}
74
-
75
- type :>=, '(%integer) -> %bool'
76
- type :>=, '(Float) -> %bool'
77
- pre(:>=) { |x| !x.nan?}
78
- type :>=, '(Rational) -> %bool'
79
- type :>=, '(BigDecimal) -> %bool'
80
- pre(:>=) { |x| !x.nan?}
81
-
82
- type :<=>, '(%integer) -> Object'
83
- post(:<=>) { |r,x| r == -1 || r==0 || r==1}
84
- type :<=>, '(Float) -> Object'
85
- post(:<=>) { |r,x| r == -1 || r==0 || r==1}
86
- type :<=>, '(Rational) -> Object'
87
- post(:<=>) { |r,x| r == -1 || r==0 || r==1}
88
- type :<=>, '(BigDecimal) -> Object'
89
- post(:<=>) { |r,x| r == -1 || r==0 || r==1}
90
-
91
- type :==, '(Object) -> %bool'
92
-
93
- type :abs, '() -> Rational'
94
- post(:abs) { |r,x| r >= 0 }
95
-
96
- type :abs2, '() -> Rational'
97
- post(:abs2) { |r,x| r >= 0 }
98
-
99
- type :angle, '() -> %numeric'
100
- post(:angle) { |r,x| r == 0 || r == Math::PI}
101
-
102
- type :arg, '() -> %numeric'
103
- post(:arg) { |r,x| r == 0 || r == Math::PI}
104
-
105
- type :div, '(Fixnum) -> %integer'
106
- pre(:div) { |x| x!=0}
107
- type :div, '(Bignum) -> %integer'
108
- pre(:div) { |x| x!=0}
109
- type :div, '(Float) -> %integer'
110
- pre(:div) { |x| x!=0 && !x.nan?}
111
- type :div, '(Rational) -> %integer'
112
- pre(:div) { |x| x!=0}
113
- type :div, '(BigDecimal) -> %integer'
114
- pre(:div) { |x| x!=0 && !x.nan?}
115
-
116
- type :modulo, '(%integer) -> Rational'
117
- pre(:modulo) { |x| x!=0}
118
- type :modulo, '(Float) -> Float'
119
- pre(:modulo) { |x| x!=0&&!x.nan?}
120
- type :modulo, '(Rational) -> Rational'
121
- pre(:modulo) { |x| x!=0}
122
- type :modulo, '(BigDecimal) -> BigDecimal'
123
- pre(:modulo) { |x| x!=0&&!x.nan?}
124
-
125
- type :ceil, '() -> %integer'
126
- type :ceil, '(%integer) -> %numeric'
127
-
128
- type :denominator, '() -> %integer'
129
- post(:denominator) { |r,x| r > 0 }
130
-
131
- type :divmod, '(%real) -> [%real, %real]'
132
- pre(:divmod) { |x| x!=0 && if x.is_a?(BigDecimal) then !x.nan? else true end}
133
-
134
- type :equal?, '(Object) -> %bool'
135
-
136
- type :fdiv, '(%integer) -> Float'
137
- type :fdiv, '(Float) -> Float'
138
- type :fdiv, '(Rational) -> Float'
139
- type :fdiv, '(BigDecimal) -> Float'
140
- type :fdiv, '(Complex) -> Float'
141
- pre(:fdiv) { |x| x.imaginary==0 && x.real.class != Float}
142
-
143
- type :floor, '() -> %integer'
144
-
145
- type :floor, '(%integer) -> %numeric'
146
-
147
- type :hash, '() -> %integer'
148
-
149
- type :inspect, '() -> String'
150
-
151
- type :numerator, '() -> %integer'
152
-
153
- type :phase, '() -> %numeric'
154
-
155
- type :quo, '(%integer) -> Rational'
156
- pre(:quo) { |x| x!=0}
157
- type :quo, '(Float) -> Float'
158
- pre(:quo) { |x| x!=0}
159
- type :quo, '(Rational) -> Rational'
160
- pre(:quo) { |x| x!=0}
161
- type :quo, '(BigDecimal) -> BigDecimal'
162
- pre(:quo) { |x| x!=0}
163
- type :quo, '(Complex) -> Complex'
164
- pre(:quo) { |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}
165
-
166
- type :rationalize, '() -> Rational'
167
-
168
- type :rationalize, '(%numeric) -> Rational'
169
- pre(:quo) { |x| if x.is_a?(Float) then x!=Float::INFINITY && !x.nan? else true end}
170
-
171
- type :round, '() -> %integer'
172
-
173
- type :round, '(%integer) -> %numeric'
174
-
175
- type :to_f, '() -> Float'
176
- pre(:to_f) { self<=Float::MAX}
177
-
178
- type :to_i, '() -> %integer'
179
-
180
- type :to_r, '() -> Rational'
181
-
182
- type :to_s, '() -> String'
183
-
184
- type :truncate, '() -> %integer'
185
-
186
- type :truncate, '(%integer) -> Rational'
187
-
188
- type :zero?, '() -> %bool'
189
-
190
- type :conj, '() -> Rational'
191
- type :conjugate, '() -> Rational'
192
-
193
- type :imag, '() -> Fixnum'
194
- post(:imag) { |r,x| r == 0 }
195
- type :imaginary, '() -> Fixnum'
196
- post(:imaginary) { |r,x| r == 0 }
197
-
198
- type :real, '() -> Rational'
199
-
200
- type :real?, '() -> true'
201
-
202
- type :to_c, '() -> Complex'
203
- post(:to_c) { |r,x| r.imaginary == 0 }
204
-
205
- type :coerce, '(%integer) -> [Rational, Rational]'
206
- type :coerce, '(Float) -> [Float, Float]'
207
- type :coerce, '(Rational) -> [Rational, Rational]'
208
- type :coerce, '(Complex) -> [%numeric, %numeric]'
209
- end
@@ -1,30 +0,0 @@
1
- class Regexp
2
- rdl_nowrap
3
-
4
- type 'self.escape', '(String or Symbol) -> String'
5
- type 'self.last_match', '() -> MatchData', wrap: false # Can't wrap or messes up MatchData
6
- type 'self.last_match', '(Fixnum) -> String', wrap: false
7
- type 'self.new', '(String, ?%any options, ?String kcode) -> Regexp'
8
- type 'self.new', '(Regexp) -> Regexp'
9
- rdl_alias 'self.compile', 'self.new'
10
- rdl_alias 'self.quote', 'self.escape'
11
- type 'self.try_convert', '(%any obj) -> Regexp or nil'
12
- type 'self.union', '(*(Regexp or String) pats) -> Regexp'
13
- type 'self.union', '(Array<Regexp or String> pats) -> Regexp'
14
- type :==, '(%any other) -> %bool'
15
- type :===, '(%any other) -> %bool', wrap: false # Can't wrap this of it messes with $1, $2, etc as well!
16
- type :=~, '(String str) -> Fixnum or nil', wrap: false # Can't wrap this or it will mess with $1, $2, etc
17
- type :casefold?, '() -> %bool'
18
- type :encoding, '() -> Encoding'
19
- rdl_alias :eql?, :==
20
- type :fixed_encoding?, '() -> %bool'
21
- type :hash, '() -> Fixnum'
22
- type :inspect, '() -> String'
23
- type :match, '(String, ?Fixnum) -> MatchData or nil'
24
- type :named_captures, '() -> Hash<String, Array<Fixnum>>'
25
- type :names, '() -> Array<String>'
26
- type :options, '() -> Fixnum'
27
- type :source, '() -> String'
28
- type :to_s, '() -> String'
29
- type :~, '() -> Fixnum or nil'
30
- end
@@ -1,58 +0,0 @@
1
- class Set
2
- rdl_nowrap
3
-
4
- type_params [:t], :all?
5
-
6
- type 'self.[]', '(*u) -> Set<u>'
7
- type 'self.new', '(?Enumerable<u> enum) -> Set<u>'
8
-
9
- rdl_alias :&, :intersection
10
- type :+, '(Enumerable<t> enum) -> Set<t>'
11
- rdl_alias :-, :difference
12
- rdl_alias :<, :proper_subset?
13
- rdl_alias :<<, :add
14
- rdl_alias :<=, :subset?
15
- rdl_alias :>, :proper_superset?
16
- rdl_alias :>=, :superset?
17
- type :^, '(Enumerable<t> enum) -> Set<t>'
18
- type :add, '(t o) -> self'
19
- type :add?, '(t o) -> self or nil'
20
- type :classify, '() { (u) -> t } -> Hash<u, Set<t>>'
21
- type :clear, '() -> self'
22
- rdl_alias :collect!, :map
23
- type :delete, '(t o) -> self'
24
- type :delete?, '(t o) -> self or nil'
25
- type :delete_if, '() { (t) -> %bool } -> self'
26
- type :difference, '(Enumerable<t> enum) -> Set<t>'
27
- type :disjoint?, '(Set<t> set) -> %bool'
28
- #?? type :divide, '() { BLOCK }'
29
- type :each, '() { (t) -> %any } -> self'
30
- type :each, '() -> Enumerator<t>'
31
- type :empty?, '() -> %bool'
32
- type :flatten!, '() -> self or nil'
33
- post(:flatten!) { |r| (not r) || (r.none? { |x| x.is_a?(Set) }) }
34
- type :flatten, '() -> Set'
35
- post(:flatten) { |r| r.none? { |x| x.is_a?(Set) } }
36
- # type :flatten_merge, '(set : XXXX, seen : ?XXXX)' #??
37
- rdl_alias :include?, :member?
38
- type :intersect?, '(Set<t> set) -> %bool'
39
- type :intersection, '(Enumerable<t> enum) -> Set<t>'
40
- type :keep_if, '() { (t) -> %bool } -> self'
41
- rdl_alias :length, :size
42
- type :map!, '() { (t) -> u } -> Set<u>' # !! Fix, actually changes type!
43
- type :member?, '(t o) -> %bool'
44
- type :merge, '(Enumerable<t> enum) -> self'
45
- type :proper_subset?, '(Set<t> set) -> %bool'
46
- type :proper_superset?, '(Set<t> set) -> %bool'
47
- type :reject!, '() { (t) -> %bool } -> self or nil'
48
- type :replace, '(Enumerable<u> enum) -> Set<u>' # !! Fix, actually changes type!
49
- type :select!, '() { (t) -> %bool } -> self or nil'
50
- type :size, '() -> Fixnum'
51
- type :subset?, '(Set<t> set) -> %bool'
52
- type :subtract, '(Enumerable<t> enum) -> self'
53
- type :superset?, '(Set<t> set) -> %bool'
54
- type :to_a, '() -> Array<t>'
55
- # type :to_set, '(klass: ?Class, args : *XXXX) { BLOCK }' # ??
56
- rdl_alias :|, :+
57
- rdl_alias :union, :+
58
- end
@@ -1,143 +0,0 @@
1
- class String
2
- rdl_nowrap
3
-
4
- type :new, '(?String str) -> String new_str'
5
- type :try_convert, '(Object obj) -> String or nil new_string'
6
- type :%, '(Object) -> String'
7
- type :*, '(Fixnum) -> String'
8
- type :+, '(String) -> String'
9
- type :<<, '(Object) -> String'
10
- type :<=>, '(String other) -> Fixnum or nil ret'
11
- type :==, '(%any) -> %bool'
12
- type :===, '(%any) -> %bool'
13
- type :=~, '(Object) -> Fixnum or nil', wrap: false # Wrapping this messes up $1 etc
14
- type :[], '(Fixnum, ?Fixnum) -> String or nil'
15
- type :[], '(Range<Fixnum> or Regexp) -> String or nil'
16
- type :[], '(Regexp, Fixnum) -> String or nil'
17
- type :[], '(Regexp, String) -> String or nil'
18
- type :[], '(String) -> String or nil'
19
- type :ascii_only?, '() -> %bool'
20
- type :b, '() -> String'
21
- type :bytes, '() -> Array' # TODO: bindings to parameterized (vars)
22
- type :bytesize, '() -> Fixnum'
23
- type :byteslice, '(Fixnum, ?Fixnum) -> String or nil'
24
- type :byteslice, '(Range<Fixnum>) -> String or nil'
25
- type :capitalize, '() -> String'
26
- type :capitalize!, '() -> String or nil'
27
- type :casecmp, '(String) -> nil or Fixnum'
28
- type :center, '(Fixnum, ?String) -> String'
29
- type :chars, '() -> Array' #deprecated
30
- type :chomp, '(?String) -> String'
31
- type :chomp!, '(?String) -> String or nil'
32
- type :chop, '() -> String'
33
- type :chop!, '() -> String or nil'
34
- type :chr, '() -> String'
35
- type :clear, '() -> String'
36
- type :codepoints, '() -> Array<Fixnum>' # TODO
37
- type :codepoints, '() {(?%any) -> %any} -> Array<Fixnum>' # TODO
38
- type :concat, '(Fixnum or Object) -> String'
39
- type :count, '(String, *String) -> Fixnum'
40
- type :crypt, '(String) -> String'
41
- type :delete, '(String, *String) -> String'
42
- type :delete!, '(String, *String) -> String or nil'
43
- type :downcase, '() -> String'
44
- type :downcase!, '() -> String or nil'
45
- type :dump, '() -> String'
46
- type :each_byte, '() {(Fixnum) -> %any} -> String'
47
- type :each_byte, '() -> Enumerator'
48
- type :each_char, '() {(String) -> %any} -> String'
49
- type :each_char, '() -> Enumerator'
50
- type :each_codepoint, '() {(Fixnum) -> %any} -> String'
51
- type :each_codepoint, '() -> Enumerator'
52
- type :each_line, '(?String) {(Fixnum) -> %any} -> String'
53
- type :each_line, '(?String) -> Enumerator'
54
- type :empty?, '() -> %bool'
55
- # type :encode, '(?Encoding, ?Encoding, *Symbol) -> String' # TODO: fix Hash arg
56
- # type :encode!, '(Encoding, ?Encoding, *Symbol) -> String'
57
- type :encoding, '() -> Encoding'
58
- type :end_with?, '(*String) -> %bool'
59
- type :eql?, '(String) -> %bool'
60
- type :force_encoding, '(String or Encoding) -> String'
61
- type :getbyte, '(Fixnum) -> Fixnum or nil'
62
- type :gsub, '(Regexp or String, String) -> String', wrap: false # Can't wrap these, since they mess with $1 etc
63
- type :gsub, '(Regexp or String, Hash) -> String', wrap: false
64
- type :gsub, '(Regexp or String) {(String) -> %any } -> String', wrap: false
65
- type :gsub, '(Regexp or String) -> Enumerator', wrap: false
66
- type :gsub, '(Regexp or String) -> String', wrap: false
67
- type :gsub!, '(Regexp or String, String) -> String or nil', wrap: false
68
- type :gsub!, '(Regexp or String) {(String) -> %any } -> String or nil', wrap: false
69
- type :gsub!, '(Regexp or String) -> Enumerator', wrap: false
70
- type :hash, '() -> Fixnum'
71
- type :hex, '() -> Fixnum'
72
- type :include?, '(String) -> %bool'
73
- type :index, '(Regexp or String, ?Fixnum) -> Fixnum or nil'
74
- type :replace, '(String) -> String'
75
- type :insert, '(Fixnum, String) -> String'
76
- type :inspect, '() -> String'
77
- type :intern, '() -> Symbol'
78
- type :length, '() -> Fixnum'
79
- type :lines, '(?String) -> Array<String>'
80
- type :ljust, '(Fixnum, ?String) -> String' # TODO
81
- type :lstrip, '() -> String'
82
- type :lstrip!, '() -> String or nil'
83
- type :match, '(Regexp or String) -> MatchData'
84
- type :match, '(Regexp or String, Fixnum) -> MatchData'
85
- type :next, '() -> String'
86
- type :next!, '() -> String'
87
- type :oct, '() -> Fixnum'
88
- type :ord, '() -> Fixnum'
89
- type :partition, '(Regexp or String) -> Array<String>'
90
- type :prepend, '(String) -> String'
91
- type :reverse, '() -> String'
92
- type :rindex, '(String or Regexp, ?Fixnum) -> Fixnum or nil' # TODO
93
- type :rjust, '(Fixnum, ?String) -> String' # TODO
94
- type :rpartition, '(String or Regexp) -> Array<String>'
95
- type :rstrip, '() -> String'
96
- type :rstrip!, '() -> String'
97
- type :scan, '(Regexp or String) -> Array<String or Array<String>>', wrap: false # Can't wrap or screws up last_match
98
- type :scan, '(Regexp or String) {(*%any) -> %any} -> Array<String or Array<String>>', wrap: false
99
- type :scrub, '(?String) -> String'
100
- type :scrub, '(?String) {(%any) -> %any} -> String'
101
- type :scrub!, '(?String) -> String'
102
- type :scrub!, '(?String) {(%any) -> %any} -> String'
103
- type :set_byte, '(Fixnum, Fixnum) -> Fixnum'
104
- type :size, '() -> Fixnum'
105
- rdl_alias :slice, :[]
106
- type :slice!, '(Fixnum, ?Fixnum) -> String or nil'
107
- type :slice!, '(Range<Fixnum> or Regexp) -> String or nil'
108
- type :slice!, '(Regexp, Fixnum) -> String or nil'
109
- type :slice!, '(Regexp, String) -> String or nil'
110
- type :slice!, '(String) -> String or nil'
111
- type :split, '(?(Regexp or String), ?Fixnum) -> Array<String>'
112
- type :split, '(?Fixnum) -> Array<String>'
113
- type :squeeze, '(?String) -> String'
114
- type :squeeze!, '(?String) -> String'
115
- type :start_with?, '(* String) -> %bool'
116
- type :strip, '() -> String'
117
- type :strip!, '() -> String'
118
- type :sub, '(Regexp or String, String or Hash) -> String', wrap: false # Can't wrap these, since they mess with $1 etc
119
- type :sub, '(Regexp or String) {(String) -> %any} -> String', wrap: false
120
- type :sub!, '(Regexp or String, String) -> String', wrap: false # TODO: Does this really not allow Hash?
121
- type :sub!, '(Regexp or String) {(String) -> %any} -> String', wrap: false
122
- type :succ, '() -> String'
123
- type :sum, '(?Fixnum) -> Fixnum'
124
- type :swapcase, '() -> String'
125
- type :swapcase!, '() -> String or nil'
126
- type :to_c, '() -> Complex'
127
- type :to_f, '() -> Float'
128
- type :to_i, '(?Fixnum) -> Fixnum'
129
- type :to_r, '() -> Rational'
130
- type :to_s, '() -> String'
131
- type :to_str, '() -> String'
132
- type :to_sym, '() -> Symbol'
133
- type :tr, '(String, String) -> String'
134
- type :tr!, '(String, String) -> String or nil'
135
- type :tr_s, '(String, String) -> String'
136
- type :tr_s!, '(String, String) -> String or nil'
137
- type :unpack, '(String) -> Array<String>'
138
- type :upcase, '() -> String'
139
- type :upcase!, '() -> String or nil'
140
- type :upto, '(String, ?bool) -> Enumerator'
141
- type :upto, '(String, ?bool) {(String) -> %any } -> String'
142
- type :valid_encoding?, '() -> %bool'
143
- end