raap 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/README.md +28 -3
- data/Rakefile +3 -1
- data/exe/raap +1 -0
- data/lib/raap/bind_call.rb +3 -1
- data/lib/raap/cli.rb +53 -34
- data/lib/raap/function_type.rb +6 -6
- data/lib/raap/method_property.rb +16 -16
- data/lib/raap/method_type.rb +5 -5
- data/lib/raap/minitest.rb +4 -2
- data/lib/raap/symbolic_caller.rb +2 -2
- data/lib/raap/type.rb +53 -73
- data/lib/raap/type_substitution.rb +6 -3
- data/lib/raap/value/bottom.rb +2 -0
- data/lib/raap/value/interface.rb +59 -33
- data/lib/raap/value/intersection.rb +24 -31
- data/lib/raap/value/module.rb +7 -3
- data/lib/raap/value/top.rb +2 -0
- data/lib/raap/value/variable.rb +2 -0
- data/lib/raap/value/void.rb +2 -0
- data/lib/raap/version.rb +1 -1
- data/lib/raap.rb +1 -0
- data/lib/shims.rb +38 -0
- data/rbs_collection.lock.yaml +5 -5
- data/sig/raap.rbs +11 -11
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5780226ede8755c1ef7f82e18b7e8d96a63d2ab6eb253bc8964f5745776f993f
|
4
|
+
data.tar.gz: 6e9dd39a302f555cac12ecb6232a7c2f39d206911fcee7a30650d5fe4a9cbc63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2841e75bc0b03742cc0d9268f9ec2ae69f2f9c6e1f579ec6e794db5e9b8f80d763fac4ce28abd7361e19ada8f6289e594b6a9a3cdc63b1806181a69a9f49bb6a
|
7
|
+
data.tar.gz: a3057811c5d13ac4f891fc2c2082b91f33a1a8d35d3c9b6e1ccb1871c268127811caa6f2708c878ef35ae4cc25143db62c4e5801ded32cfad9a1db50387753a6
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 3.
|
2
|
+
TargetRubyVersion: 3.0
|
3
3
|
NewCops: enable
|
4
4
|
Include:
|
5
5
|
- 'lib/**/*.rb'
|
@@ -14,6 +14,8 @@ Style:
|
|
14
14
|
Style/HashSyntax:
|
15
15
|
EnforcedShorthandSyntax: always
|
16
16
|
Enabled: true
|
17
|
+
Style/FrozenStringLiteralComment:
|
18
|
+
Enabled: true
|
17
19
|
|
18
20
|
Metrics:
|
19
21
|
Enabled: false
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RaaP
|
2
2
|
|
3
|
-
|
3
|
+
<img src="https://raw.githubusercontent.com/ksss/raap/main/public/jacket.webp" width=400/>
|
4
4
|
|
5
5
|
## RBS as a Property
|
6
6
|
|
@@ -70,8 +70,24 @@ $ raap 'MyClass' # Run only RBS of MyClass
|
|
70
70
|
$ raap 'MyClass::*' # Run each class under MyClass
|
71
71
|
$ raap 'MyClass.singleton_method' # Run only MyClass.singleton_method
|
72
72
|
$ raap 'MyClass#instance_method' # Run only MyClass#instance_method
|
73
|
+
$ raap 'MyClass' '!MyClass#skip' # Run methods MyClass without #skip
|
73
74
|
```
|
74
75
|
|
76
|
+
```
|
77
|
+
$ cat test/raap.txt
|
78
|
+
MyClass
|
79
|
+
!MyClass#skip
|
80
|
+
|
81
|
+
$ raap $(cat test/raap.txt) # You can manage the methods to be tested in a file
|
82
|
+
```
|
83
|
+
|
84
|
+
## Log level definition
|
85
|
+
|
86
|
+
- error: Information on status of inability to continue execution.
|
87
|
+
- warn: Information on partial corrections required.
|
88
|
+
- info: A somewhat visualized representation of the execution state.
|
89
|
+
- debug: All information including stack traces.
|
90
|
+
|
75
91
|
## Size
|
76
92
|
|
77
93
|
Random values are determined based on size.
|
@@ -103,11 +119,15 @@ You can specify to load specify PATH as RBS.
|
|
103
119
|
|
104
120
|
### `--library lib`
|
105
121
|
|
106
|
-
You can specify to load RBS library
|
122
|
+
You can specify to load RBS library.
|
107
123
|
|
108
124
|
### `--require lib`
|
109
125
|
|
110
|
-
You can specify require Ruby library
|
126
|
+
You can specify require Ruby library.
|
127
|
+
|
128
|
+
### `--log-level level`
|
129
|
+
|
130
|
+
You can specify log level (debug, info, warn or error).
|
111
131
|
|
112
132
|
### `--timeout sec`
|
113
133
|
|
@@ -125,6 +145,11 @@ You can specify size of end.
|
|
125
145
|
|
126
146
|
You can specify size of step like `Integer#step: (to: Integer, by: Integer)`.
|
127
147
|
|
148
|
+
### `--allow-private`
|
149
|
+
|
150
|
+
By default, raap only validates public methods.
|
151
|
+
However, by setting this option, it is possible to intentionally validate private methods in the RBS.
|
152
|
+
|
128
153
|
## First support is CLI
|
129
154
|
|
130
155
|
In RaaP, usage through the CLI is the primary support focus, and efforts are made to maintain compatibility. The use of the library's code (such as `RaaP::Type`) does not guarantee compatibility.
|
data/Rakefile
CHANGED
data/exe/raap
CHANGED
data/lib/raap/bind_call.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RaaP
|
2
4
|
module BindCall
|
3
5
|
class << self
|
4
|
-
def
|
6
|
+
def define_method(...) = ::Module.instance_method(:define_method).bind_call(...)
|
5
7
|
def respond_to?(...) = ::Kernel.instance_method(:respond_to?).bind_call(...)
|
6
8
|
def instance_of?(...) = ::Kernel.instance_method(:instance_of?).bind_call(...)
|
7
9
|
def is_a?(...) = ::Kernel.instance_method(:is_a?).bind_call(...)
|
data/lib/raap/cli.rb
CHANGED
@@ -12,7 +12,6 @@ module RaaP
|
|
12
12
|
:size_to,
|
13
13
|
:size_by,
|
14
14
|
:allow_private,
|
15
|
-
:skips,
|
16
15
|
keyword_init: true
|
17
16
|
)
|
18
17
|
|
@@ -45,7 +44,6 @@ module RaaP
|
|
45
44
|
size_from: 0,
|
46
45
|
size_to: 99,
|
47
46
|
size_by: 1,
|
48
|
-
skips: [],
|
49
47
|
allow_private: false,
|
50
48
|
)
|
51
49
|
@argv = argv
|
@@ -64,7 +62,7 @@ module RaaP
|
|
64
62
|
o.on('--require lib', 'require ruby library') do |lib|
|
65
63
|
@option.requires << lib
|
66
64
|
end
|
67
|
-
o.on('--log-level level', "default:
|
65
|
+
o.on('--log-level level', "default: info") do |arg|
|
68
66
|
RaaP.logger.level = arg
|
69
67
|
end
|
70
68
|
o.on('--timeout sec', Float, "default: #{@option.timeout}") do |arg|
|
@@ -82,9 +80,6 @@ module RaaP
|
|
82
80
|
o.on('--allow-private', "default: #{@option.allow_private}") do
|
83
81
|
@option.allow_private = true
|
84
82
|
end
|
85
|
-
o.on('--skip tag', "skip case (e.g. `Foo#meth`)") do |tag|
|
86
|
-
@option.skips << tag
|
87
|
-
end
|
88
83
|
end.parse!(@argv)
|
89
84
|
|
90
85
|
@option.dirs.each do |dir|
|
@@ -96,10 +91,6 @@ module RaaP
|
|
96
91
|
@option.requires.each do |lib|
|
97
92
|
require lib
|
98
93
|
end
|
99
|
-
@option.skips.each do |skip|
|
100
|
-
@skip << skip
|
101
|
-
end
|
102
|
-
@skip.freeze
|
103
94
|
|
104
95
|
self
|
105
96
|
end
|
@@ -111,16 +102,29 @@ module RaaP
|
|
111
102
|
exit 1
|
112
103
|
end
|
113
104
|
|
114
|
-
|
105
|
+
# Search skip tag
|
106
|
+
@argv.each do |tag|
|
107
|
+
if tag.start_with?('!')
|
108
|
+
t = tag[1..] or raise
|
109
|
+
t = "::#{t}" unless t.start_with?('::')
|
110
|
+
t or raise
|
111
|
+
@skip << t
|
112
|
+
end
|
113
|
+
end
|
114
|
+
@skip.freeze
|
115
|
+
|
116
|
+
@argv.each do |tag|
|
117
|
+
next if tag.start_with?('!')
|
118
|
+
|
115
119
|
case
|
116
120
|
when tag.include?('#')
|
117
|
-
run_by(kind: :instance, tag:)
|
121
|
+
run_by(kind: :instance, tag: tag)
|
118
122
|
when tag.include?('.')
|
119
|
-
run_by(kind: :singleton, tag:)
|
123
|
+
run_by(kind: :singleton, tag: tag)
|
120
124
|
when tag.end_with?('*')
|
121
|
-
run_by_type_name_with_search(tag:)
|
125
|
+
run_by_type_name_with_search(tag: tag)
|
122
126
|
else
|
123
|
-
run_by_type_name(tag:)
|
127
|
+
run_by_type_name(tag: tag)
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
@@ -194,9 +198,10 @@ module RaaP
|
|
194
198
|
|
195
199
|
RaaP.logger.info("# #{type}")
|
196
200
|
@results << {
|
197
|
-
method
|
201
|
+
method: method,
|
198
202
|
properties: method.method_types.map do |method_type|
|
199
|
-
property(receiver_type
|
203
|
+
property(receiver_type: receiver_type, type_params_decl: type_params_decl, type_args: type_args, method_type: method_type,
|
204
|
+
method_name: method_name)
|
200
205
|
end
|
201
206
|
}
|
202
207
|
end
|
@@ -204,7 +209,11 @@ module RaaP
|
|
204
209
|
def run_by_type_name_with_search(tag:)
|
205
210
|
first, _last = tag.split('::')
|
206
211
|
RBS.env.class_decls.each do |name, _entry|
|
207
|
-
if ['', '::'].any? { |pre| name.to_s.
|
212
|
+
if ['', '::'].any? { |pre| name.to_s.start_with?("#{pre}#{first}") }
|
213
|
+
if @skip.include?(name.to_s)
|
214
|
+
RaaP.logger.info("Skip #{name}")
|
215
|
+
next
|
216
|
+
end
|
208
217
|
run_by_type_name(tag: name.to_s)
|
209
218
|
end
|
210
219
|
end
|
@@ -220,32 +229,40 @@ module RaaP
|
|
220
229
|
|
221
230
|
definition = RBS.builder.build_singleton(type_name)
|
222
231
|
type_params_decl = definition.type_params_decl
|
223
|
-
definition.methods.
|
224
|
-
|
232
|
+
definition.methods.each do |method_name, method|
|
233
|
+
if @skip.include?("#{type_name.absolute!}.#{method_name}")
|
234
|
+
RaaP.logger.info("Skip #{"#{type_name.absolute!}.#{method_name}"}")
|
235
|
+
next
|
236
|
+
end
|
225
237
|
next unless method.accessibility == :public
|
226
238
|
next if method.defined_in != type_name
|
227
239
|
|
228
240
|
RaaP.logger.info("# #{type_name}.#{method_name}")
|
229
241
|
@results << {
|
230
|
-
method
|
242
|
+
method: method,
|
231
243
|
properties: method.method_types.map do |method_type|
|
232
|
-
property(receiver_type: Type.new("singleton(#{type.name})"), type_params_decl
|
244
|
+
property(receiver_type: Type.new("singleton(#{type.name})"), type_params_decl: type_params_decl, type_args: type_args,
|
245
|
+
method_type: method_type, method_name: method_name)
|
233
246
|
end
|
234
247
|
}
|
235
248
|
end
|
236
249
|
|
237
250
|
definition = RBS.builder.build_instance(type_name)
|
238
251
|
type_params_decl = definition.type_params_decl
|
239
|
-
definition.methods.
|
240
|
-
|
252
|
+
definition.methods.each do |method_name, method|
|
253
|
+
if @skip.include?("#{type_name.absolute!}##{method_name}")
|
254
|
+
RaaP.logger.info("Skip #{"#{type_name.absolute!}.#{method_name}"}")
|
255
|
+
next
|
256
|
+
end
|
241
257
|
next unless method.accessibility == :public
|
242
258
|
next if method.defined_in != type_name
|
243
259
|
|
244
260
|
RaaP.logger.info("# #{type_name}##{method_name}")
|
245
261
|
@results << {
|
246
|
-
method
|
262
|
+
method: method,
|
247
263
|
properties: method.method_types.map do |method_type|
|
248
|
-
property(receiver_type: Type.new(type.name), type_params_decl
|
264
|
+
property(receiver_type: Type.new(type.name), type_params_decl: type_params_decl, type_args: type_args, method_type: method_type,
|
265
|
+
method_name: method_name)
|
249
266
|
end
|
250
267
|
}
|
251
268
|
end
|
@@ -258,28 +275,30 @@ module RaaP
|
|
258
275
|
else
|
259
276
|
prefix = ''
|
260
277
|
end
|
261
|
-
|
278
|
+
|
279
|
+
# type_args delegate to self_type
|
280
|
+
type_params_decl.each_with_index do |param, i|
|
262
281
|
if rtype.instance_of?(::RBS::Types::ClassInstance)
|
263
|
-
rtype.args[i] = type_args[i] || ::RBS::Types::Bases::Any.new(location: nil)
|
282
|
+
rtype.args[i] = type_args[i] || param.upper_bound || ::RBS::Types::Bases::Any.new(location: nil)
|
264
283
|
end
|
265
284
|
end
|
266
285
|
RaaP.logger.info("## def #{prefix}#{method_name}: #{method_type}")
|
267
286
|
status = 0
|
268
287
|
reason = nil
|
269
288
|
prop = MethodProperty.new(
|
270
|
-
receiver_type
|
271
|
-
method_name
|
289
|
+
receiver_type: receiver_type,
|
290
|
+
method_name: method_name,
|
272
291
|
method_type: MethodType.new(
|
273
292
|
method_type,
|
274
|
-
type_params_decl
|
275
|
-
type_args
|
293
|
+
type_params_decl: type_params_decl,
|
294
|
+
type_args: type_args,
|
276
295
|
self_type: rtype,
|
277
296
|
instance_type: ::RBS::Types::ClassInstance.new(name: rtype.name, args: type_args, location: nil),
|
278
297
|
class_type: ::RBS::Types::ClassSingleton.new(name: rtype.name, location: nil),
|
279
298
|
),
|
280
299
|
size_step: @option.size_from.step(to: @option.size_to, by: @option.size_by),
|
281
300
|
timeout: @option.timeout,
|
282
|
-
allow_private:
|
301
|
+
allow_private: @option.allow_private,
|
283
302
|
)
|
284
303
|
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
285
304
|
stats = prop.run do |called|
|
@@ -290,7 +309,7 @@ module RaaP
|
|
290
309
|
in Result::Failure => f
|
291
310
|
puts 'F'
|
292
311
|
if (e = f.exception)
|
293
|
-
RaaP.logger.
|
312
|
+
RaaP.logger.info { "Failure: [#{e.class}] #{e.message}" }
|
294
313
|
RaaP.logger.debug { e.backtrace.join("\n") }
|
295
314
|
end
|
296
315
|
RaaP.logger.debug { PP.pp(f.symbolic_call, ''.dup) }
|
data/lib/raap/function_type.rb
CHANGED
@@ -7,12 +7,12 @@ module RaaP
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def pick_arguments(size: 10)
|
10
|
-
SymbolicCaller.new(arguments_to_symbolic_call(size:)).eval
|
10
|
+
SymbolicCaller.new(arguments_to_symbolic_call(size: size)).eval
|
11
11
|
end
|
12
12
|
|
13
13
|
def arguments_to_symbolic_call(size: 10)
|
14
|
-
a = to_symbolic_call_recursive(build_args_type, size:)
|
15
|
-
k = to_symbolic_call_recursive(build_kwargs_type, size:)
|
14
|
+
a = to_symbolic_call_recursive(build_args_type, size: size)
|
15
|
+
k = to_symbolic_call_recursive(build_kwargs_type, size: size)
|
16
16
|
|
17
17
|
[a, k]
|
18
18
|
end
|
@@ -24,11 +24,11 @@ module RaaP
|
|
24
24
|
when type.nil?
|
25
25
|
nil
|
26
26
|
when type.respond_to?(:each_pair)
|
27
|
-
type.each_pair.to_h { |k, v| [k, to_symbolic_call_recursive(v, size:)] }
|
27
|
+
type.each_pair.to_h { |k, v| [k, to_symbolic_call_recursive(v, size: size)] }
|
28
28
|
when type.respond_to?(:each)
|
29
|
-
type.each.map { |v| to_symbolic_call_recursive(v, size:) }
|
29
|
+
type.each.map { |v| to_symbolic_call_recursive(v, size: size) }
|
30
30
|
else
|
31
|
-
type.to_symbolic_call(size:)
|
31
|
+
type.to_symbolic_call(size: size)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
data/lib/raap/method_property.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RaaP
|
4
4
|
class MethodProperty
|
5
|
-
class Stats < Struct.new(:success, :skip, :exception, :break)
|
5
|
+
class Stats < Struct.new(:success, :skip, :exception, :break, keyword_init: true)
|
6
6
|
def initialize(success: 0, skip: 0, exception: 0, break: false)
|
7
7
|
super
|
8
8
|
end
|
@@ -23,7 +23,7 @@ module RaaP
|
|
23
23
|
Timeout.timeout(@timeout) do
|
24
24
|
catch(:break) do
|
25
25
|
@size_step.each do |size|
|
26
|
-
call(size
|
26
|
+
call(size: size, stats: stats).tap do |ret|
|
27
27
|
case ret
|
28
28
|
when Result::Success
|
29
29
|
stats.success += 1
|
@@ -50,13 +50,13 @@ module RaaP
|
|
50
50
|
private
|
51
51
|
|
52
52
|
def call(size:, stats:)
|
53
|
-
if @method_type.rbs.each_type.find { |t| t.instance_of?(::RBS::Types::Bases::Any) }
|
53
|
+
if @method_type.rbs.type.each_type.find { |t| t.instance_of?(::RBS::Types::Bases::Any) }
|
54
54
|
RaaP.logger.info { "Skip type check since `#{@method_type.rbs}` includes `untyped`" }
|
55
55
|
stats.break = true
|
56
56
|
throw :break
|
57
57
|
end
|
58
|
-
receiver_value = @receiver_type.to_symbolic_call(size:)
|
59
|
-
args, kwargs, block = @method_type.arguments_to_symbolic_call(size:)
|
58
|
+
receiver_value = @receiver_type.to_symbolic_call(size: size)
|
59
|
+
args, kwargs, block = @method_type.arguments_to_symbolic_call(size: size)
|
60
60
|
# @type var symbolic_call: symbolic_call
|
61
61
|
symbolic_call = [:call, receiver_value, @method_name, args, kwargs, block]
|
62
62
|
symbolic_caller = SymbolicCaller.new(symbolic_call, allow_private: @allow_private)
|
@@ -77,25 +77,25 @@ module RaaP
|
|
77
77
|
end
|
78
78
|
else
|
79
79
|
return_value = symbolic_caller.eval
|
80
|
-
check = check_return(receiver_value
|
80
|
+
check = check_return(receiver_value: receiver_value, return_value: return_value)
|
81
81
|
end
|
82
82
|
case check
|
83
83
|
in [:success]
|
84
|
-
Result::Success.new(symbolic_call
|
84
|
+
Result::Success.new(symbolic_call: symbolic_call, return_value: return_value)
|
85
85
|
in [:failure]
|
86
|
-
Result::Failure.new(symbolic_call
|
86
|
+
Result::Failure.new(symbolic_call: symbolic_call, return_value: return_value)
|
87
87
|
in [:exception, exception]
|
88
|
-
Result::Exception.new(symbolic_call
|
88
|
+
Result::Exception.new(symbolic_call: symbolic_call, exception: exception)
|
89
89
|
end
|
90
90
|
rescue TypeError => exception
|
91
|
-
Result::Failure.new(symbolic_call
|
91
|
+
Result::Failure.new(symbolic_call: symbolic_call, return_value: return_value, exception: exception)
|
92
92
|
end
|
93
93
|
|
94
94
|
# not ensure symbolic_call
|
95
95
|
rescue NoMethodError, NotImplementedError => exception
|
96
|
-
Result::Skip.new(symbolic_call
|
96
|
+
Result::Skip.new(symbolic_call: symbolic_call, exception: exception)
|
97
97
|
rescue NameError => e
|
98
|
-
RaaP.logger.
|
98
|
+
RaaP.logger.warn("[#{e.class}] #{e.detailed_message}")
|
99
99
|
msg = e.name.nil? ? '' : "for `#{BindCall.to_s(e.receiver)}::#{e.name}`"
|
100
100
|
RaaP.logger.warn("Implementation is not found #{msg} maybe.")
|
101
101
|
RaaP.logger.debug(e.backtrace&.join("\n"))
|
@@ -103,9 +103,9 @@ module RaaP
|
|
103
103
|
throw :break
|
104
104
|
rescue SystemStackError => exception
|
105
105
|
RaaP.logger.info "Found recursive type definition."
|
106
|
-
Result::Skip.new(symbolic_call
|
106
|
+
Result::Skip.new(symbolic_call: symbolic_call, exception: exception)
|
107
107
|
rescue => exception
|
108
|
-
Result::Exception.new(symbolic_call
|
108
|
+
Result::Exception.new(symbolic_call: symbolic_call, exception: exception)
|
109
109
|
end
|
110
110
|
|
111
111
|
def check_return(receiver_value:, return_value:)
|
@@ -126,8 +126,8 @@ module RaaP
|
|
126
126
|
instance_class = BindCall.class(receiver_value)
|
127
127
|
end
|
128
128
|
type_check = ::RBS::Test::TypeCheck.new(
|
129
|
-
self_class
|
130
|
-
instance_class
|
129
|
+
self_class: self_class,
|
130
|
+
instance_class: instance_class,
|
131
131
|
class_class: Module,
|
132
132
|
builder: RBS.builder,
|
133
133
|
sample_size: 100,
|
data/lib/raap/method_type.rb
CHANGED
@@ -20,17 +20,17 @@ module RaaP
|
|
20
20
|
params = (type_params_decl + rbs.type_params).uniq
|
21
21
|
ts = TypeSubstitution.new(params, type_args)
|
22
22
|
|
23
|
-
@rbs = ts.method_type_sub(rbs, self_type
|
23
|
+
@rbs = ts.method_type_sub(rbs, self_type: self_type, instance_type: instance_type, class_type: class_type)
|
24
24
|
@fun_type = FunctionType.new(@rbs.type)
|
25
25
|
end
|
26
26
|
|
27
27
|
def pick_arguments(size: 10)
|
28
|
-
SymbolicCaller.new(arguments_to_symbolic_call(size:)).eval
|
28
|
+
SymbolicCaller.new(arguments_to_symbolic_call(size: size)).eval
|
29
29
|
end
|
30
30
|
|
31
31
|
def arguments_to_symbolic_call(size: 10)
|
32
|
-
args, kwargs = @fun_type.arguments_to_symbolic_call(size:)
|
33
|
-
block = pick_block(size:)
|
32
|
+
args, kwargs = @fun_type.arguments_to_symbolic_call(size: size)
|
33
|
+
block = pick_block(size: size)
|
34
34
|
|
35
35
|
[args, kwargs, block]
|
36
36
|
end
|
@@ -40,7 +40,7 @@ module RaaP
|
|
40
40
|
return nil if block.nil?
|
41
41
|
return nil if (block.required == false) && [true, false].sample
|
42
42
|
|
43
|
-
fixed_return_value = Type.new(block.type.return_type).pick(size:)
|
43
|
+
fixed_return_value = Type.new(block.type.return_type).pick(size: size)
|
44
44
|
Proc.new { fixed_return_value }
|
45
45
|
end
|
46
46
|
|
data/lib/raap/minitest.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'minitest'
|
2
4
|
|
3
5
|
module RaaP
|
@@ -11,7 +13,7 @@ module RaaP
|
|
11
13
|
method_type = RaaP::MethodType.new(type)
|
12
14
|
size_step.each do |size|
|
13
15
|
# TODO assert_send_type
|
14
|
-
args, kwargs, _block = method_type.pick_arguments(size:)
|
16
|
+
args, kwargs, _block = method_type.pick_arguments(size: size)
|
15
17
|
return_value = yield(*args, **kwargs)
|
16
18
|
i = BindCall.inspect(return_value)
|
17
19
|
c = BindCall.class(return_value)
|
@@ -28,7 +30,7 @@ module RaaP
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
size_step.each do |size|
|
31
|
-
values = types.map { |t| t.pick(size:) }
|
33
|
+
values = types.map { |t| t.pick(size: size) }
|
32
34
|
assert yield(*values)
|
33
35
|
end
|
34
36
|
end
|
data/lib/raap/symbolic_caller.rb
CHANGED
data/lib/raap/type.rb
CHANGED
@@ -39,10 +39,34 @@ module RaaP
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def self.call_new_from(base, type, size:)
|
43
|
+
type_name = type.name.absolute!
|
44
|
+
definition = RBS.builder.build_singleton(type_name)
|
45
|
+
snew = definition.methods[:new]
|
46
|
+
if snew
|
47
|
+
# class
|
48
|
+
rbs_method_type = snew.method_types.sample or raise
|
49
|
+
type_params = definition.type_params_decl.concat(rbs_method_type.type_params.drop(definition.type_params_decl.length))
|
50
|
+
ts = TypeSubstitution.new(type_params, type.args)
|
51
|
+
maped_rbs_method_type = ts.method_type_sub(rbs_method_type)
|
52
|
+
method_type = MethodType.new(maped_rbs_method_type)
|
53
|
+
|
54
|
+
begin
|
55
|
+
args, kwargs, block = method_type.arguments_to_symbolic_call(size: size)
|
56
|
+
[:call, base, :new, args, kwargs, block]
|
57
|
+
rescue
|
58
|
+
$stderr.puts "Fail with `#{rbs_method_type}`"
|
59
|
+
raise
|
60
|
+
end
|
61
|
+
else
|
62
|
+
[:call, Value::Module, :new, [type.to_s], { size: size }, nil]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
42
66
|
# Special class case
|
43
67
|
register("::Array") do
|
44
68
|
instance = __skip__ = type
|
45
|
-
t = instance.args[0] ? Type.new(instance.args[0], range:) : Type.random
|
69
|
+
t = instance.args[0] ? Type.new(instance.args[0], range: range) : Type.random
|
46
70
|
array(t)
|
47
71
|
end
|
48
72
|
register("::Binding") { sized { binding } }
|
@@ -63,7 +87,7 @@ module RaaP
|
|
63
87
|
register("::NilClass") { sized { nil } }
|
64
88
|
register("::Proc") { sized { Proc.new {} } }
|
65
89
|
register("::Rational") { rational }
|
66
|
-
register("::Regexp") { sized { |size| Regexp.new(string.pick(size:)) } }
|
90
|
+
register("::Regexp") { sized { |size| Regexp.new(string.pick(size: size)) } }
|
67
91
|
register("::String") { string }
|
68
92
|
register("::Struct") { sized { Struct.new(:foo, :bar).new } }
|
69
93
|
register("::Symbol") { symbol }
|
@@ -94,11 +118,11 @@ module RaaP
|
|
94
118
|
end
|
95
119
|
|
96
120
|
def pick(size: 10)
|
97
|
-
to_symbolic_caller(size:).eval
|
121
|
+
to_symbolic_caller(size: size).eval
|
98
122
|
end
|
99
123
|
|
100
124
|
def to_symbolic_caller(size: 10)
|
101
|
-
SymbolicCaller.new(to_symbolic_call(size:))
|
125
|
+
SymbolicCaller.new(to_symbolic_call(size: size))
|
102
126
|
end
|
103
127
|
|
104
128
|
def to_symbolic_call(size: 10)
|
@@ -107,20 +131,20 @@ module RaaP
|
|
107
131
|
|
108
132
|
case type
|
109
133
|
when ::RBS::Types::Tuple
|
110
|
-
type.types.map { |t| Type.new(t).to_symbolic_call(size:) }
|
134
|
+
type.types.map { |t| Type.new(t).to_symbolic_call(size: size) }
|
111
135
|
when ::RBS::Types::Union
|
112
|
-
type.types.sample&.then { |t| Type.new(t).to_symbolic_call(size:) }
|
136
|
+
type.types.sample&.then { |t| Type.new(t).to_symbolic_call(size: size) }
|
113
137
|
when ::RBS::Types::Intersection
|
114
138
|
if type.free_variables.empty?
|
115
|
-
[:call, Value::Intersection, :new, [type.to_s], { size: }, nil]
|
139
|
+
[:call, Value::Intersection, :new, [type.to_s], { size: size }, nil]
|
116
140
|
else
|
117
|
-
[:call, Value::Intersection, :new, [type], { size: }, nil]
|
141
|
+
[:call, Value::Intersection, :new, [type], { size: size }, nil]
|
118
142
|
end
|
119
143
|
when ::RBS::Types::Interface
|
120
144
|
if type.free_variables.empty?
|
121
|
-
[:call, Value::Interface, :new, [type.to_s], { size: }, nil]
|
145
|
+
[:call, Value::Interface, :new, [type.to_s], { size: size }, nil]
|
122
146
|
else
|
123
|
-
[:call, Value::Interface, :new, [type], { size: }, nil]
|
147
|
+
[:call, Value::Interface, :new, [type], { size: size }, nil]
|
124
148
|
end
|
125
149
|
when ::RBS::Types::Variable
|
126
150
|
[:call, Value::Variable, :new, [type.to_s], {}, nil]
|
@@ -138,31 +162,33 @@ module RaaP
|
|
138
162
|
when ::RBS::Types::Alias
|
139
163
|
case gen = GENERATORS[type.name.absolute!.to_s]
|
140
164
|
in Proc then instance_exec(&gen)
|
141
|
-
in nil then Type.new(RBS.builder.expand_alias2(type.name, type.args)).to_symbolic_call(size:)
|
165
|
+
in nil then Type.new(RBS.builder.expand_alias2(type.name, type.args)).to_symbolic_call(size: size)
|
142
166
|
end
|
143
167
|
when ::RBS::Types::Bases::Class
|
144
|
-
|
168
|
+
RaaP.logger.warn("Unresolved `class` type, use Object instead.")
|
169
|
+
Object
|
145
170
|
when ::RBS::Types::Bases::Instance
|
146
|
-
|
171
|
+
RaaP.logger.warn("Unresolved `instance` type, use Object.new instead.")
|
172
|
+
Object.new
|
147
173
|
when ::RBS::Types::Bases::Self
|
148
174
|
raise "cannot resolve `self` type"
|
149
175
|
when ::RBS::Types::ClassSingleton
|
150
176
|
Object.const_get(type.name.to_s)
|
151
177
|
when ::RBS::Types::ClassInstance
|
152
178
|
case gen = GENERATORS[type.name.absolute!.to_s]
|
153
|
-
in Proc then instance_exec(&gen).pick(size:)
|
154
|
-
in nil then to_symbolic_call_from_initialize(type, size:)
|
179
|
+
in Proc then instance_exec(&gen).pick(size: size)
|
180
|
+
in nil then to_symbolic_call_from_initialize(type, size: size)
|
155
181
|
end
|
156
182
|
when ::RBS::Types::Record
|
157
183
|
type.fields.transform_values { |t| Type.new(t).to_symbolic_call(size: size / 2) }
|
158
184
|
when ::RBS::Types::Proc
|
159
|
-
Proc.new { Type.new(type.type.return_type).to_symbolic_call(size:) }
|
185
|
+
Proc.new { Type.new(type.type.return_type).to_symbolic_call(size: size) }
|
160
186
|
when ::RBS::Types::Literal
|
161
187
|
type.literal
|
162
188
|
when ::RBS::Types::Bases::Bool
|
163
|
-
bool.pick(size:)
|
189
|
+
bool.pick(size: size)
|
164
190
|
when ::RBS::Types::Bases::Any
|
165
|
-
Type.random.to_symbolic_call(size:)
|
191
|
+
Type.random.to_symbolic_call(size: size)
|
166
192
|
when ::RBS::Types::Bases::Nil
|
167
193
|
nil
|
168
194
|
else
|
@@ -175,28 +201,7 @@ module RaaP
|
|
175
201
|
def to_symbolic_call_from_initialize(type, size:)
|
176
202
|
type_name = type.name.absolute!
|
177
203
|
const = Object.const_get(type_name.to_s)
|
178
|
-
|
179
|
-
snew = definition.methods[:new]
|
180
|
-
if snew
|
181
|
-
# class
|
182
|
-
rbs_method_type = snew.method_types.sample or raise
|
183
|
-
type_params = definition.type_params_decl.concat(rbs_method_type.type_params.drop(definition.type_params_decl.length))
|
184
|
-
ts = TypeSubstitution.new(type_params, type.args)
|
185
|
-
maped_rbs_method_type = ts.method_type_sub(rbs_method_type)
|
186
|
-
method_type = MethodType.new(maped_rbs_method_type)
|
187
|
-
|
188
|
-
begin
|
189
|
-
try(times: 5, size:) do |size|
|
190
|
-
args, kwargs, block = method_type.arguments_to_symbolic_call(size:)
|
191
|
-
[:call, const, :new, args, kwargs, block]
|
192
|
-
end
|
193
|
-
rescue
|
194
|
-
$stderr.puts "Fail with `#{rbs_method_type}`"
|
195
|
-
raise
|
196
|
-
end
|
197
|
-
else
|
198
|
-
[:call, Value::Module, :new, [type.to_s], { size: }, nil]
|
199
|
-
end
|
204
|
+
Type.call_new_from(const, type, size: size)
|
200
205
|
end
|
201
206
|
|
202
207
|
def parse(type)
|
@@ -210,33 +215,8 @@ module RaaP
|
|
210
215
|
end
|
211
216
|
end
|
212
217
|
|
213
|
-
def try(times:, size:)
|
214
|
-
# @type var error: Exception?
|
215
|
-
ret = error = nil
|
216
|
-
times.times do
|
217
|
-
ret = yield size
|
218
|
-
if ret
|
219
|
-
error = nil
|
220
|
-
break
|
221
|
-
end
|
222
|
-
rescue => e
|
223
|
-
size += 1
|
224
|
-
error = e
|
225
|
-
next
|
226
|
-
end
|
227
|
-
|
228
|
-
if error
|
229
|
-
$stderr.puts
|
230
|
-
$stderr.puts "=== Catch error when generating type `#{type}`. Please check your RBS or RaaP bug. ==="
|
231
|
-
$stderr.puts "(#{error.class}) #{error.message}"
|
232
|
-
raise error
|
233
|
-
end
|
234
|
-
|
235
|
-
ret
|
236
|
-
end
|
237
|
-
|
238
218
|
def integer
|
239
|
-
sized { |size| float.pick(size:).round }
|
219
|
+
sized { |size| float.pick(size: size).round }
|
240
220
|
end
|
241
221
|
|
242
222
|
def none_zero_integer
|
@@ -260,16 +240,16 @@ module RaaP
|
|
260
240
|
|
261
241
|
def rational
|
262
242
|
sized do |size|
|
263
|
-
a = integer.pick(size:)
|
264
|
-
b = none_zero_integer.pick(size:)
|
243
|
+
a = integer.pick(size: size)
|
244
|
+
b = none_zero_integer.pick(size: size)
|
265
245
|
[:call, Kernel, :Rational, [a, b], {}, nil]
|
266
246
|
end
|
267
247
|
end
|
268
248
|
|
269
249
|
def complex
|
270
250
|
sized do |size|
|
271
|
-
a = integer.pick(size:)
|
272
|
-
b = none_zero_integer.pick(size:)
|
251
|
+
a = integer.pick(size: size)
|
252
|
+
b = none_zero_integer.pick(size: size)
|
273
253
|
[:call, Kernel, :Complex, [a, b], {}, nil]
|
274
254
|
end
|
275
255
|
end
|
@@ -294,13 +274,13 @@ module RaaP
|
|
294
274
|
|
295
275
|
def symbol
|
296
276
|
sized do |size|
|
297
|
-
string.pick(size:).to_sym
|
277
|
+
string.pick(size: size).to_sym
|
298
278
|
end
|
299
279
|
end
|
300
280
|
|
301
281
|
def array(type)
|
302
282
|
sized do |size|
|
303
|
-
Array.new(integer.pick(size:).abs) do
|
283
|
+
Array.new(integer.pick(size: size).abs) do
|
304
284
|
type.to_symbolic_call(size: size / 2)
|
305
285
|
end
|
306
286
|
end
|
@@ -311,7 +291,7 @@ module RaaP
|
|
311
291
|
def dict(key_type, value_type)
|
312
292
|
sized do |size|
|
313
293
|
csize = size / 2
|
314
|
-
Array.new(integer.pick(size:).abs).to_h do
|
294
|
+
Array.new(integer.pick(size: size).abs).to_h do
|
315
295
|
[
|
316
296
|
key_type.to_symbolic_call(size: csize),
|
317
297
|
value_type.to_symbolic_call(size: csize)
|
@@ -21,11 +21,14 @@ module RaaP
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def method_type_sub(method_type, self_type: nil, instance_type: nil, class_type: nil)
|
24
|
+
self_type = self_type.is_a?(::String) ? RBS.parse_type(self_type) : self_type
|
25
|
+
instance_type = instance_type.is_a?(::String) ? RBS.parse_type(instance_type) : instance_type
|
26
|
+
class_type = class_type.is_a?(::String) ? RBS.parse_type(class_type) : class_type
|
24
27
|
sub = build
|
25
28
|
::RBS::MethodType.new(
|
26
29
|
type_params: [],
|
27
|
-
type: method_type.type.sub(sub).then { |ty| sub(ty, self_type
|
28
|
-
block: method_type.block&.sub(sub)&.then { |bl| sub(bl, self_type
|
30
|
+
type: method_type.type.sub(sub).then { |ty| sub(ty, self_type: self_type, instance_type: instance_type, class_type: class_type) },
|
31
|
+
block: method_type.block&.sub(sub)&.then { |bl| sub(bl, self_type: self_type, instance_type: instance_type, class_type: class_type) },
|
29
32
|
location: method_type.location
|
30
33
|
)
|
31
34
|
end
|
@@ -46,7 +49,7 @@ module RaaP
|
|
46
49
|
when ::RBS::Types::Bases::Class
|
47
50
|
class_type || ty
|
48
51
|
else
|
49
|
-
sub(ty, self_type
|
52
|
+
sub(ty, self_type: self_type, instance_type: instance_type, class_type: class_type)
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
data/lib/raap/value/bottom.rb
CHANGED
data/lib/raap/value/interface.rb
CHANGED
@@ -3,43 +3,69 @@
|
|
3
3
|
module RaaP
|
4
4
|
module Value
|
5
5
|
class Interface < BasicObject
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
class << self
|
7
|
+
def define_method_from_interface(base_class, type, size: 3)
|
8
|
+
type = type.is_a?(::String) ? RBS.parse_type(type) : type
|
9
|
+
unless type.instance_of?(::RBS::Types::Interface)
|
10
|
+
::Kernel.raise ::TypeError, "not an interface type: #{type}"
|
11
|
+
end
|
12
|
+
self_type = type
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
14
|
+
# Referring to Steep
|
15
|
+
instance_type = ::RBS::Types::ClassInstance.new(name: TypeName("::Object"), args: [], location: nil)
|
16
|
+
class_type = ::RBS::Types::ClassSingleton.new(name: TypeName("::Object"), location: nil)
|
17
|
+
|
18
|
+
definition = RBS.builder.build_interface(type.name.absolute!)
|
19
|
+
definition.methods.each do |name, method|
|
20
|
+
method_type = method.method_types.sample or ::Kernel.raise
|
21
|
+
type_params = definition.type_params_decl.concat(method_type.type_params.drop(definition.type_params_decl.length))
|
22
|
+
ts = TypeSubstitution.new(type_params, type.args)
|
23
|
+
subed_method_type = ts.method_type_sub(method_type, self_type: self_type, instance_type: instance_type, class_type: class_type)
|
24
|
+
|
25
|
+
BindCall.define_method(base_class, name) do |*_, &b|
|
26
|
+
@fixed_return_value ||= {}
|
27
|
+
@fixed_return_value[name] ||= if self_type == subed_method_type.type.return_type
|
28
|
+
self
|
29
|
+
else
|
30
|
+
Type.new(subed_method_type.type.return_type).pick(size: size)
|
31
|
+
end
|
32
|
+
# @type var b: Proc?
|
33
|
+
if b
|
34
|
+
@fixed_block_arguments ||= {}
|
35
|
+
@fixed_block_arguments[name] ||= if subed_method_type.block
|
36
|
+
size.times.map do
|
37
|
+
FunctionType.new(subed_method_type.block.type)
|
38
|
+
.pick_arguments(size: size)
|
39
|
+
end
|
40
|
+
else
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
@fixed_block_arguments[name].each do |a, kw|
|
44
|
+
b.call(*a, **kw)
|
45
|
+
end
|
38
46
|
end
|
47
|
+
@fixed_return_value[name]
|
39
48
|
end
|
40
|
-
@fixed_return_value
|
41
49
|
end
|
42
50
|
end
|
51
|
+
|
52
|
+
def new(type, size: 3)
|
53
|
+
temp_class = ::Class.new(Interface) do |c|
|
54
|
+
define_method_from_interface(c, type, size: size)
|
55
|
+
end
|
56
|
+
instance = temp_class.allocate
|
57
|
+
instance.__send__(:initialize, type, size: size)
|
58
|
+
instance
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def initialize(type, size: 3)
|
63
|
+
@type = type.is_a?(::String) ? RBS.parse_type(type) : type
|
64
|
+
unless @type.instance_of?(::RBS::Types::Interface)
|
65
|
+
::Kernel.raise ::TypeError, "not an interface type: #{type}"
|
66
|
+
end
|
67
|
+
@definition = RBS.builder.build_interface(@type.name.absolute!)
|
68
|
+
@size = size
|
43
69
|
end
|
44
70
|
|
45
71
|
def respond_to?(name, _include_all = false)
|
@@ -51,7 +77,7 @@ module RaaP
|
|
51
77
|
end
|
52
78
|
|
53
79
|
def inspect
|
54
|
-
"#<interface @type
|
80
|
+
"#<interface @type=`#{@type}` @methods=#{@definition.methods.keys} @size=#{@size}>"
|
55
81
|
end
|
56
82
|
end
|
57
83
|
end
|
@@ -2,45 +2,38 @@
|
|
2
2
|
|
3
3
|
module RaaP
|
4
4
|
module Value
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module Intersection
|
6
|
+
# Build an object to realize an intersection.
|
7
|
+
def self.new(type, size: 3)
|
8
|
+
type = type.is_a?(::String) ? RBS.parse_type(type) : type
|
9
|
+
unless type.instance_of?(::RBS::Types::Intersection)
|
10
|
+
::Kernel.raise ::TypeError, "not an intersection type: #{type}"
|
11
|
+
end
|
12
|
+
instances = type.types.filter_map do |t|
|
13
|
+
t.instance_of?(::RBS::Types::ClassInstance) && Object.const_get(t.name.absolute!.to_s)
|
14
|
+
end
|
15
|
+
instances.uniq!
|
16
|
+
unless instances.count { |c| c.is_a?(::Class) } <= 1
|
17
|
+
raise ArgumentError, "intersection type must have at least one class instance type in `#{instances}`"
|
10
18
|
end
|
11
|
-
@children = @type.types.map { |t| Type.new(t).pick(size:) }
|
12
|
-
@size = size
|
13
|
-
end
|
14
19
|
|
15
|
-
|
16
|
-
"#<intersection @type.to_s=#{@type.to_s.inspect} @size=#{@size.inspect}>"
|
17
|
-
end
|
20
|
+
base = instances.find { |c| c.is_a?(::Class) } || BasicObject
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
c = Class.new(base) do
|
23
|
+
instances.select { |i| !i.is_a?(::Class) }.each do |m|
|
24
|
+
include(m)
|
25
|
+
end
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
@children.each do |child|
|
26
|
-
if BindCall.respond_to?(child, name)
|
27
|
-
return child.__send__(name, *args, **kwargs, &block)
|
28
|
-
end
|
27
|
+
interfaces = type.types.select do |t|
|
28
|
+
t.instance_of?(::RBS::Types::Interface)
|
29
29
|
end
|
30
|
-
::Kernel.raise
|
31
|
-
else
|
32
|
-
super
|
33
|
-
end
|
34
|
-
end
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
if BindCall.instance_of?(child, ::BasicObject)
|
39
|
-
BindCall.respond_to?(child, name, include_all)
|
40
|
-
else
|
41
|
-
child.respond_to?(name, include_all)
|
31
|
+
interfaces.each do |interface|
|
32
|
+
Interface.define_method_from_interface(self, interface, size: size)
|
42
33
|
end
|
43
34
|
end
|
35
|
+
type = ::RBS::Types::ClassInstance.new(name: TypeName(base.name), args: [], location: nil)
|
36
|
+
SymbolicCaller.new(Type.call_new_from(c, type, size: size)).eval
|
44
37
|
end
|
45
38
|
end
|
46
39
|
end
|
data/lib/raap/value/module.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RaaP
|
2
4
|
module Value
|
3
5
|
# FIXME: consider self_types
|
@@ -30,12 +32,14 @@ module RaaP
|
|
30
32
|
"#{a_instance.name}[#{args.map(&:to_s).join(', ')}]"
|
31
33
|
end
|
32
34
|
end.then do |ts|
|
33
|
-
|
34
|
-
|
35
|
+
if !ts.include?('::BasicObject') || ts.any? { |t| t.split('::').last&.start_with?('_') }
|
36
|
+
ts.unshift('Object')
|
37
|
+
end
|
38
|
+
Type.new(ts.uniq.join(' & ')).pick(size: size)
|
35
39
|
end
|
36
40
|
end
|
37
41
|
const = ::Object.const_get(@type.name.absolute!.to_s)
|
38
|
-
BindCall.extend(
|
42
|
+
BindCall.extend(self, const)
|
39
43
|
end
|
40
44
|
|
41
45
|
def method_missing(name, *args, **kwargs, &block)
|
data/lib/raap/value/top.rb
CHANGED
data/lib/raap/value/variable.rb
CHANGED
data/lib/raap/value/void.rb
CHANGED
data/lib/raap/version.rb
CHANGED
data/lib/raap.rb
CHANGED
data/lib/shims.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Ruby 3.2
|
4
|
+
unless Exception.method_defined?(:detailed_message)
|
5
|
+
class Exception
|
6
|
+
alias detailed_message message
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Ruby 3.2
|
11
|
+
unless defined?(Data)
|
12
|
+
class Data
|
13
|
+
class << self
|
14
|
+
def define(*syms)
|
15
|
+
_ = Class.new do |c|
|
16
|
+
define_method(:initialize) do |*args, **kwargs|
|
17
|
+
if !args.empty?
|
18
|
+
syms.zip(args).each do |sym, arg|
|
19
|
+
instance_variable_set("@#{sym}", arg)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
if !kwargs.empty?
|
23
|
+
kwargs.each do |k, v|
|
24
|
+
instance_variable_set("@#{k}", v)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
syms.each do |sym|
|
30
|
+
c.define_method(sym) do
|
31
|
+
instance_variable_get("@#{sym}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/rbs_collection.lock.yaml
CHANGED
@@ -10,7 +10,7 @@ gems:
|
|
10
10
|
source:
|
11
11
|
type: git
|
12
12
|
name: ruby/gem_rbs_collection
|
13
|
-
revision:
|
13
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
14
14
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
15
15
|
repo_dir: gems
|
16
16
|
- name: base64
|
@@ -26,7 +26,7 @@ gems:
|
|
26
26
|
source:
|
27
27
|
type: git
|
28
28
|
name: ruby/gem_rbs_collection
|
29
|
-
revision:
|
29
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
30
30
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
31
31
|
repo_dir: gems
|
32
32
|
- name: connection_pool
|
@@ -34,7 +34,7 @@ gems:
|
|
34
34
|
source:
|
35
35
|
type: git
|
36
36
|
name: ruby/gem_rbs_collection
|
37
|
-
revision:
|
37
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
38
38
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
39
39
|
repo_dir: gems
|
40
40
|
- name: date
|
@@ -54,7 +54,7 @@ gems:
|
|
54
54
|
source:
|
55
55
|
type: git
|
56
56
|
name: ruby/gem_rbs_collection
|
57
|
-
revision:
|
57
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
58
58
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
59
59
|
repo_dir: gems
|
60
60
|
- name: io-console
|
@@ -94,7 +94,7 @@ gems:
|
|
94
94
|
source:
|
95
95
|
type: git
|
96
96
|
name: ruby/gem_rbs_collection
|
97
|
-
revision:
|
97
|
+
revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
|
98
98
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
99
99
|
repo_dir: gems
|
100
100
|
- name: rbs
|
data/sig/raap.rbs
CHANGED
@@ -6,7 +6,7 @@ module RaaP
|
|
6
6
|
def self.logger=: (::Logger) -> void
|
7
7
|
|
8
8
|
module BindCall
|
9
|
-
def self.
|
9
|
+
def self.define_method: (untyped, Symbol) { (*untyped, **untyped) -> untyped } -> void
|
10
10
|
def self.respond_to?: (untyped, untyped, ?boolish) -> bool
|
11
11
|
def self.instance_of?: (untyped, Module) -> bool
|
12
12
|
def self.is_a?: (untyped, Module) -> bool
|
@@ -19,15 +19,15 @@ module RaaP
|
|
19
19
|
|
20
20
|
class CLI
|
21
21
|
class Option < ::Struct[untyped]
|
22
|
-
def self.new: (?dirs: ::Array[String], ?requires: ::Array[String], ?libraries: ::Array[String], ?timeout: (Integer | Float | nil), ?size_from: ::Integer, ?size_to: ::Integer, ?size_by: ::Integer, ?allow_private: bool
|
22
|
+
def self.new: (?dirs: ::Array[String], ?requires: ::Array[String], ?libraries: ::Array[String], ?timeout: (Integer | Float | nil), ?size_from: ::Integer, ?size_to: ::Integer, ?size_by: ::Integer, ?allow_private: bool) -> instance
|
23
23
|
|
24
|
-
def self.[]: (?dirs: ::Array[String], ?requires: ::Array[String], ?libraries: ::Array[String], ?timeout: (Integer | Float | nil), ?size_from: ::Integer, ?size_to: ::Integer, ?size_by: ::Integer, ?allow_private: bool
|
24
|
+
def self.[]: (?dirs: ::Array[String], ?requires: ::Array[String], ?libraries: ::Array[String], ?timeout: (Integer | Float | nil), ?size_from: ::Integer, ?size_to: ::Integer, ?size_by: ::Integer, ?allow_private: bool) -> instance
|
25
25
|
|
26
26
|
def self.keyword_init?: () -> true
|
27
27
|
|
28
|
-
def self.members: () -> [ :dirs, :requires, :library, :timeout, :size_from, :size_to, :size_by, :allow_private
|
28
|
+
def self.members: () -> [ :dirs, :requires, :library, :timeout, :size_from, :size_to, :size_by, :allow_private]
|
29
29
|
|
30
|
-
def members: () -> [ :dirs, :requires, :library, :timeout, :size_from, :size_to, :size_by, :allow_private
|
30
|
+
def members: () -> [ :dirs, :requires, :library, :timeout, :size_from, :size_to, :size_by, :allow_private]
|
31
31
|
|
32
32
|
attr_accessor dirs: ::Array[String]
|
33
33
|
|
@@ -44,8 +44,6 @@ module RaaP
|
|
44
44
|
attr_accessor size_by: ::Integer
|
45
45
|
|
46
46
|
attr_accessor allow_private: bool
|
47
|
-
|
48
|
-
attr_accessor skips: ::Array[String]
|
49
47
|
end
|
50
48
|
|
51
49
|
type property_result = [Integer, Symbol, ::RBS::MethodType, StringIO?]
|
@@ -53,7 +51,9 @@ module RaaP
|
|
53
51
|
DEFAULT_SKIP: ::Set[String]
|
54
52
|
|
55
53
|
@argv: Array[String]
|
54
|
+
@option: Option
|
56
55
|
@results: Array[{ method: ::RBS::Definition::Method, properties: Array[property_result] }]
|
56
|
+
@skip: ::Set[::String]
|
57
57
|
|
58
58
|
def self.option: () -> Option
|
59
59
|
def self.option=: (Option) -> void
|
@@ -220,7 +220,7 @@ module RaaP
|
|
220
220
|
|
221
221
|
def initialize: (::Array[::RBS::AST::TypeParam], ::Array[::RBS::Types::t]) -> void
|
222
222
|
def build: () -> ::RBS::Substitution
|
223
|
-
def method_type_sub: (::RBS::MethodType, ?self_type: ::RBS::Types::
|
223
|
+
def method_type_sub: (::RBS::MethodType, ?self_type: ::RBS::Types::t?, ?instance_type: ::RBS::Types::ClassInstance?, ?class_type: ::RBS::Types::ClassSingleton?) -> ::RBS::MethodType
|
224
224
|
|
225
225
|
private
|
226
226
|
|
@@ -228,7 +228,7 @@ module RaaP
|
|
228
228
|
def map_type: { (untyped) -> untyped } -> untyped
|
229
229
|
end
|
230
230
|
|
231
|
-
def sub: (_MapType search, self_type: ::RBS::Types::
|
231
|
+
def sub: (_MapType search, self_type: ::RBS::Types::t?, instance_type: ::RBS::Types::t?, class_type: ::RBS::Types::t?) -> untyped
|
232
232
|
end
|
233
233
|
|
234
234
|
class Type
|
@@ -245,6 +245,7 @@ module RaaP
|
|
245
245
|
def self.register: (String) { () [self: instance] -> Sized[untyped] } -> void
|
246
246
|
def self.random: () -> Type
|
247
247
|
def self.random_without_basic_object: () -> Type
|
248
|
+
def self.call_new_from: (Module, ::RBS::Types::ClassInstance, size: Integer) -> symbolic_call
|
248
249
|
|
249
250
|
attr_reader type: ::RBS::Types::t
|
250
251
|
attr_reader range: Range[untyped]
|
@@ -292,9 +293,8 @@ module RaaP
|
|
292
293
|
@type: ::RBS::Types::Interface
|
293
294
|
@size: Integer
|
294
295
|
@definition: ::RBS::Definition
|
295
|
-
@fixed_return_value: untyped
|
296
|
-
@fixed_block_arguments: Array[untyped]
|
297
296
|
|
297
|
+
def self.define_method_from_interface: (Class base_class, String | ::RBS::Types::Interface type, ?size: Integer) -> void
|
298
298
|
def initialize: (String | ::RBS::Types::Interface | String, ?size: Integer) -> void
|
299
299
|
def respond_to?: (Symbol, ?boolish) -> bool
|
300
300
|
def inspect: () -> String
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/raap/value/variable.rb
|
77
77
|
- lib/raap/value/void.rb
|
78
78
|
- lib/raap/version.rb
|
79
|
+
- lib/shims.rb
|
79
80
|
- public/jacket.webp
|
80
81
|
- rbs_collection.lock.yaml
|
81
82
|
- rbs_collection.yaml
|
@@ -94,14 +95,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
95
|
requirements:
|
95
96
|
- - ">="
|
96
97
|
- !ruby/object:Gem::Version
|
97
|
-
version: 3.
|
98
|
+
version: 3.0.0
|
98
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
100
|
requirements:
|
100
101
|
- - ">="
|
101
102
|
- !ruby/object:Gem::Version
|
102
103
|
version: '0'
|
103
104
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
105
|
+
rubygems_version: 3.2.33
|
105
106
|
signing_key:
|
106
107
|
specification_version: 4
|
107
108
|
summary: RBS as a Property
|