steep 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/exe/rbs +1 -1
  4. data/lib/steep/annotation_parser.rb +4 -4
  5. data/lib/steep/ast/buffer.rb +11 -7
  6. data/lib/steep/ast/builtin.rb +8 -0
  7. data/lib/steep/ast/types/factory.rb +55 -55
  8. data/lib/steep/drivers/check.rb +20 -4
  9. data/lib/steep/drivers/langserver.rb +6 -1
  10. data/lib/steep/drivers/vendor.rb +2 -2
  11. data/lib/steep/project/completion_provider.rb +5 -11
  12. data/lib/steep/project/dsl.rb +14 -0
  13. data/lib/steep/project/file.rb +42 -46
  14. data/lib/steep/project/hover_content.rb +11 -5
  15. data/lib/steep/project/options.rb +25 -3
  16. data/lib/steep/project/target.rb +10 -4
  17. data/lib/steep/signature/errors.rb +1 -1
  18. data/lib/steep/signature/validator.rb +8 -8
  19. data/lib/steep/source.rb +1 -1
  20. data/lib/steep/type_construction.rb +987 -711
  21. data/lib/steep/type_inference/constant_env.rb +1 -1
  22. data/lib/steep/type_inference/context.rb +7 -3
  23. data/lib/steep/type_inference/context_array.rb +111 -0
  24. data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
  25. data/lib/steep/type_inference/logic.rb +130 -0
  26. data/lib/steep/type_inference/type_env.rb +5 -69
  27. data/lib/steep/typing.rb +79 -22
  28. data/lib/steep/version.rb +1 -1
  29. data/lib/steep.rb +6 -1
  30. data/smoke/alias/Steepfile +1 -0
  31. data/smoke/and/Steepfile +1 -0
  32. data/smoke/array/Steepfile +1 -0
  33. data/smoke/array/b.rb +0 -2
  34. data/smoke/block/Steepfile +1 -0
  35. data/smoke/case/Steepfile +1 -0
  36. data/smoke/class/Steepfile +1 -0
  37. data/smoke/const/Steepfile +1 -0
  38. data/smoke/dstr/Steepfile +1 -0
  39. data/smoke/ensure/Steepfile +1 -0
  40. data/smoke/enumerator/Steepfile +1 -0
  41. data/smoke/extension/Steepfile +1 -0
  42. data/smoke/extension/c.rb +1 -0
  43. data/smoke/hash/Steepfile +1 -0
  44. data/smoke/hello/Steepfile +1 -0
  45. data/smoke/if/Steepfile +1 -0
  46. data/smoke/if/a.rb +1 -1
  47. data/smoke/implements/Steepfile +1 -0
  48. data/smoke/initialize/Steepfile +1 -0
  49. data/smoke/integer/Steepfile +1 -0
  50. data/smoke/interface/Steepfile +1 -0
  51. data/smoke/kwbegin/Steepfile +1 -0
  52. data/smoke/lambda/Steepfile +1 -0
  53. data/smoke/literal/Steepfile +1 -0
  54. data/smoke/map/Steepfile +1 -0
  55. data/smoke/method/Steepfile +1 -0
  56. data/smoke/module/Steepfile +1 -0
  57. data/smoke/regexp/Steepfile +1 -0
  58. data/smoke/regression/Steepfile +1 -0
  59. data/smoke/rescue/Steepfile +1 -0
  60. data/smoke/rescue/a.rb +1 -1
  61. data/smoke/self/Steepfile +1 -0
  62. data/smoke/skip/Steepfile +1 -0
  63. data/smoke/stdout/Steepfile +1 -0
  64. data/smoke/super/Steepfile +1 -0
  65. data/smoke/type_case/Steepfile +1 -0
  66. data/smoke/yield/Steepfile +1 -0
  67. data/steep.gemspec +1 -1
  68. data/vendor/ruby-signature/.gitignore +2 -2
  69. data/vendor/ruby-signature/README.md +2 -2
  70. data/vendor/ruby-signature/Rakefile +2 -2
  71. data/vendor/ruby-signature/bin/annotate-with-rdoc +14 -13
  72. data/vendor/ruby-signature/bin/console +1 -1
  73. data/vendor/ruby-signature/bin/sort +7 -6
  74. data/vendor/ruby-signature/bin/test_runner.rb +0 -1
  75. data/vendor/ruby-signature/docs/CONTRIBUTING.md +1 -1
  76. data/vendor/ruby-signature/docs/sigs.md +3 -3
  77. data/vendor/ruby-signature/docs/stdlib.md +1 -1
  78. data/vendor/ruby-signature/docs/syntax.md +9 -9
  79. data/vendor/ruby-signature/exe/rbs +5 -1
  80. data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +27 -0
  81. data/vendor/ruby-signature/lib/rbs/ast/comment.rb +27 -0
  82. data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +395 -0
  83. data/vendor/ruby-signature/lib/rbs/ast/members.rb +362 -0
  84. data/vendor/ruby-signature/lib/rbs/buffer.rb +50 -0
  85. data/vendor/ruby-signature/lib/rbs/builtin_names.rb +55 -0
  86. data/vendor/ruby-signature/lib/rbs/cli.rb +558 -0
  87. data/vendor/ruby-signature/lib/rbs/constant.rb +26 -0
  88. data/vendor/ruby-signature/lib/rbs/constant_table.rb +150 -0
  89. data/vendor/ruby-signature/lib/rbs/definition.rb +170 -0
  90. data/vendor/ruby-signature/lib/rbs/definition_builder.rb +919 -0
  91. data/vendor/ruby-signature/lib/rbs/environment.rb +281 -0
  92. data/vendor/ruby-signature/lib/rbs/environment_loader.rb +136 -0
  93. data/vendor/ruby-signature/lib/rbs/environment_walker.rb +124 -0
  94. data/vendor/ruby-signature/lib/rbs/errors.rb +187 -0
  95. data/vendor/ruby-signature/lib/rbs/location.rb +102 -0
  96. data/vendor/ruby-signature/lib/rbs/method_type.rb +123 -0
  97. data/vendor/ruby-signature/lib/rbs/namespace.rb +91 -0
  98. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.rb +21 -23
  99. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.y +18 -18
  100. data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +553 -0
  101. data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +587 -0
  102. data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +381 -0
  103. data/vendor/ruby-signature/lib/rbs/substitution.rb +46 -0
  104. data/vendor/ruby-signature/lib/rbs/test/errors.rb +61 -0
  105. data/vendor/ruby-signature/lib/rbs/test/hook.rb +294 -0
  106. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/test/setup.rb +7 -7
  107. data/vendor/ruby-signature/lib/rbs/test/spy.rb +325 -0
  108. data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +183 -0
  109. data/vendor/ruby-signature/lib/rbs/test/type_check.rb +254 -0
  110. data/vendor/ruby-signature/lib/rbs/test.rb +26 -0
  111. data/vendor/ruby-signature/lib/rbs/type_name.rb +70 -0
  112. data/vendor/ruby-signature/lib/rbs/types.rb +936 -0
  113. data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +138 -0
  114. data/vendor/ruby-signature/lib/rbs/vendorer.rb +47 -0
  115. data/vendor/ruby-signature/lib/rbs/version.rb +3 -0
  116. data/vendor/ruby-signature/lib/rbs/writer.rb +269 -0
  117. data/vendor/ruby-signature/lib/rbs.rb +64 -0
  118. data/vendor/ruby-signature/lib/ruby/signature.rb +4 -61
  119. data/vendor/ruby-signature/{ruby-signature.gemspec → rbs.gemspec} +4 -4
  120. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +58 -1
  121. data/vendor/ruby-signature/stdlib/base64/base64.rbs +69 -13
  122. data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +372 -0
  123. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +9 -0
  124. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +1 -7
  125. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +2 -1
  126. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +3 -2
  127. data/vendor/ruby-signature/stdlib/builtin/file.rbs +902 -302
  128. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +190 -68
  129. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +3 -6
  130. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +6 -4
  131. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +146 -120
  132. data/vendor/ruby-signature/stdlib/builtin/math.rbs +310 -7
  133. data/vendor/ruby-signature/stdlib/builtin/method.rbs +11 -8
  134. data/vendor/ruby-signature/stdlib/builtin/module.rbs +959 -103
  135. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +3 -0
  136. data/vendor/ruby-signature/stdlib/builtin/process.rbs +981 -108
  137. data/vendor/ruby-signature/stdlib/builtin/random.rbs +215 -41
  138. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +47 -0
  139. data/vendor/ruby-signature/stdlib/builtin/string.rbs +9 -2
  140. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +282 -11
  141. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +11 -13
  142. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +25 -29
  143. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +1 -1
  144. data/vendor/ruby-signature/stdlib/builtin/time.rbs +875 -567
  145. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +243 -44
  146. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +103 -109
  147. data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +62 -0
  148. data/vendor/ruby-signature/stdlib/csv/csv.rbs +773 -0
  149. data/vendor/ruby-signature/stdlib/erb/erb.rbs +375 -1
  150. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -4
  151. data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +247 -0
  152. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +1088 -16
  153. data/vendor/ruby-signature/stdlib/set/set.rbs +251 -27
  154. metadata +49 -44
  155. data/exe/ruby-signature +0 -3
  156. data/vendor/ruby-signature/exe/ruby-signature +0 -7
  157. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
  158. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
  159. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
  160. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
  161. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
  162. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
  163. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -555
  164. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
  165. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
  166. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
  167. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
  168. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
  169. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
  170. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
  171. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
  172. data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
  173. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
  174. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
  175. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -444
  176. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
  177. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
  178. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
  179. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
  180. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
  181. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -327
  182. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
  183. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
  184. data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
  185. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
  186. data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
  187. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
  188. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
  189. data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
  190. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
@@ -1,15 +1,71 @@
1
+ # The Base64 module provides for the encoding (#encode64, #strict_encode64,
2
+ # #urlsafe_encode64) and decoding (#decode64, #strict_decode64,
3
+ # #urlsafe_decode64) of binary data using a Base64 representation.
4
+ #
5
+ # ## Example
6
+ #
7
+ # A simple encoding and decoding.
8
+ #
9
+ # require "base64"
10
+ #
11
+ # enc = Base64.encode64('Send reinforcements')
12
+ # # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
13
+ # plain = Base64.decode64(enc)
14
+ # # -> "Send reinforcements"
15
+ #
16
+ # The purpose of using base64 to encode data is that it translates any binary
17
+ # data into purely printable characters.
18
+ #
1
19
  module Base64
2
- def self.decode64: (String str) -> String
3
- def self.encode64: (String bin) -> String
4
- def self.strict_decode64: (String str) -> String
5
- def self.strict_encode64: (String bin) -> String
6
- def self.urlsafe_decode64: (String str) -> String
7
- def self.urlsafe_encode64: (String bin) -> String
8
-
9
- def decode64: (String str) -> String
10
- def encode64: (String bin) -> String
11
- def strict_decode64: (String str) -> String
12
- def strict_encode64: (String bin) -> String
13
- def urlsafe_decode64: (String str) -> String
14
- def urlsafe_encode64: (String bin, ?padding: bool) -> String
20
+ # Returns the Base64-decoded version of `str`. This method complies with RFC
21
+ # 2045. Characters outside the base alphabet are ignored.
22
+ #
23
+ # require 'base64'
24
+ # str = 'VGhpcyBpcyBsaW5lIG9uZQpUaGlzIG' +
25
+ # 'lzIGxpbmUgdHdvClRoaXMgaXMgbGlu' +
26
+ # 'ZSB0aHJlZQpBbmQgc28gb24uLi4K'
27
+ # puts Base64.decode64(str)
28
+ #
29
+ # *Generates:*
30
+ #
31
+ # This is line one
32
+ # This is line two
33
+ # This is line three
34
+ # And so on...
35
+ def self?.decode64: (String str) -> String
36
+
37
+ # Returns the Base64-encoded version of `bin`. This method complies with RFC
38
+ # 2045. Line feeds are added to every 60 encoded characters.
39
+ #
40
+ # require 'base64'
41
+ # Base64.encode64("Now is the time for all good coders\nto learn Ruby")
42
+ #
43
+ # *Generates:*
44
+ #
45
+ # Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
46
+ # UnVieQ==
47
+ def self?.encode64: (String bin) -> String
48
+
49
+ # Returns the Base64-decoded version of `str`. This method complies with RFC
50
+ # 4648. ArgumentError is raised if `str` is incorrectly padded or contains
51
+ # non-alphabet characters. Note that CR or LF are also rejected.
52
+ def self?.strict_decode64: (String str) -> String
53
+
54
+ # Returns the Base64-encoded version of `bin`. This method complies with RFC
55
+ # 4648. No line feeds are added.
56
+ def self?.strict_encode64: (String bin) -> String
57
+
58
+ # Returns the Base64-decoded version of `str`. This method complies with ``Base
59
+ # 64 Encoding with URL and Filename Safe Alphabet'' in RFC 4648. The alphabet
60
+ # uses '-' instead of '+' and '_' instead of '/'.
61
+ #
62
+ # The padding character is optional. This method accepts both correctly-padded
63
+ # and unpadded input. Note that it still rejects incorrectly-padded input.
64
+ def self?.urlsafe_decode64: (String str) -> String
65
+
66
+ # Returns the Base64-encoded version of `bin`. This method complies with ``Base
67
+ # 64 Encoding with URL and Filename Safe Alphabet'' in RFC 4648. The alphabet
68
+ # uses '-' instead of '+' and '_' instead of '/'. Note that the result can still
69
+ # contain '='. You can remove the padding by setting `padding` as false.
70
+ def self?.urlsafe_encode64: (String bin, ?padding: bool) -> String
15
71
  end
@@ -0,0 +1,372 @@
1
+ # The Benchmark module provides methods to measure and report the time used to
2
+ # execute Ruby code.
3
+ #
4
+ # * Measure the time to construct the string given by the expression
5
+ # `"a"*1_000_000_000`:
6
+ #
7
+ # require 'benchmark'
8
+ #
9
+ # puts Benchmark.measure { "a"*1_000_000_000 }
10
+ #
11
+ # On my machine (OSX 10.8.3 on i5 1.7 GHz) this generates:
12
+ #
13
+ # 0.350000 0.400000 0.750000 ( 0.835234)
14
+ #
15
+ # This report shows the user CPU time, system CPU time, the sum of the user
16
+ # and system CPU times, and the elapsed real time. The unit of time is
17
+ # seconds.
18
+ #
19
+ # * Do some experiments sequentially using the #bm method:
20
+ #
21
+ # require 'benchmark'
22
+ #
23
+ # n = 5000000
24
+ # Benchmark.bm do |x|
25
+ # x.report { for i in 1..n; a = "1"; end }
26
+ # x.report { n.times do ; a = "1"; end }
27
+ # x.report { 1.upto(n) do ; a = "1"; end }
28
+ # end
29
+ #
30
+ # The result:
31
+ #
32
+ # user system total real
33
+ # 1.010000 0.000000 1.010000 ( 1.014479)
34
+ # 1.000000 0.000000 1.000000 ( 0.998261)
35
+ # 0.980000 0.000000 0.980000 ( 0.981335)
36
+ #
37
+ # * Continuing the previous example, put a label in each report:
38
+ #
39
+ # require 'benchmark'
40
+ #
41
+ # n = 5000000
42
+ # Benchmark.bm(7) do |x|
43
+ # x.report("for:") { for i in 1..n; a = "1"; end }
44
+ # x.report("times:") { n.times do ; a = "1"; end }
45
+ # x.report("upto:") { 1.upto(n) do ; a = "1"; end }
46
+ # end
47
+ #
48
+ #
49
+ # The result:
50
+ #
51
+ # user system total real
52
+ # for: 1.010000 0.000000 1.010000 ( 1.015688)
53
+ # times: 1.000000 0.000000 1.000000 ( 1.003611)
54
+ # upto: 1.030000 0.000000 1.030000 ( 1.028098)
55
+ #
56
+ # * The times for some benchmarks depend on the order in which items are run.
57
+ # These differences are due to the cost of memory allocation and garbage
58
+ # collection. To avoid these discrepancies, the #bmbm method is provided.
59
+ # For example, to compare ways to sort an array of floats:
60
+ #
61
+ # require 'benchmark'
62
+ #
63
+ # array = (1..1000000).map { rand }
64
+ #
65
+ # Benchmark.bmbm do |x|
66
+ # x.report("sort!") { array.dup.sort! }
67
+ # x.report("sort") { array.dup.sort }
68
+ # end
69
+ #
70
+ # The result:
71
+ #
72
+ # Rehearsal -----------------------------------------
73
+ # sort! 1.490000 0.010000 1.500000 ( 1.490520)
74
+ # sort 1.460000 0.000000 1.460000 ( 1.463025)
75
+ # -------------------------------- total: 2.960000sec
76
+ #
77
+ # user system total real
78
+ # sort! 1.460000 0.000000 1.460000 ( 1.460465)
79
+ # sort 1.450000 0.010000 1.460000 ( 1.448327)
80
+ #
81
+ # * Report statistics of sequential experiments with unique labels, using the
82
+ # #benchmark method:
83
+ #
84
+ # require 'benchmark'
85
+ # include Benchmark # we need the CAPTION and FORMAT constants
86
+ #
87
+ # n = 5000000
88
+ # Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
89
+ # tf = x.report("for:") { for i in 1..n; a = "1"; end }
90
+ # tt = x.report("times:") { n.times do ; a = "1"; end }
91
+ # tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
92
+ # [tf+tt+tu, (tf+tt+tu)/3]
93
+ # end
94
+ #
95
+ # The result:
96
+ #
97
+ # user system total real
98
+ # for: 0.950000 0.000000 0.950000 ( 0.952039)
99
+ # times: 0.980000 0.000000 0.980000 ( 0.984938)
100
+ # upto: 0.950000 0.000000 0.950000 ( 0.946787)
101
+ # >total: 2.880000 0.000000 2.880000 ( 2.883764)
102
+ # >avg: 0.960000 0.000000 0.960000 ( 0.961255)
103
+ #
104
+ #
105
+ module Benchmark
106
+ # Invokes the block with a Benchmark::Report object, which may be used to
107
+ # collect and report on the results of individual benchmark tests. Reserves
108
+ # `label_width` leading spaces for labels on each line. Prints `caption` at the
109
+ # top of the report, and uses `format` to format each line. Returns an array of
110
+ # Benchmark::Tms objects.
111
+ #
112
+ # If the block returns an array of Benchmark::Tms objects, these will be used to
113
+ # format additional lines of output. If `labels` parameter are given, these are
114
+ # used to label these extra lines.
115
+ #
116
+ # *Note*: Other methods provide a simpler interface to this one, and are
117
+ # suitable for nearly all benchmarking requirements. See the examples in
118
+ # Benchmark, and the #bm and #bmbm methods.
119
+ #
120
+ # Example:
121
+ #
122
+ # require 'benchmark'
123
+ # include Benchmark # we need the CAPTION and FORMAT constants
124
+ #
125
+ # n = 5000000
126
+ # Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
127
+ # tf = x.report("for:") { for i in 1..n; a = "1"; end }
128
+ # tt = x.report("times:") { n.times do ; a = "1"; end }
129
+ # tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
130
+ # [tf+tt+tu, (tf+tt+tu)/3]
131
+ # end
132
+ #
133
+ # Generates:
134
+ #
135
+ # user system total real
136
+ # for: 0.970000 0.000000 0.970000 ( 0.970493)
137
+ # times: 0.990000 0.000000 0.990000 ( 0.989542)
138
+ # upto: 0.970000 0.000000 0.970000 ( 0.972854)
139
+ # >total: 2.930000 0.000000 2.930000 ( 2.932889)
140
+ # >avg: 0.976667 0.000000 0.976667 ( 0.977630)
141
+ #
142
+ def self?.benchmark: (String caption, ?Integer? label_width, ?String? format, *String labels) { (Report report) -> (Array[Tms] | void) } -> ::Array[Benchmark::Tms]
143
+
144
+ # A simple interface to the #benchmark method, #bm generates sequential reports
145
+ # with labels. `label_width` and `labels` parameters have the same meaning as
146
+ # for #benchmark.
147
+ #
148
+ # require 'benchmark'
149
+ #
150
+ # n = 5000000
151
+ # Benchmark.bm(7) do |x|
152
+ # x.report("for:") { for i in 1..n; a = "1"; end }
153
+ # x.report("times:") { n.times do ; a = "1"; end }
154
+ # x.report("upto:") { 1.upto(n) do ; a = "1"; end }
155
+ # end
156
+ #
157
+ # Generates:
158
+ #
159
+ # user system total real
160
+ # for: 0.960000 0.000000 0.960000 ( 0.957966)
161
+ # times: 0.960000 0.000000 0.960000 ( 0.960423)
162
+ # upto: 0.950000 0.000000 0.950000 ( 0.954864)
163
+ #
164
+ def self?.bm: (?Integer label_width, *String labels) { (Report report) -> void } -> ::Array[Benchmark::Tms]
165
+
166
+ # Sometimes benchmark results are skewed because code executed earlier
167
+ # encounters different garbage collection overheads than that run later. #bmbm
168
+ # attempts to minimize this effect by running the tests twice, the first time as
169
+ # a rehearsal in order to get the runtime environment stable, the second time
170
+ # for real. GC.start is executed before the start of each of the real timings;
171
+ # the cost of this is not included in the timings. In reality, though, there's
172
+ # only so much that #bmbm can do, and the results are not guaranteed to be
173
+ # isolated from garbage collection and other effects.
174
+ #
175
+ # Because #bmbm takes two passes through the tests, it can calculate the
176
+ # required label width.
177
+ #
178
+ # require 'benchmark'
179
+ #
180
+ # array = (1..1000000).map { rand }
181
+ #
182
+ # Benchmark.bmbm do |x|
183
+ # x.report("sort!") { array.dup.sort! }
184
+ # x.report("sort") { array.dup.sort }
185
+ # end
186
+ #
187
+ # Generates:
188
+ #
189
+ # Rehearsal -----------------------------------------
190
+ # sort! 1.440000 0.010000 1.450000 ( 1.446833)
191
+ # sort 1.440000 0.000000 1.440000 ( 1.448257)
192
+ # -------------------------------- total: 2.890000sec
193
+ #
194
+ # user system total real
195
+ # sort! 1.460000 0.000000 1.460000 ( 1.458065)
196
+ # sort 1.450000 0.000000 1.450000 ( 1.455963)
197
+ #
198
+ # #bmbm yields a Benchmark::Job object and returns an array of Benchmark::Tms
199
+ # objects.
200
+ #
201
+ def self?.bmbm: (?Integer width) { (Job job) -> void } -> ::Array[Benchmark::Tms]
202
+
203
+ # Returns the time used to execute the given block as a Benchmark::Tms object.
204
+ # Takes `label` option.
205
+ #
206
+ # require 'benchmark'
207
+ #
208
+ # n = 1000000
209
+ #
210
+ # time = Benchmark.measure do
211
+ # n.times { a = "1" }
212
+ # end
213
+ # puts time
214
+ #
215
+ # Generates:
216
+ #
217
+ # 0.220000 0.000000 0.220000 ( 0.227313)
218
+ #
219
+ def self?.measure: (?String label) { () -> void } -> Benchmark::Tms
220
+
221
+ # Returns the elapsed real time used to execute the given block.
222
+ #
223
+ def self?.realtime: () { () -> void } -> Float
224
+ end
225
+
226
+ Benchmark::BENCHMARK_VERSION: String
227
+
228
+ # The default caption string (heading above the output times).
229
+ #
230
+ Benchmark::CAPTION: String
231
+
232
+ # The default format string used to display times. See also
233
+ # Benchmark::Tms#format.
234
+ #
235
+ Benchmark::FORMAT: String
236
+
237
+ class Benchmark::Job
238
+ # Prints the `label` and measured time for the block,
239
+ # formatted by `format`. See Tms#format for the
240
+ # formatting rules.
241
+ def item: (?String label) { () -> void } -> self
242
+
243
+ # An array of 2-element arrays, consisting of label and block pairs.
244
+ def list: () -> ::Array[untyped]
245
+
246
+ alias report item
247
+
248
+ # Length of the widest label in the #list.
249
+ def width: () -> Integer
250
+ end
251
+
252
+ class Benchmark::Report
253
+ # Prints the `label` and measured time for the block,
254
+ # formatted by `format`. See Tms#format for the
255
+ # formatting rules.
256
+ def item: (?String label, *untyped format) { () -> void } -> Tms
257
+
258
+ # An array of Benchmark::Tms objects representing each item.
259
+ def list: () -> ::Array[Benchmark::Tms]
260
+
261
+ alias report item
262
+ end
263
+
264
+ # A data object, representing the times associated with a benchmark measurement.
265
+ #
266
+ class Benchmark::Tms
267
+ # Returns a new Tms object obtained by memberwise multiplication of the
268
+ # individual times for this Tms object by `x`.
269
+ #
270
+ def *: (untyped x) -> untyped
271
+
272
+ # Returns a new Tms object obtained by memberwise summation of the individual
273
+ # times for this Tms object with those of the `other` Tms object. This method
274
+ # and #/() are useful for taking statistics.
275
+ #
276
+ def +: (untyped other) -> untyped
277
+
278
+ # Returns a new Tms object obtained by memberwise subtraction of the individual
279
+ # times for the `other` Tms object from those of this Tms object.
280
+ #
281
+ def -: (untyped other) -> untyped
282
+
283
+ # Returns a new Tms object obtained by memberwise division of the individual
284
+ # times for this Tms object by `x`. This method and #+() are useful for taking
285
+ # statistics.
286
+ #
287
+ def /: (untyped x) -> untyped
288
+
289
+ # Returns a new Tms object whose times are the sum of the times for this Tms
290
+ # object, plus the time required to execute the code block (`blk`).
291
+ #
292
+ def add: () { (*untyped) -> untyped } -> untyped
293
+
294
+ # An in-place version of #add. Changes the times of this Tms object by making it
295
+ # the sum of the times for this Tms object, plus the time required to execute
296
+ # the code block (`blk`).
297
+ #
298
+ def add!: () { (*untyped) -> untyped } -> untyped
299
+
300
+ # System CPU time of children
301
+ #
302
+ def cstime: () -> Float
303
+
304
+ # User CPU time of children
305
+ #
306
+ def cutime: () -> Float
307
+
308
+ # Returns the contents of this Tms object as a formatted string, according to a
309
+ # `format` string like that passed to Kernel.format. In addition, #format
310
+ # accepts the following extensions:
311
+ #
312
+ # `%u`
313
+ # : Replaced by the user CPU time, as reported by Tms#utime.
314
+ # `%y`
315
+ # : Replaced by the system CPU time, as reported by #stime (Mnemonic: y of
316
+ # "s*y*stem")
317
+ # `%U`
318
+ # : Replaced by the children's user CPU time, as reported by Tms#cutime
319
+ # `%Y`
320
+ # : Replaced by the children's system CPU time, as reported by Tms#cstime
321
+ # `%t`
322
+ # : Replaced by the total CPU time, as reported by Tms#total
323
+ # `%r`
324
+ # : Replaced by the elapsed real time, as reported by Tms#real
325
+ # `%n`
326
+ # : Replaced by the label string, as reported by Tms#label (Mnemonic: n of
327
+ # "*n*ame")
328
+ #
329
+ #
330
+ # If `format` is not given, FORMAT is used as default value, detailing the user,
331
+ # system and real elapsed time.
332
+ #
333
+ def format: (?String format, *untyped args) -> String
334
+
335
+ # Label
336
+ #
337
+ def label: () -> String
338
+
339
+ # Elapsed real time
340
+ #
341
+ def real: () -> Float
342
+
343
+ # System CPU time
344
+ #
345
+ def stime: () -> Float
346
+
347
+ # Returns a new 6-element array, consisting of the label, user CPU time, system
348
+ # CPU time, children's user CPU time, children's system CPU time and elapsed
349
+ # real time.
350
+ #
351
+ def to_a: () -> untyped
352
+
353
+ # Same as #format.
354
+ #
355
+ def to_s: () -> String
356
+
357
+ # Total time, that is `utime` + `stime` + `cutime` + `cstime`
358
+ #
359
+ def total: () -> Float
360
+
361
+ # User CPU time
362
+ #
363
+ def utime: () -> Float
364
+ end
365
+
366
+ # Default caption, see also Benchmark::CAPTION
367
+ #
368
+ Benchmark::Tms::CAPTION: String
369
+
370
+ # Default format string, see also Benchmark::FORMAT
371
+ #
372
+ Benchmark::Tms::FORMAT: String
@@ -22,10 +22,19 @@ interface _ToProc
22
22
  def to_proc: () -> untyped
23
23
  end
24
24
 
25
+ interface _ToPath
26
+ def to_path: () -> String
27
+ end
28
+
25
29
  interface _Each[out A, out B]
26
30
  def each: { (A) -> void } -> B
27
31
  end
28
32
 
33
+ interface _Exception
34
+ def exception: () -> Exception
35
+ | (String arg0) -> Exception
36
+ end
37
+
29
38
  class BigDecimal
30
39
  end
31
40
 
@@ -249,14 +249,8 @@ class Dir
249
249
  # passed *aDir* as a parameter. The directory is closed at the end of the block,
250
250
  # and Dir::open returns the value of the block.
251
251
  #
252
- # # arglists 💪👽🚨 << Delete this section
253
- # Dir.open( string ) -> aDir
254
- # Dir.open( string, encoding: enc ) -> aDir
255
- # Dir.open( string ) {| aDir | block } -> anObject
256
- # Dir.open( string, encoding: enc ) {| aDir | block } -> anObject
257
- #
258
252
  def self.open: (string, ?encoding: Encoding | string | nil) -> Dir
259
- | [U] (string, ?encoding: Encoding) { (Dir) -> U } -> U
253
+ | [U] (string, ?encoding: Encoding | string | nil) { (Dir) -> U } -> U
260
254
 
261
255
  # Returns the path to the current working directory of this process as a string.
262
256
  #
@@ -86,10 +86,11 @@ class Encoding < Object
86
86
  #
87
87
  # [::default\_internal](Encoding.downloaded.ruby_doc#method-c-default_internal)
88
88
  # is initialized by the source file's internal\_encoding or -E option.
89
- def self.default_internal: () -> Encoding
89
+ def self.default_internal: () -> Encoding?
90
90
 
91
91
  def self.default_internal=: (String arg0) -> String?
92
92
  | (Encoding arg0) -> Encoding?
93
+ | (nil arg0) -> nil
93
94
 
94
95
  def self.find: (String | Encoding arg0) -> Encoding
95
96
 
@@ -124,7 +124,7 @@
124
124
  class Exception < Object
125
125
  def self.to_tty?: () -> bool
126
126
 
127
- def self.exception: (?String msg) -> self
127
+ def self.exception: (?String msg) -> Exception
128
128
 
129
129
  def ==: (untyped arg0) -> bool
130
130
 
@@ -172,7 +172,8 @@ class Exception < Object
172
172
  # original exception information.
173
173
  def cause: () -> Exception?
174
174
 
175
- def exception: (?String arg0) -> Exception
175
+ def exception: () -> self
176
+ | (String arg0) -> Exception
176
177
 
177
178
  def initialize: (?String arg0) -> void
178
179