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,197 +0,0 @@
1
- class Integer < Numeric
2
- rdl_nowrap
3
-
4
- type :%, '(Fixnum x {{ x!=0 }}) -> Fixnum'
5
- type :%, '(Bignum x {{ x!=0 }}) -> %integer'
6
- type :%, '(Float x {{ x!=0 }}) -> Float'
7
- type :%, '(Rational x {{ x!=0 }}) -> Rational'
8
- type :%, '(BigDecimal x {{ x!=0 }}) -> BigDecimal'
9
-
10
- type :&, '(%integer) -> Fixnum'
11
-
12
- type :*, '(%integer) -> %integer'
13
- type :*, '(Float) -> Float'
14
- type :*, '(Rational) -> Rational'
15
- type :*, '(BigDecimal) -> BigDecimal'
16
- type :*, '(Complex) -> Complex'
17
- 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
18
-
19
- type :**, '(%integer) -> %numeric'
20
- type :**, '(Float) -> %numeric'
21
- type :**, '(Rational) -> %numeric'
22
- type :**, '(BigDecimal) -> BigDecimal'
23
- pre(:**) { |x| x!=BigDecimal::INFINITY && if self<0 then x<=-1||x>=0 else true end}
24
- post(:**) { |r,x| r.real?}
25
- type :**, '(Complex) -> Complex'
26
- 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}
27
-
28
- type :+, '(%integer) -> %integer'
29
- type :+, '(Float) -> Float'
30
- type :+, '(Rational) -> Rational'
31
- type :+, '(BigDecimal) -> BigDecimal'
32
- type :+, '(Complex) -> Complex'
33
-
34
- type :-, '(%integer) -> %integer'
35
- type :-, '(Float) -> Float'
36
- type :-, '(Rational) -> Rational'
37
- type :-, '(BigDecimal) -> BigDecimal'
38
- type :-, '(Complex) -> Complex'
39
-
40
- type :-, '() -> %integer'
41
-
42
- type :/, '(%integer x {{ x!=0 }}) -> %integer'
43
- type :/, '(Float x {{ x!=0 }}) -> Float'
44
- type :/, '(Rational x {{ x!=0 }}) -> Rational'
45
- type :/, '(BigDecimal x {{ x!=0 }}) -> BigDecimal'
46
- type :/, '(Complex x {{ x!=0 }}) -> Complex'
47
- 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}
48
-
49
- type :<, '(%integer) -> %bool'
50
- type :<, '(Float) -> %bool'
51
- type :<, '(Rational) -> %bool'
52
- type :<, '(BigDecimal) -> %bool'
53
-
54
- type :<<, '(Fixnum) -> %integer'
55
-
56
- type :<=, '(%integer) -> %bool'
57
- type :<=, '(Float) -> %bool'
58
- type :<=, '(Rational) -> %bool'
59
- type :<=, '(BigDecimal) -> %bool'
60
-
61
- type :<=>, '(%integer) -> Object'
62
- post(:<=>) { |r,x| r == -1 || r == 0 || r == 1 }
63
- type :<=>, '(Float) -> Object'
64
- post(:<=>) { |r,x| r == -1 || r == 0 || r == 1 }
65
- type :<=>, '(Rational) -> Object'
66
- post(:<=>) { |r,x| r == -1 || r == 0 || r == 1 }
67
- type :<=>, '(BigDecimal) -> Object'
68
- post(:<=>) { |r,x| r == -1 || r == 0 || r == 1 }
69
-
70
- type :==, '(Object) -> %bool'
71
-
72
- type :===, '(Object) -> %bool'
73
-
74
- type :>, '(%integer) -> %bool'
75
- type :>, '(Float) -> %bool'
76
- type :>, '(Rational) -> %bool'
77
- type :>, '(BigDecimal) -> %bool'
78
-
79
- type :>=, '(%integer) -> %bool'
80
- type :>=, '(Float) -> %bool'
81
- type :>=, '(Rational) -> %bool'
82
- type :>=, '(BigDecimal) -> %bool'
83
-
84
- type :>>, '(%integer) -> %integer r {{ r >= 0 }}'
85
-
86
- type :[], '(%integer) -> Fixnum'
87
- post(:[]) { |r,x| r == 0 || r==1}
88
- type :[], '(Rational) -> Fixnum'
89
- post(:[]) { |r,x| r == 0 || r==1}
90
- type :[], '(Float) -> Fixnum'
91
- pre(:[]) { |x| x != Float::INFINITY && !x.nan? }
92
- post(:[]) { |r,x| r == 0 || r==1}
93
- type :[], '(BigDecimal) -> Fixnum'
94
- pre(:[]) { |x| x != BigDecimal::INFINITY && !x.nan? }
95
- post(:[]) { |r,x| r == 0 || r == 1 }
96
-
97
- type :^, '(%integer) -> %integer'
98
-
99
- type :|, '(%integer) -> %integer'
100
-
101
- type :~, '() -> %integer'
102
-
103
- type :abs, '() -> %integer r {{ r>=0 }}'
104
-
105
- type :bit_length, '() -> %integer r {{ r>=0 }}'
106
-
107
- type :div, '(%integer x {{ x!=0 }}) -> %integer'
108
- type :div, '(Float x {{ x!=0 && !x.nan? }}) -> %integer'
109
- type :div, '(Rational x {{ x!=0 }}) -> %integer'
110
- type :div, '(BigDecimal x {{ x!=0 && !x.nan? }}) -> %integer'
111
-
112
- type :divmod, '(%real x {{ x!=0 }}) -> [%real, %real]'
113
- pre(:divmod) { |x| if x.is_a?(Float) then !x.nan? else true end}
114
-
115
- type :fdiv, '(%integer) -> Float'
116
- type :fdiv, '(Float) -> Float'
117
- type :fdiv, '(Rational) -> Float'
118
- type :fdiv, '(BigDecimal) -> BigDecimal'
119
- type :fdiv, '(Complex) -> Complex'
120
- pre(:fdiv) { |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 && if (x.real.is_a?(Rational) && x.imaginary.is_a?(Float)) then !x.imaginary.nan? else true end}
121
-
122
- type :to_s, '() -> String'
123
- type :inspect, '() -> String'
124
-
125
- type :magnitude, '() -> %integer r {{ r>=0 }}'
126
-
127
- type :modulo, '(Fixnum x {{ x!=0 }}) -> Fixnum'
128
- type :modulo, '(Bignum x {{ x!=0 }}) -> %integer'
129
- type :modulo, '(Float x {{ x!=0 }}) -> Float'
130
- type :modulo, '(Rational x {{ x!=0 }}) -> Rational'
131
- type :modulo, '(BigDecimal x {{ x!=0 }}) -> BigDecimal'
132
-
133
- type :quo, '(%integer x {{ x!=0 }}) -> Rational'
134
- type :quo, '(Float x {{ x!=0 }}) -> Float'
135
- type :quo, '(Rational x {{ x!=0 }}) -> Rational'
136
- type :quo, '(BigDecimal x {{ x!=0 }}) -> BigDecimal'
137
- type :quo, '(Complex x {{ x!=0 }}) -> Complex'
138
- pre(:quo) { |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 && if (x.real.is_a?(Rational) && x.imaginary.is_a?(Float)) then !x.imaginary.nan? else true end}
139
-
140
- type :abs2, '() -> %integer r {{ r>=0 }}'
141
- type :angle, '() -> %numeric'
142
- post(:angle) { |r,x| r == 0 || r == Math::PI}
143
- type :arg, '() -> %numeric'
144
- post(:arg) { |r,x| r == 0 || r == Math::PI}
145
- type :equal?, '(Object) -> %bool'
146
- type :eql?, '(Object) -> %bool'
147
- type :hash, '() -> %integer'
148
- type :ceil, '() -> %integer'
149
- type :chr, '(Encoding) -> String'
150
- type :coerce, '(%numeric) -> [%real, %real]'
151
- pre(:coerce) { |x| if x.is_a?(Complex) then x.imaginary==0 else true end}
152
- type :conj, '() -> %integer'
153
- type :conjugate, '() -> %integer'
154
- type :denominator, '() -> Fixnum'
155
- post(:denominator) { |r,x| r == 1 }
156
- type :downto, '(%integer) { (%integer) -> %any } -> %integer'
157
- type :downto, '(%integer limit) -> Enumerator<%integer>'
158
- type :even?, '() -> %bool'
159
- type :gcd, '(%integer) -> %integer'
160
- type :gcdlcm, '(%integer) -> [%integer, %integer]'
161
- type :floor, '() -> %integer'
162
- type :imag, '() -> Fixnum r {{ r==0 }}'
163
- type :imaginary, '() -> Fixnum r {{ r==0 }}'
164
- type :integer?, '() -> true'
165
- type :lcm, '(%integer) -> %integer'
166
- type :next, '() -> %integer'
167
- type :numerator, '() -> %integer'
168
- type :odd?, '() -> %bool'
169
- type :ord, '() -> %integer'
170
- type :phase, '() -> %numeric'
171
- type :pred, '() -> %integer'
172
- type :rationalize, '() -> Rational'
173
- type :rationalize, '(%numeric) -> Rational'
174
- type :real, '() -> %integer'
175
- type :real?, '() -> true'
176
- type :remainder, '(Fixnum x {{ x!=0 }}) -> Fixnum r {{ r>=0 }}'
177
- type :remainder, '(Bignum x {{ x!=0 }}) -> Fixnum r {{ r>=0 }}'
178
- type :remainder, '(Float x {{ x!=0 }}) -> Float'
179
- type :remainder, '(Rational x {{ x!=0 }}) -> Rational r {{ r>=0 }}'
180
- type :remainder, '(BigDecimal x {{ x!=0 }}) -> BigDecimal'
181
- type :round, '() -> %integer'
182
- type :round, '(%numeric) -> %numeric'
183
- pre(:round) { |x| x!=0 && if x.is_a?(Complex) then x.imaginary==0 && (if x.real.is_a?(Float)||x.real.is_a?(BigDecimal) then !x.real.infinite? && !x.real.nan? else true end) elsif x.is_a?(Float) then x!=Float::INFINITY && !x.nan? elsif x.is_a?(BigDecimal) then x!=BigDecimal::INFINITY && !x.nan? else true end} #Also, x must be in range [-2**31, 2**31].
184
- type :size, '() -> %integer'
185
- type :succ, '() -> %integer'
186
- type :times, '() { (%integer) -> %any } -> %integer'
187
- type :times, '() -> Enumerator<%integer>'
188
- type :to_c, '() -> Complex r {{ r.imaginary==0 }}'
189
- type :to_f, '() -> Float'
190
- type :to_i, '() -> %integer'
191
- type :to_int, '() -> %integer'
192
- type :to_r, '() -> Rational'
193
- type :truncate, '() -> %integer'
194
- type :upto, '(%integer) { (%integer) -> %any } -> %integer'
195
- type :upto, '(%integer) -> Enumerator<%integer>'
196
- type :zero?, '() -> %bool'
197
- end
@@ -1,103 +0,0 @@
1
- class IO
2
- rdl_nowrap # Do not wrap this class. Leads to mysterious errors.
3
-
4
- type 'self.binread', '(String name, ?Fixnum length, ?Fixnum offset) -> String'
5
- type 'self.binwrite', '(String name, String, ?Fixnum offset, %open_args) -> Fixnum'
6
- type 'self.copy_stream', '(String or IO src, String or IO dst, ?Fixnum copy_length, ?Fixnum src_offset) -> Fixnum'
7
- rdl_alias 'self.for_fd', 'self.new'
8
- type 'self.foreach', '(String name, ?String sep, ?Fixnum limit, %open_args) { (String) -> %any } -> nil'
9
- type 'self.foreach', '(String name, ?String sep, ?Fixnum limit, %open_args) -> Enumerator<String>'
10
- type 'self.new', '(Fixnum fd, ?Fixnum mode, ?Fixnum opt) -> IO'
11
- type 'self.open', '(Fixnum fd, ?String mode, %open_args) -> IO'
12
- type 'self.open', '(Fixnum fd, ?String mode, %open_args) { (IO) -> t } -> t'
13
- type 'self.pipe', '(?String ext_or_ext_int_enc, %open_args) -> [IO, IO]'
14
- type 'self.pipe', '(?String ext_enc, ?String int_enc, %open_args) -> [IO, IO]'
15
- type 'self.pipe', '(?String ext_or_ext_int_enc, %open_args) { ([IO, IO]) -> t } -> t'
16
- type 'self.pipe', '(?String ext_enc, ?String int_enc, %open_args) { ([IO, IO]) -> t } -> t'
17
- type 'self.popen', '(?Hash<String, String> env, String cmd, ?String mode, %open_args) -> IO'
18
- type 'self.popen', '(?Hash<String, String> env, String cmd, ?String mode, %open_args) { (IO) -> t } -> t'
19
- type 'self.read', '(String name, ?Fixnum length, ?Fixnum offset, %open_args) -> String'
20
- type 'self.readlines', '(String name, ?String sep, ?Fixnum limit, %open_args) -> Array<String>'
21
- type 'self.select', '(Array<IO> read_array, ?Array<IO> write_array, ?Array<IO> error_array, ?Fixnum timeout) -> Array<IO> or nil'
22
- type 'self.sysopen', '(String path, ?String mode, ?String perm) -> Fixnum' # TODO unsure of type of perm
23
- type 'self.try_convert', '([to_io: () -> IO]) -> IO or nil'
24
- type 'self.write', '(String name, String, ?Fixnum offset, %open_args) -> Fixnum'
25
- type :<<, '([to_s: () -> String]) -> self'
26
- type :advise, '(:normal or :sequence or :random or :willneed or :dontneed or :noreuse, ?Fixnum offset, ?Fixnum len) -> nil'
27
- type :autoclose=, '(%bool) -> %bool'
28
- type :autoclose?, '() -> %bool'
29
- type :binmode, '() -> self'
30
- type :binmode?, '() -> %bool'
31
- rdl_alias :bytes, :each_byte # deprecated
32
- rdl_alias :chars, :each_char # deprecated
33
- type :close, '() -> nil'
34
- type :close_on_exec=, '(%bool) -> %bool'
35
- type :close_on_exec?, '() -> %bool'
36
- type :close_read, '() -> nil'
37
- type :close_write, '() -> nil'
38
- type :closed?, '() -> %bool'
39
- rdl_alias :codepoints, :each_codepoint # deprecated
40
- type :each, '(?String sep, ?Fixnum limit) { (String) -> %any } -> self'
41
- type :each, '(?String sep, ?Fixnum limit) -> Enumerator<String>'
42
- rdl_alias :each_line, :each
43
- type :each_byte, '() { (Fixnum) -> %any } -> self'
44
- type :each_byte, '() -> Enumerator<Fixnum>'
45
- type :each_char, '() { (String) -> %any } -> self'
46
- type :each_char, '() -> Enumerator<String>'
47
- type :each_codepoint, '() { (Fixnum) -> %any } -> self'
48
- type :each_codepoint, '() -> Enumerator<Fixnum>'
49
- type :eof, '() -> %bool'
50
- rdl_alias :eof?, :eof
51
- type :external_enconding, '() -> Enconding'
52
- type :fcntl, '(Fixnum integer_cmd, String or Fixnum arg) -> Fixnum'
53
- type :fdatasync, '() -> 0 or nil'
54
- type :fileno, '() -> Fixnum'
55
- type :flush, '() -> self'
56
- type :fsync, '() -> 0 or nil'
57
- type :getbyte, '() -> Fixnum or nil'
58
- type :getc, '() -> String or nil'
59
- type :gets, '(?String sep, ?Fixnum limit) -> String or nil'
60
- type :inspect, '() -> String'
61
- type :internal_encoding, '() -> Encoding'
62
- type :ioctl, '(Fixnum integer_cmd, String or Fixnum arg) -> Fixnum'
63
- type :isatty, '() -> %bool'
64
- type :lineno, '() -> Fixnum'
65
- type :lineno=, '(Fixnum) -> Fixnum'
66
- rdl_alias :lines, :each_line # deprecated
67
- type :pid, '() -> Fixnum'
68
- type :pos, '() -> Fixnum'
69
- type :pos=, '(Fixnum) -> Fixnum'
70
- type :print, '(*[to_s: () -> String]) -> nil'
71
- type :printf, '(String format_string, *%any) -> nil'
72
- type :putc, '(Numeric or String) -> %any'
73
- type :puts, '(*[to_s: () -> String]) -> nil'
74
- type :read, '(?Fixnum length, ?String outbuf) -> String or nil'
75
- type :read_nonblock, '(Fixnum maxlen) -> String'
76
- type :read_nonblock, '(Fixnum maxlen, String outbuf) -> String outbuf'
77
- type :readbyte, '() -> Fixnum'
78
- type :readchar, '() -> String'
79
- type :readline, '(?String sep, ?Fixnum limit) -> String'
80
- type :readlines, '(?String sep, ?Fixnum limit) -> Array<String>'
81
- type :readpartial, '(Fixnum maxlen) -> String'
82
- type :readpartial, '(Fixnum maxlen, String outbuf) -> String outbuf'
83
- type :reopen, '(IO other_IO) -> IO'
84
- type :reopen, '(String path, String mode_str) -> IO'
85
- type :rewrind, '() -> 0'
86
- type :seek, '(Fixnum amount, ?Fixnum whence) -> 0'
87
- type :set_encoding, '(?String or Encoding ext_or_ext_int_enc) -> self'
88
- type :set_encoding, '(?String or Encoding ext_enc, ?String or Encoding int_enc) -> self'
89
- type :stat, '() -> File::Stat'
90
- type :sync, '() -> %bool'
91
- type :sync=, '(%bool) -> %bool'
92
- type :sysread, '(Fixnum maxlen, String outbuf) -> String'
93
- type :sysseek, '(Fixnum amount, ?Fixnum whence) -> Fixnum'
94
- type :syswrite, '(String) -> Fixnum'
95
- type :tell, '() -> Fixnum'
96
- rdl_alias :to_i, :fileno
97
- type :to_io, '() -> self'
98
- type :tty?, '() -> %bool'
99
- type :ungetbyte, '(String or Fixnum) -> nil'
100
- type :ungetc, '(String) -> nil'
101
- type :write, '(String) -> Fixnum'
102
- type :write_nonbloc, '(String, ?Fixnum options) -> Fixnum'
103
- end
@@ -1,90 +0,0 @@
1
- module Kernel
2
- rdl_nowrap
3
-
4
- # type 'self.Array', '([to_ary: () -> Array<t>]) -> Array<t>'
5
- # type 'self.Array', '([to_a: () -> Array<t>]) -> Array<t>'
6
- type 'self.Complex', '(Numeric x, Numeric y) -> Complex'
7
- type 'self.Complex', '(String x) -> Complex'
8
- type 'self.Float', '(Numeric x) -> Float'
9
- # type 'self.Float', '(x : [to_f : () -> Float]) -> Float'
10
- # type 'self.Hash', '(x : [to_hash : () -> Hash<k,v>]) -> Hash<k,v>'
11
- type 'self.Hash', '(nil x) -> Hash<k,v>'
12
- # type 'self.Hash, '(x : []) -> Hash<k,v>'
13
- type 'self.Integer', '(Numeric or String arg, ?Fixnum base) -> Integer'
14
- # type 'self.Integer', '(arg : [to_int : () -> Integer], base : ?Fixnum) -> Integer'
15
- # type 'self.Integer', '(arg : [to_i : () -> Integer], base : ?Fixnum) -> Integer'
16
- type 'self.Rational', '(Numeric x, Numeric y) -> Rational'
17
- type 'self.Rational', '(String x) -> Rational'
18
- # type 'self.String', '(arg : [to_s : () -> String]) -> String'
19
- type 'self.__callee__', '() -> Symbol or nil'
20
- type 'self.__dir__', '() -> String or nil'
21
- type 'self.__method__', '() -> Symbol or nil'
22
- type 'self.`', '(String) -> String'
23
- type 'self.abort', '(?String msg) -> %bot'
24
- type 'self.at_exit', '() { () -> %any} -> Proc' # TODO: Fix proc
25
- type 'self.autoload', '(String or Symbol module, String filename) -> nil'
26
- type 'self.autoload?', '(Symbol or String name) -> String or nil'
27
- type 'self.binding', '() -> Binding'
28
- type 'self.block_given?', '() -> %bool'
29
- type 'self.caller', '(?Fixnum start, ?Fixnum length) -> Array<String> or nil'
30
- type 'self.caller', '(Range) -> Array<String> or nil'
31
- type 'self.caller_locations', '(?Fixnum start, ?Fixnum length) -> Array<String> or nil'
32
- type 'self.caller_locations', '(Range) -> Array<String> or nil'
33
- # type 'self.catch' # TODO
34
- type 'self.eval', '(String, ?Binding, ?String filename, ?Fixnum lineno) -> %any'
35
- # type 'self.exec' #TODO
36
- type 'self.exit', '(Fixnum or %bool status) -> %bot'
37
- type 'self.exit!', '(Fixnum or %bool status) -> %bot'
38
- type 'self.fail', '() -> %bot'
39
- type 'self.fail', '(String) -> %bot'
40
- type 'self.fail', '(Class, Array<String>) -> %bot'
41
- type 'self.fail', '(Class, String, Array<String>) -> %bot'
42
- # type 'self.fail', '(String or [exception : () -> String], ?String, ?Array<String>) -> %any'
43
- # type 'self.fork' #TODO
44
- type 'self.format', '(String format, *%any args) -> String'
45
- type 'self.gets', '(?String, ?Fixnum) -> String'
46
- type 'self.global_variables', '() -> Array<Symbol>'
47
- type 'self.iterator?', '() -> %bool'
48
- # type 'self.lambda' # TODO
49
- type 'self.load', '(String filename, ?%bool) -> %bool'
50
- type 'self.local_variables', '() -> Array<Symbol>'
51
- # type 'self.loop' #TODO
52
- type 'self.open', '(String path, ?(String or Fixnum) mode, ?String perm) -> IO or nil'
53
- # type 'self.open', '(String path, mode : ?String, perm: ?String) {(IO) -> %any)} -> %any' # TODO: returns block value
54
- # type 'self.open', '(String path, mode : ?Fixnum, perm: ?String) {(IO) -> %any)} -> %any' # TODO: returns block value
55
- # type 'self.p', '(*[inspect : () -> String]) -> nil'
56
- # type 'self.print', '(*[to_s : () -> String] -> nil'
57
- type 'self.printf', '(?IO, ?String, *%any) -> nil'
58
- type(:proc, "() {(*%any) -> %any} -> Proc") # TODO more precise
59
- type 'self.putc', '(Fixnum) -> Fixnum'
60
- type 'self.puts', '(*[to_s : () -> String]) -> nil'
61
- type 'self.raise', '() -> %bot'
62
- # type 'self.raise', '(String or [exception : () -> String], ?String, ?Array<String>) -> %any'
63
- # TODO: above same as fail?
64
- type 'self.rand', '(Fixnum or Range max) -> Numeric'
65
- type 'self.readline', '(?String, ?Fixnum) -> String'
66
- type 'self.readlines', '(?String, ?Fixnum) -> Array<String>'
67
- type 'self.require', '(String name) -> %bool'
68
- type 'self.require_relative', '(String name) -> %bool'
69
- type 'self.select',
70
- '(Array<IO> read, ?Array<IO> write, ?Array<IO> error, ?Fixnum timeout) -> Array<String>' # TODO: return type?
71
- # type 'self.set_trace_func' #TODO
72
- type 'self.sleep', '(Numeric duration) -> Fixnum'
73
- # type 'self.spawn' #TODO
74
- rdl_alias :sprintf, :format # TODO: are they aliases?
75
- type 'self.srand', '(Numeric number) -> Numeric'
76
- type 'self.syscall', '(Fixnum num, *%any args) -> %any' # TODO : ?
77
- # type 'self.system' # TODO
78
- type 'self.test', '(String cmd, String file1, ?String file2) -> %bool or Time' # TODO: better, dependent type?
79
- # type 'self.throw' # TODO
80
- # type 'self.trace_var' # TODO
81
- # type 'self.trap' # TODO
82
- # type 'self.untrace_var' # TODO
83
- type 'self.warn', '(*String msg) -> nil'
84
- type :clone, '() -> self'
85
- type :raise, '() -> %bot'
86
- type :raise, '(String) -> %bot'
87
- type :raise, '(Class, String, Array<String>) -> %bot'
88
- type :send, '(String or Symbol, *%any) -> %any'
89
- type :send, '(String or Symbol, *%any) { (*%any) -> %any } -> %any'
90
- end
@@ -1,5 +0,0 @@
1
- module Marshal
2
- rdl_nowrap
3
-
4
- type 'self.load', '(String, ?Proc) -> Object'
5
- end
@@ -1,26 +0,0 @@
1
- class MatchData
2
- rdl_nowrap
3
-
4
- type :==, '(%any) -> %bool'
5
- type :[], '(Fixnum i) -> String or nil'
6
- type :[], '(Fixnum start, Fixnum length) -> Array<String>'
7
- type :[], '(Range<Fixnum> range) -> Array<String>'
8
- type :[], '(String or Symbol name) -> String or nil'
9
- type :begin, '(Fixnum n) -> Fixnum'
10
- type :captures, '() -> Array<String>'
11
- type :end, '(Fixnum n) -> Fixnum'
12
- type :eql?, '(%any other) -> %bool'
13
- type :hash, '() -> Fixnum'
14
- type :inspect, '() -> String'
15
- type :length, '() -> Fixnum'
16
- type :names, '() -> Array<String>'
17
- type :offset, '(Fixnum n) -> Array<Fixnum>'
18
- type :post_match, '() -> String'
19
- type :pre_match, '() -> String'
20
- type :regexp, '() -> Regexp'
21
- type :size, '() -> Fixnum'
22
- type :string, '() -> String'
23
- type :to_a, '() -> Array<String>'
24
- type :to_s, '() -> String'
25
- type :values_at, '(*Fixnum indexes) -> Array<String>'
26
- end
@@ -1,53 +0,0 @@
1
- module Math
2
- rdl_nowrap
3
-
4
- type 'self.acos', '(%real x) -> Float'
5
- pre('self.acos') { |x| -1 <= x && x <= 1 }
6
- post('self.acos') { |r, _| 0 <= r && r <= Math::PI }
7
- type 'self.acosh', '(%real x) -> Float'
8
- pre('self.acosh') { |x| 1 <= x }
9
- post('self.acosh') { |r, _| 0 <= r }
10
- type 'self.asin', '(%real x) -> Float'
11
- pre('self.asin') { |x| -1 <= x && x <= 1 }
12
- post('self.asin') { |r, _| -Math::PI/2 <= r && r <= Math::PI/2 }
13
- type 'self.asinh', '(%real x) -> Float'
14
- type 'self.atan', '(%real x) -> Float'
15
- post('self.atan') { |r, _| -Math::PI/2 <= r && r <= Math::PI/2 }
16
- type 'self.atan2', '(%real y, %real x) -> Float'
17
- post('self.atan2') { |r, _| -Math::PI <= r && r <= Math::PI }
18
- type 'self.atanh', '(%real x) -> Float'
19
- pre('self.atanh') { |x| -1 < x && x < 1 }
20
- type 'self.cbrt', '(%real x) -> Float'
21
- pre('self.cbrt') { |x| 0 <= x }
22
- post('self.cbrt') { |x| 0 <= x }
23
- type 'self.cos', '(%real x) -> Float'
24
- post('self.cos') { |r, _| -1 <= r && r <= 1 }
25
- type 'self.cosh', '(%real x) -> Float'
26
- post('self.cosh') { |r, _| 1 <= r }
27
- type 'self.erf', '(%real x) -> Float'
28
- post('self.erf') { |r, _| -1 < r && r < 1 }
29
- type 'self.erfc', '(%real x) -> Float'
30
- post('self.erfc') { |r, _| 0 < r && r < 2 }
31
- type 'self.exp', '(%real x) -> Float'
32
- post('self.exp') { |r, _| 0 < r }
33
- type 'self.frexp', '(%real x) -> [%real, %real]'
34
- type 'self.gamma', '(%real x) -> Float'
35
- type 'self.hypot', '(%real x, %real y) -> Float'
36
- type 'self.ldexp', '(%real fraction, %real exponent) -> Float'
37
- type 'self.lgamma', '(%real x) -> -1 or 1 or Float'
38
- type 'self.log', '(%real x, ?(%real) base) -> Float'
39
- type 'self.log10', '(%real x) -> Float'
40
- pre('self.log10') { |x| 0 < x }
41
- type 'self.log2', '(%real x) -> Float'
42
- pre('self.log2') { |x| 0 < x }
43
- type 'self.sin', '(%real x) -> Float'
44
- post('self.sin') { |r, _| -1 <= r && r <= 1 }
45
- type 'self.sinh', '(%real x) -> Float'
46
- type 'self.sqrt', '(%real x) -> Float'
47
- pre('self.sqrt') { |x| 0 <= x }
48
- post('self.sqrt') { |r, _| 0 <= r }
49
- type 'self.tan', '(%real x) -> Float'
50
- type 'self.tanh', '(%real x) -> Float'
51
- post('self.tanh') { |r, _| -1 < r && r < 1 }
52
-
53
- end