raap 0.4.0 → 0.5.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 +2 -0
- data/README.md +21 -3
- data/exe/raap +1 -0
- data/lib/raap/bind_call.rb +3 -1
- data/lib/raap/cli.rb +36 -20
- data/lib/raap/method_property.rb +1 -1
- data/lib/raap/minitest.rb +2 -0
- data/lib/raap/type.rb +29 -49
- data/lib/raap/type_substitution.rb +3 -0
- 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/sig/raap.rbs +11 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94f0ec4ff924c5089f8e307002dd5f3cd778f04e686acd8b46466139c3c1aebd
|
4
|
+
data.tar.gz: e9a06fb3c71cfc6cd605031fe8cb899a123dc82a94ef00586d39e8329c45beac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed0d647fefa8591c0a03981232c84d64bf7c70bcf9207d2dd6471a9f3369747b5dd3adcc3cd60a8e1d65f0e1543ed7a5f5108eef6523c7d306cfc399d0bc63e4
|
7
|
+
data.tar.gz: 537c5dfbb65bb12064e46c47fb75a60321ee0f16296f1272ef27d68927f4f9f3d5875ea6f3ac2225c76a2d274fbe393bff20f573b8d138b52a6ced8027528e1f
|
data/.rubocop.yml
CHANGED
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,6 +70,15 @@ $ 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 method MyClass without #skip
|
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
|
73
82
|
```
|
74
83
|
|
75
84
|
## Size
|
@@ -103,11 +112,15 @@ You can specify to load specify PATH as RBS.
|
|
103
112
|
|
104
113
|
### `--library lib`
|
105
114
|
|
106
|
-
You can specify to load RBS library
|
115
|
+
You can specify to load RBS library.
|
107
116
|
|
108
117
|
### `--require lib`
|
109
118
|
|
110
|
-
You can specify require Ruby library
|
119
|
+
You can specify require Ruby library.
|
120
|
+
|
121
|
+
### `--log-level level`
|
122
|
+
|
123
|
+
You can specify log level (debug, info, warn or error).
|
111
124
|
|
112
125
|
### `--timeout sec`
|
113
126
|
|
@@ -125,6 +138,11 @@ You can specify size of end.
|
|
125
138
|
|
126
139
|
You can specify size of step like `Integer#step: (to: Integer, by: Integer)`.
|
127
140
|
|
141
|
+
### `--allow-private`
|
142
|
+
|
143
|
+
By default, raap only validates public methods.
|
144
|
+
However, by setting this option, it is possible to intentionally validate private methods in the RBS.
|
145
|
+
|
128
146
|
## First support is CLI
|
129
147
|
|
130
148
|
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/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,7 +102,20 @@ 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?('!') && (tag.include?('#') || tag.include?('.'))
|
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
121
|
run_by(kind: :instance, tag:)
|
@@ -204,7 +208,11 @@ module RaaP
|
|
204
208
|
def run_by_type_name_with_search(tag:)
|
205
209
|
first, _last = tag.split('::')
|
206
210
|
RBS.env.class_decls.each do |name, _entry|
|
207
|
-
if ['', '::'].any? { |pre| name.to_s.
|
211
|
+
if ['', '::'].any? { |pre| name.to_s.start_with?("#{pre}#{first}") }
|
212
|
+
if @skip.include?(name.to_s)
|
213
|
+
RaaP.logger.info("Skip #{name}")
|
214
|
+
next
|
215
|
+
end
|
208
216
|
run_by_type_name(tag: name.to_s)
|
209
217
|
end
|
210
218
|
end
|
@@ -220,8 +228,11 @@ module RaaP
|
|
220
228
|
|
221
229
|
definition = RBS.builder.build_singleton(type_name)
|
222
230
|
type_params_decl = definition.type_params_decl
|
223
|
-
definition.methods.
|
224
|
-
|
231
|
+
definition.methods.each do |method_name, method|
|
232
|
+
if @skip.include?("#{type_name.absolute!}.#{method_name}")
|
233
|
+
RaaP.logger.info("Skip #{"#{type_name.absolute!}.#{method_name}"}")
|
234
|
+
next
|
235
|
+
end
|
225
236
|
next unless method.accessibility == :public
|
226
237
|
next if method.defined_in != type_name
|
227
238
|
|
@@ -236,8 +247,11 @@ module RaaP
|
|
236
247
|
|
237
248
|
definition = RBS.builder.build_instance(type_name)
|
238
249
|
type_params_decl = definition.type_params_decl
|
239
|
-
definition.methods.
|
240
|
-
|
250
|
+
definition.methods.each do |method_name, method|
|
251
|
+
if @skip.include?("#{type_name.absolute!}##{method_name}")
|
252
|
+
RaaP.logger.info("Skip #{"#{type_name.absolute!}.#{method_name}"}")
|
253
|
+
next
|
254
|
+
end
|
241
255
|
next unless method.accessibility == :public
|
242
256
|
next if method.defined_in != type_name
|
243
257
|
|
@@ -258,9 +272,11 @@ module RaaP
|
|
258
272
|
else
|
259
273
|
prefix = ''
|
260
274
|
end
|
261
|
-
|
275
|
+
|
276
|
+
# type_args delegate to self_type
|
277
|
+
type_params_decl.each_with_index do |param, i|
|
262
278
|
if rtype.instance_of?(::RBS::Types::ClassInstance)
|
263
|
-
rtype.args[i] = type_args[i] || ::RBS::Types::Bases::Any.new(location: nil)
|
279
|
+
rtype.args[i] = type_args[i] || param.upper_bound || ::RBS::Types::Bases::Any.new(location: nil)
|
264
280
|
end
|
265
281
|
end
|
266
282
|
RaaP.logger.info("## def #{prefix}#{method_name}: #{method_type}")
|
@@ -279,7 +295,7 @@ module RaaP
|
|
279
295
|
),
|
280
296
|
size_step: @option.size_from.step(to: @option.size_to, by: @option.size_by),
|
281
297
|
timeout: @option.timeout,
|
282
|
-
allow_private:
|
298
|
+
allow_private: @option.allow_private,
|
283
299
|
)
|
284
300
|
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
285
301
|
stats = prop.run do |called|
|
@@ -290,7 +306,7 @@ module RaaP
|
|
290
306
|
in Result::Failure => f
|
291
307
|
puts 'F'
|
292
308
|
if (e = f.exception)
|
293
|
-
RaaP.logger.
|
309
|
+
RaaP.logger.info { "Failure: [#{e.class}] #{e.message}" }
|
294
310
|
RaaP.logger.debug { e.backtrace.join("\n") }
|
295
311
|
end
|
296
312
|
RaaP.logger.debug { PP.pp(f.symbolic_call, ''.dup) }
|
data/lib/raap/method_property.rb
CHANGED
@@ -50,7 +50,7 @@ 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
|
data/lib/raap/minitest.rb
CHANGED
data/lib/raap/type.rb
CHANGED
@@ -39,6 +39,30 @@ 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:)
|
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: }, nil]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
42
66
|
# Special class case
|
43
67
|
register("::Array") do
|
44
68
|
instance = __skip__ = type
|
@@ -141,9 +165,11 @@ module RaaP
|
|
141
165
|
in nil then Type.new(RBS.builder.expand_alias2(type.name, type.args)).to_symbolic_call(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
|
@@ -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:)
|
200
205
|
end
|
201
206
|
|
202
207
|
def parse(type)
|
@@ -210,31 +215,6 @@ 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
219
|
sized { |size| float.pick(size:).round }
|
240
220
|
end
|
@@ -21,6 +21,9 @@ 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: [],
|
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:, instance_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:)
|
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:)
|
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:)
|
55
|
+
end
|
56
|
+
instance = temp_class.allocate
|
57
|
+
instance.__send__(:initialize, type, 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:)
|
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:)).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:)
|
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/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.5.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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|