raap 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -4
- data/lib/raap/bind_call.rb +1 -0
- data/lib/raap/cli.rb +22 -8
- data/lib/raap/method_property.rb +22 -20
- data/lib/raap/method_type.rb +13 -0
- data/lib/raap/minitest.rb +35 -0
- data/lib/raap/symbolic_caller.rb +39 -17
- data/lib/raap/type.rb +34 -17
- data/lib/raap/version.rb +1 -1
- data/lib/raap.rb +2 -1
- data/sig/raap.rbs +42 -25
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 272cb44584fb297591d356de0c90ecfbcf782951ed4a02432eb4cd87a6849f0f
|
4
|
+
data.tar.gz: d0776eeeb3f840a1730f16a9df385414e3697631191961b986085773cad49e04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09ace505a4973cac5f075a133fc6e13c8fa34bde72adf522cc095ad3accfccec574b3209aaf4bca8deceb398b5b36f0893672722504895d51413c65877efc167'
|
7
|
+
data.tar.gz: 1fe3eb4b5695bd69b2a30fdd2035a81aa3be1a289dee120f4664f95bb1d6d9a5ab8849f11acb957e8ac97e8dfb174f49536542fc96f29ecfade076e15b76619e
|
data/README.md
CHANGED
@@ -12,17 +12,54 @@ The return value of the method is checked to see if it matches the type, if not,
|
|
12
12
|
|
13
13
|
If you write an RBS, it becomes a test case.
|
14
14
|
|
15
|
-
##
|
15
|
+
## Concept
|
16
|
+
|
17
|
+
If you has next signature.
|
18
|
+
|
19
|
+
```rbs
|
20
|
+
class Foo
|
21
|
+
end
|
22
|
+
|
23
|
+
class Bar
|
24
|
+
def initialize: (foo: Foo) -> void
|
25
|
+
def f2s: (Float) -> String
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
Then, RaaP run next testing code automaticaly.
|
30
|
+
|
31
|
+
```rb
|
32
|
+
describe Bar do
|
33
|
+
let(:foo) { Foo.new }
|
34
|
+
let(:bar) { Bar.new(foo: foo) }
|
16
35
|
|
17
|
-
|
36
|
+
it "#f2s" do
|
37
|
+
100.times do |size|
|
38
|
+
float = Random.rand * size
|
39
|
+
expect(bar.f2s(float)).to be_a(String)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
If you got a failure?
|
46
|
+
|
47
|
+
- Fix RBS
|
48
|
+
- Fix implementation of `Bar#f2s`
|
49
|
+
|
50
|
+
Then, you can start loop again.
|
51
|
+
|
52
|
+
Finally, you get the perfect RBS!
|
53
|
+
|
54
|
+
## Installation
|
18
55
|
|
19
56
|
Install the gem and add to the application's Gemfile by executing:
|
20
57
|
|
21
|
-
$ bundle add
|
58
|
+
$ bundle add raap
|
22
59
|
|
23
60
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
24
61
|
|
25
|
-
$ gem install
|
62
|
+
$ gem install raap
|
26
63
|
|
27
64
|
## Usage
|
28
65
|
|
data/lib/raap/bind_call.rb
CHANGED
@@ -8,6 +8,7 @@ module RaaP
|
|
8
8
|
def extend(...) = ::Kernel.instance_method(:extend).bind_call(...)
|
9
9
|
def name(...) = ::Module.instance_method(:name).bind_call(...)
|
10
10
|
def to_s(...) = ::Kernel.instance_method(:to_s).bind_call(...)
|
11
|
+
def public_send(...) = ::Kernel.instance_method(:public_send).bind_call(...)
|
11
12
|
|
12
13
|
def class(obj)
|
13
14
|
if respond_to?(obj, :class)
|
data/lib/raap/cli.rb
CHANGED
@@ -103,7 +103,11 @@ module RaaP
|
|
103
103
|
|
104
104
|
def run_by_instance(tag:)
|
105
105
|
t, m = tag.split('#', 2)
|
106
|
+
t or raise
|
107
|
+
m or raise
|
106
108
|
type = RBS.parse_type(t)
|
109
|
+
type = __skip__ = type
|
110
|
+
raise "cannot specified #{type}" unless type.respond_to?(:name)
|
107
111
|
receiver_type = Type.new(type.to_s)
|
108
112
|
method_name = m.to_sym
|
109
113
|
definition = RBS.builder.build_instance(type.name)
|
@@ -121,7 +125,11 @@ module RaaP
|
|
121
125
|
|
122
126
|
def run_by_singleton(tag:)
|
123
127
|
t, m = tag.split('.', 2)
|
128
|
+
t or raise
|
129
|
+
m or raise
|
124
130
|
type = RBS.parse_type(t)
|
131
|
+
raise "cannot specified #{type.class}" unless type.respond_to?(:name)
|
132
|
+
type = __skip__ = type
|
125
133
|
receiver_type = Type.new("singleton(#{type.name})")
|
126
134
|
method_name = m.to_sym
|
127
135
|
definition = RBS.builder.build_singleton(type.name)
|
@@ -150,6 +158,8 @@ module RaaP
|
|
150
158
|
|
151
159
|
def run_by_type_name(tag:)
|
152
160
|
type = RBS.parse_type(tag)
|
161
|
+
type = __skip__ = type
|
162
|
+
raise "cannot specified #{type.class}" unless type.respond_to?(:name)
|
153
163
|
type_name = type.name.absolute!
|
154
164
|
|
155
165
|
ret = []
|
@@ -157,6 +167,7 @@ module RaaP
|
|
157
167
|
definition = RBS.builder.build_singleton(type_name)
|
158
168
|
type_params_decl = definition.type_params_decl
|
159
169
|
definition.methods.filter_map do |method_name, method|
|
170
|
+
next unless method.accessibility == :public
|
160
171
|
next if method.defined_in != type_name
|
161
172
|
next if method_name == :fork || method_name == :spawn # TODO: skip solution
|
162
173
|
puts "# #{type_name}.#{method_name}"
|
@@ -169,6 +180,7 @@ module RaaP
|
|
169
180
|
definition = RBS.builder.build_instance(type_name)
|
170
181
|
type_params_decl = definition.type_params_decl
|
171
182
|
definition.methods.filter_map do |method_name, method|
|
183
|
+
next unless method.accessibility == :public
|
172
184
|
next if method.defined_in != type_name
|
173
185
|
next if method_name == :fork || method_name == :spawn # TODO: skip solution
|
174
186
|
puts "# #{type_name}##{method_name}"
|
@@ -182,12 +194,13 @@ module RaaP
|
|
182
194
|
end
|
183
195
|
|
184
196
|
def property(receiver_type:, type_params_decl:, method_type:, method_name:)
|
197
|
+
rtype = __skip__ = receiver_type.type
|
185
198
|
if receiver_type.type.instance_of?(::RBS::Types::ClassSingleton)
|
186
199
|
prefix = 'self.'
|
187
200
|
type_args = []
|
188
201
|
else
|
189
202
|
prefix = ''
|
190
|
-
type_args =
|
203
|
+
type_args = rtype.args
|
191
204
|
end
|
192
205
|
puts "## def #{prefix}#{method_name}: #{method_type}"
|
193
206
|
status = 0
|
@@ -198,23 +211,23 @@ module RaaP
|
|
198
211
|
method_type,
|
199
212
|
type_params_decl:,
|
200
213
|
type_args:,
|
201
|
-
self_type:
|
202
|
-
instance_type: ::RBS::Types::ClassInstance.new(name:
|
203
|
-
class_type: ::RBS::Types::ClassSingleton.new(name:
|
214
|
+
self_type: rtype,
|
215
|
+
instance_type: ::RBS::Types::ClassInstance.new(name: rtype.name, args: type_args, location: nil),
|
216
|
+
class_type: ::RBS::Types::ClassSingleton.new(name: rtype.name, location: nil),
|
204
217
|
),
|
205
218
|
size_step: CLI.option.size_from.step(to: CLI.option.size_to, by: CLI.option.size_by),
|
206
219
|
timeout: CLI.option.timeout,
|
207
220
|
).run do |called|
|
208
221
|
case called
|
209
222
|
in Result::Success => s
|
210
|
-
RaaP.logger.debug { "Success: #{s.called_str}" }
|
211
223
|
print '.'
|
224
|
+
RaaP.logger.debug { "Success: #{s.called_str}" }
|
212
225
|
in Result::Failure => f
|
213
226
|
puts 'F'
|
214
227
|
puts "Failed in case of `#{f.called_str}`"
|
215
228
|
puts
|
216
229
|
RaaP.logger.debug { PP.pp(f.symbolic_call, ''.dup) }
|
217
|
-
puts "
|
230
|
+
puts "### call stack:"
|
218
231
|
puts
|
219
232
|
puts "```"
|
220
233
|
puts SymbolicCaller.new(f.symbolic_call).to_lines.join("\n")
|
@@ -223,10 +236,11 @@ module RaaP
|
|
223
236
|
throw :break
|
224
237
|
in Result::Skip => s
|
225
238
|
print 'S'
|
239
|
+
RaaP::logger.debug("Skip: [#{s.exception.class}] #{s.exception.message}")
|
226
240
|
in Result::Exception => e
|
227
|
-
RaaP.logger.info("#{e.exception.class}: #{e.exception.message}")
|
228
|
-
RaaP.logger.debug(e.exception.backtrace.join("\n"))
|
229
241
|
print 'E'
|
242
|
+
RaaP.logger.info("Exception: [#{e.exception.class}] #{e.exception.message}")
|
243
|
+
RaaP.logger.debug(e.exception.backtrace.join("\n"))
|
230
244
|
end
|
231
245
|
end
|
232
246
|
puts
|
data/lib/raap/method_property.rb
CHANGED
@@ -24,9 +24,6 @@ module RaaP
|
|
24
24
|
|
25
25
|
def run
|
26
26
|
stats = Stats.new
|
27
|
-
if receiver_type.type.to_s == 'String' && method_name == :initialize
|
28
|
-
return stats
|
29
|
-
end
|
30
27
|
begin
|
31
28
|
Timeout.timeout(@timeout) do
|
32
29
|
catch(:break) do
|
@@ -48,24 +45,31 @@ module RaaP
|
|
48
45
|
arguments = method_type.pick_arguments(size: size, eval: false)
|
49
46
|
method_value = MethodValue.new(receiver_value:, arguments:, method_name:, size:)
|
50
47
|
symbolic_call = method_value.to_symbolic_call
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
begin
|
49
|
+
# ensure method_value
|
50
|
+
check = false
|
51
|
+
if return_type.instance_of?(::RBS::Types::Bases::Bottom)
|
52
|
+
begin
|
53
|
+
return_value = SymbolicCaller.new(symbolic_call).eval
|
54
|
+
rescue => e
|
55
|
+
check = true
|
56
|
+
return_value = Value::Bottom.new
|
57
|
+
end
|
58
|
+
else
|
54
59
|
return_value = SymbolicCaller.new(symbolic_call).eval
|
55
|
-
|
56
|
-
check = true
|
57
|
-
return_value = Value::Bottom.new
|
60
|
+
check = check_return(receiver_value:, return_value:, method_type:)
|
58
61
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
else
|
62
|
+
if check
|
63
|
+
stats.success += 1
|
64
|
+
Result::Success.new(method_value:, return_value:)
|
65
|
+
else
|
66
|
+
Result::Failure.new(method_value:, return_value:, symbolic_call:)
|
67
|
+
end
|
68
|
+
rescue TypeError => exception
|
67
69
|
Result::Failure.new(method_value:, return_value:, symbolic_call:)
|
68
70
|
end
|
71
|
+
|
72
|
+
# not ensure method_value
|
69
73
|
rescue NoMethodError => exception
|
70
74
|
stats.skip += 1
|
71
75
|
Result::Skip.new(method_value:, exception:)
|
@@ -80,8 +84,6 @@ module RaaP
|
|
80
84
|
stats.skip += 1
|
81
85
|
RaaP.logger.warn "Found recursive type definition."
|
82
86
|
Result::Skip.new(method_value: nil, exception:)
|
83
|
-
rescue TypeError => exception
|
84
|
-
Result::Failure.new(method_value:, return_value:, symbolic_call:)
|
85
87
|
rescue => exception
|
86
88
|
stats.exception += 1
|
87
89
|
Result::Exception.new(method_value:, exception:)
|
@@ -104,7 +106,7 @@ module RaaP
|
|
104
106
|
instance_class: instance_class,
|
105
107
|
class_class: Module,
|
106
108
|
builder: RBS.builder,
|
107
|
-
sample_size:
|
109
|
+
sample_size: 100,
|
108
110
|
unchecked_classes: []
|
109
111
|
)
|
110
112
|
begin
|
data/lib/raap/method_type.rb
CHANGED
@@ -36,5 +36,18 @@ module RaaP
|
|
36
36
|
|
37
37
|
Proc.new { Type.new(block.type.return_type).pick(size:, eval:) }
|
38
38
|
end
|
39
|
+
|
40
|
+
def check_return(return_value)
|
41
|
+
untyped = __skip__ = nil
|
42
|
+
type_check = ::RBS::Test::TypeCheck.new(
|
43
|
+
self_class: untyped, # cannot support `self`
|
44
|
+
instance_class: untyped, # cannot support `instance`
|
45
|
+
class_class: untyped, # cannot support `class`
|
46
|
+
builder: RBS.builder,
|
47
|
+
sample_size: 100,
|
48
|
+
unchecked_classes: []
|
49
|
+
)
|
50
|
+
type_check.value(return_value, rbs.type.return_type)
|
51
|
+
end
|
39
52
|
end
|
40
53
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'minitest'
|
2
|
+
|
3
|
+
module RaaP
|
4
|
+
module Minitest
|
5
|
+
def forall(*types, size_step: 0...100)
|
6
|
+
# @type self: Minitest::Test
|
7
|
+
|
8
|
+
if types.length == 1 && types.first.instance_of?(String) && types.first.start_with?("(")
|
9
|
+
# forall("(Integer) -> String") { |int| Foo.new.int2str(int) }
|
10
|
+
type = types.first
|
11
|
+
method_type = RaaP::MethodType.new(type)
|
12
|
+
size_step.each do |size|
|
13
|
+
# TODO assert_send_type
|
14
|
+
args, kwargs, _block = method_type.pick_arguments(size: size)
|
15
|
+
return_value = yield(*args, **kwargs)
|
16
|
+
assert method_type.check_return(return_value), "return value: #{BindCall.inspect(return_value)}[#{BindCall.class(return_value)}] is not match with `#{method_type.rbs.type.return_type}`"
|
17
|
+
end
|
18
|
+
else
|
19
|
+
# forall("Integer", "String") { |int, str| Foo.new.int_str(int, str) }
|
20
|
+
types.map! do |type|
|
21
|
+
case type
|
22
|
+
in String then RaaP::Type.new(type)
|
23
|
+
else type
|
24
|
+
end
|
25
|
+
end
|
26
|
+
size_step.each do |size|
|
27
|
+
values = types.map { |type| type.pick(size: size) }
|
28
|
+
assert yield(*values)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Minitest::Test.include RaaP::Minitest
|
data/lib/raap/symbolic_caller.rb
CHANGED
@@ -16,6 +16,21 @@ module RaaP
|
|
16
16
|
# c = C.new(a: a, b: b)
|
17
17
|
# c.run() { }
|
18
18
|
class SymbolicCaller
|
19
|
+
class Var
|
20
|
+
attr_reader :name
|
21
|
+
def initialize(name)
|
22
|
+
@name = name
|
23
|
+
end
|
24
|
+
|
25
|
+
def +(other)
|
26
|
+
"#{self}#{other}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
@name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
19
34
|
attr_reader :symbolic_call
|
20
35
|
|
21
36
|
def initialize(symbolic_call)
|
@@ -39,18 +54,27 @@ module RaaP
|
|
39
54
|
|
40
55
|
is_mod = receiver_value.is_a?(Module)
|
41
56
|
|
42
|
-
|
43
|
-
|
57
|
+
case
|
58
|
+
when receiver_value == Kernel
|
59
|
+
var = Var.new(method_name.to_s.downcase)
|
60
|
+
var_eq = "#{var} = "
|
44
61
|
receiver = ''
|
45
|
-
|
46
|
-
|
62
|
+
when BindCall.instance_of?(receiver_value, Var)
|
63
|
+
var_eq = ""
|
64
|
+
var = Var.new(receiver_value.name)
|
65
|
+
receiver = var + '.'
|
66
|
+
when is_mod
|
67
|
+
var = Var.new(var_name(receiver_value))
|
68
|
+
var_eq = "#{var} = "
|
47
69
|
receiver = receiver_value.name + '.'
|
48
70
|
else
|
49
|
-
|
71
|
+
var_eq = ""
|
50
72
|
receiver = if printable?(receiver_value)
|
51
|
-
printable(receiver_value)
|
73
|
+
var = Var.new(printable(receiver_value))
|
74
|
+
var + '.'
|
52
75
|
else
|
53
|
-
var_name(receiver_value.class)
|
76
|
+
var = Var.new(var_name(receiver_value.class))
|
77
|
+
var + '.'
|
54
78
|
end
|
55
79
|
end
|
56
80
|
|
@@ -59,9 +83,9 @@ module RaaP
|
|
59
83
|
arguments << kwargs.map{|k,v| "#{k}: #{printable(v)}" }.join(', ') if !kwargs.empty?
|
60
84
|
block_str = block ? " { }" : ""
|
61
85
|
|
62
|
-
lines << "#{
|
86
|
+
lines << "#{var_eq}#{receiver}#{method_name}(#{arguments.join(', ')})#{block_str}"
|
63
87
|
|
64
|
-
|
88
|
+
var
|
65
89
|
end
|
66
90
|
end
|
67
91
|
end
|
@@ -78,6 +102,8 @@ module RaaP
|
|
78
102
|
args = _walk(args, &block) if !args.empty?
|
79
103
|
kwargs = _walk(kwargs, &block) if !kwargs.empty?
|
80
104
|
block.call [:call, receiver, method_name, args, kwargs, b]
|
105
|
+
in Var
|
106
|
+
symbolic_call.name
|
81
107
|
in Array
|
82
108
|
symbolic_call.map { |sc| _walk(sc, &block) }
|
83
109
|
in Hash
|
@@ -89,13 +115,7 @@ module RaaP
|
|
89
115
|
|
90
116
|
def eval_one(symbolic_call)
|
91
117
|
symbolic_call => [:call, receiver_value, method_name, args, kwargs, block]
|
92
|
-
|
93
|
-
begin
|
94
|
-
receiver_value.__send__(method_name, *args, **kwargs, &block)
|
95
|
-
rescue => e
|
96
|
-
RaaP.logger.error("Cannot eval symbolic call #{symbolic_call} with #{e.class}")
|
97
|
-
raise
|
98
|
-
end
|
118
|
+
BindCall.public_send(receiver_value, method_name, *args, **kwargs, &block)
|
99
119
|
end
|
100
120
|
|
101
121
|
def var_name(mod)
|
@@ -104,7 +124,7 @@ module RaaP
|
|
104
124
|
|
105
125
|
def printable?(obj)
|
106
126
|
case obj
|
107
|
-
when Symbol, Integer, Float, Regexp, nil, true, false, String, Module
|
127
|
+
when Symbol, Integer, Float, Regexp, nil, true, false, String, Module, Var
|
108
128
|
true
|
109
129
|
else
|
110
130
|
false
|
@@ -113,6 +133,8 @@ module RaaP
|
|
113
133
|
|
114
134
|
def printable(obj)
|
115
135
|
case obj
|
136
|
+
when Var
|
137
|
+
obj.name
|
116
138
|
# Object from which it can get strings that can be eval with `#inspect`
|
117
139
|
when Symbol, Integer, Float, Regexp, nil, true, false
|
118
140
|
obj.inspect
|
data/lib/raap/type.rb
CHANGED
@@ -23,12 +23,14 @@ module RaaP
|
|
23
23
|
|
24
24
|
# Type.register "::Integer::positive" { sized { |size| size } }
|
25
25
|
def self.register(type_name, &block)
|
26
|
-
|
26
|
+
raise ArgumentError, "block is required" unless block
|
27
|
+
GENERATORS[type_name] = __skip__ = block
|
27
28
|
end
|
28
29
|
|
29
30
|
# Special class case
|
30
31
|
register("::Array") do
|
31
|
-
|
32
|
+
_type = __skip__ = type
|
33
|
+
t = _type.args[0] || 'untyped'
|
32
34
|
array(Type.new(t, range: range))
|
33
35
|
end
|
34
36
|
register("::Binding") { sized { binding } }
|
@@ -40,8 +42,9 @@ module RaaP
|
|
40
42
|
register("::Hash") do
|
41
43
|
sized do |size|
|
42
44
|
Array.new(integer.pick(size: size).abs).to_h do
|
43
|
-
|
44
|
-
|
45
|
+
_type = __skip__ = type
|
46
|
+
k = _type.args[0] || 'untyped'
|
47
|
+
v = _type.args[1] || 'untyped'
|
45
48
|
[Type.new(k).pick(size: size), Type.new(v).pick(size: size)]
|
46
49
|
end
|
47
50
|
end
|
@@ -66,10 +69,20 @@ module RaaP
|
|
66
69
|
def initialize(type, range: nil..nil)
|
67
70
|
@type = parse(type)
|
68
71
|
@range = range
|
72
|
+
@such_that = nil
|
73
|
+
end
|
74
|
+
|
75
|
+
def such_that(&block)
|
76
|
+
@such_that = block
|
77
|
+
self
|
69
78
|
end
|
70
79
|
|
71
80
|
def sized(&block)
|
72
|
-
Sized.new(&block)
|
81
|
+
Sized.new(&block).tap do |sized|
|
82
|
+
if s = @such_that
|
83
|
+
sized.such_that(&s)
|
84
|
+
end
|
85
|
+
end
|
73
86
|
end
|
74
87
|
|
75
88
|
def pick(size: 10, eval: true)
|
@@ -112,8 +125,8 @@ module RaaP
|
|
112
125
|
Object.const_get(type.name.to_s)
|
113
126
|
when ::RBS::Types::ClassInstance
|
114
127
|
case gen = GENERATORS[type.name.absolute!.to_s]
|
115
|
-
|
116
|
-
|
128
|
+
in Proc then instance_exec(&gen).pick(size: size)
|
129
|
+
in nil then pick_from_initialize(type, size:)
|
117
130
|
end
|
118
131
|
when ::RBS::Types::Record
|
119
132
|
type.fields.transform_values { |t| Type.new(t).pick(size:) }
|
@@ -138,6 +151,8 @@ module RaaP
|
|
138
151
|
end
|
139
152
|
end
|
140
153
|
|
154
|
+
private
|
155
|
+
|
141
156
|
def pick_from_initialize(type, size:)
|
142
157
|
type_name = type.name.absolute!
|
143
158
|
const = Object.const_get(type_name.to_s)
|
@@ -166,8 +181,6 @@ module RaaP
|
|
166
181
|
end
|
167
182
|
end
|
168
183
|
|
169
|
-
private
|
170
|
-
|
171
184
|
def parse(type)
|
172
185
|
case type
|
173
186
|
when String
|
@@ -279,24 +292,28 @@ module RaaP
|
|
279
292
|
|
280
293
|
def encoding
|
281
294
|
sized do
|
282
|
-
|
283
|
-
e = Encoding.list.sample
|
295
|
+
e = Encoding.list.sample or raise
|
284
296
|
[:call, Encoding, :find, [e.name], {} , nil]
|
285
297
|
end
|
286
298
|
end
|
287
299
|
|
288
300
|
def bool
|
289
|
-
sized
|
301
|
+
sized do
|
302
|
+
Random.rand(2) == 0
|
303
|
+
end
|
290
304
|
end
|
291
305
|
|
292
306
|
def untyped
|
293
|
-
case Random.rand(
|
307
|
+
case Random.rand(9)
|
294
308
|
in 0 then integer
|
295
309
|
in 1 then float
|
296
|
-
in 2 then
|
297
|
-
in 3 then
|
298
|
-
in 4 then
|
299
|
-
in 5 then
|
310
|
+
in 2 then rational
|
311
|
+
in 3 then complex
|
312
|
+
in 4 then string
|
313
|
+
in 5 then symbol
|
314
|
+
in 6 then bool
|
315
|
+
in 7 then encoding
|
316
|
+
in 8 then sized { BasicObject.new }
|
300
317
|
end
|
301
318
|
end
|
302
319
|
|
data/lib/raap/version.rb
CHANGED
data/lib/raap.rb
CHANGED
@@ -16,7 +16,7 @@ module RaaP
|
|
16
16
|
end
|
17
17
|
|
18
18
|
self.logger = ::Logger.new($stdout)
|
19
|
-
self.logger.level = ::Logger::
|
19
|
+
self.logger.level = ::Logger::INFO
|
20
20
|
|
21
21
|
autoload :BindCall, "raap/bind_call"
|
22
22
|
autoload :CLI, "raap/cli"
|
@@ -24,6 +24,7 @@ module RaaP
|
|
24
24
|
autoload :MethodProperty, "raap/method_property"
|
25
25
|
autoload :MethodType, "raap/method_type"
|
26
26
|
autoload :MethodValue, "raap/method_value"
|
27
|
+
autoload :Minitest, "raap/minitest"
|
27
28
|
autoload :RBS, "raap/rbs"
|
28
29
|
autoload :Result, "raap/result"
|
29
30
|
autoload :Sized, "raap/sized"
|
data/sig/raap.rbs
CHANGED
@@ -103,6 +103,7 @@ module RaaP
|
|
103
103
|
def initialize: (::RBS::MethodType | String method, ?type_params_decl: Array[untyped], ?type_args: Array[untyped], ?self_type: ::RBS::Types::ClassInstance?, ?instance_type: ::RBS::Types::ClassInstance?, ?class_type: ::RBS::Types::ClassSingleton?) -> void
|
104
104
|
def pick_arguments: (?size: Integer, ?eval: bool) -> [Array[untyped], Hash[Symbol, untyped], ::Proc?]
|
105
105
|
def pick_block: (?size: Integer, ?eval: bool) -> ::Proc?
|
106
|
+
def check_return: (untyped) -> bool
|
106
107
|
end
|
107
108
|
|
108
109
|
class MethodValue < Data
|
@@ -129,7 +130,14 @@ module RaaP
|
|
129
130
|
def block_str: () -> String?
|
130
131
|
end
|
131
132
|
|
133
|
+
module Minitest
|
134
|
+
end
|
135
|
+
|
132
136
|
module RBS
|
137
|
+
self.@builder: ::RBS::DefinitionBuilder
|
138
|
+
self.@env: ::RBS::Environment
|
139
|
+
self.@loader: ::RBS::EnvironmentLoader
|
140
|
+
|
133
141
|
def self.builder: () -> ::RBS::DefinitionBuilder
|
134
142
|
def self.env: () -> ::RBS::Environment
|
135
143
|
def self.loader: () -> ::RBS::EnvironmentLoader
|
@@ -169,21 +177,24 @@ module RaaP
|
|
169
177
|
end
|
170
178
|
end
|
171
179
|
|
172
|
-
|
173
|
-
def pick: (size: Integer) -> T
|
174
|
-
end
|
175
|
-
|
176
|
-
class Sized
|
180
|
+
class Sized[T]
|
177
181
|
@block: ::Proc
|
178
182
|
@such_that: ::Proc?
|
179
183
|
|
180
184
|
def initialize: () { (Integer) -> untyped } -> void
|
181
|
-
|
185
|
+
def pick: (size: Integer) -> T
|
182
186
|
def such_that: () { (untyped) -> boolish } -> self
|
183
187
|
def such_that_loop: [R] () { (Integer) -> R } -> R
|
184
188
|
end
|
185
189
|
|
186
190
|
class SymbolicCaller
|
191
|
+
class Var
|
192
|
+
attr_reader name: String
|
193
|
+
def initialize: (String name) -> void
|
194
|
+
def +: (String) -> String
|
195
|
+
def to_s: () -> String
|
196
|
+
end
|
197
|
+
|
187
198
|
attr_reader symbolic_call: untyped
|
188
199
|
def initialize: (untyped) -> void
|
189
200
|
def eval: () -> untyped
|
@@ -213,7 +224,7 @@ module RaaP
|
|
213
224
|
def map_type: { (untyped) -> untyped } -> untyped
|
214
225
|
end
|
215
226
|
|
216
|
-
def sub: (_MapType search, self_type: ::RBS::Types::ClassInstance?, instance_type: ::RBS::Types::ClassInstance?,
|
227
|
+
def sub: (_MapType search, self_type: ::RBS::Types::ClassInstance?, instance_type: ::RBS::Types::ClassInstance?, class_type: ::RBS::Types::ClassSingleton?) -> untyped
|
217
228
|
end
|
218
229
|
|
219
230
|
class Type
|
@@ -222,39 +233,45 @@ module RaaP
|
|
222
233
|
def self.positive_float: () -> Float
|
223
234
|
end
|
224
235
|
|
225
|
-
|
236
|
+
@such_that: (^(untyped) -> ::boolish)?
|
237
|
+
|
238
|
+
GENERATORS: Hash[String, ^() -> Sized[untyped]]
|
226
239
|
SIMPLE_SOURCE: Array[String]
|
227
240
|
RECURSION: Hash[String, :found | :logged]
|
228
241
|
|
229
|
-
def self.register: (String) { () [self: instance] ->
|
242
|
+
def self.register: (String) { () [self: instance] -> Sized[untyped] } -> void
|
230
243
|
attr_reader type: ::RBS::Types::t
|
231
244
|
attr_reader range: Range[untyped]
|
232
245
|
|
233
246
|
def initialize: (String | ::RBS::Types::t, ?range: Range[untyped]) -> void
|
234
247
|
|
235
|
-
|
236
|
-
|
248
|
+
# Define rule for generating values
|
249
|
+
# type.such_that { |i| i != 0 }.pick #=> ensure that the value is not 0
|
250
|
+
def such_that: () { (untyped) -> boolish } -> self
|
251
|
+
|
252
|
+
# Basic API for materializing values
|
253
|
+
def pick: (?size: Integer, ?eval: bool) -> untyped
|
237
254
|
def to_symbolic_call: (?size: Integer) -> untyped
|
238
|
-
def
|
239
|
-
def sized: () { (Integer size) -> untyped } -> _Pick[untyped]
|
255
|
+
def sized: [T] () { (Integer size) -> T } -> Sized[T]
|
240
256
|
|
241
257
|
private
|
242
258
|
|
259
|
+
def pick_from_initialize: (::RBS::Types::ClassInstance, size: Integer) -> (symbolic_call | Value::Module)
|
243
260
|
def parse: (String | ::RBS::Types::t) -> ::RBS::Types::t?
|
244
261
|
def try: (times: Integer, size: Integer) { (Integer size) -> untyped } -> untyped
|
245
262
|
|
246
|
-
def numeric: () ->
|
247
|
-
def integer: () ->
|
248
|
-
def none_zero_integer: () ->
|
249
|
-
def float: () ->
|
250
|
-
def rational: () ->
|
251
|
-
def complex: () ->
|
252
|
-
def string: () ->
|
253
|
-
def symbol: () ->
|
254
|
-
def array: (Type) ->
|
255
|
-
def encoding: () ->
|
256
|
-
def bool: () ->
|
257
|
-
def untyped: () ->
|
263
|
+
def numeric: () -> Sized[Numeric]
|
264
|
+
def integer: () -> Sized[Integer]
|
265
|
+
def none_zero_integer: () -> Sized[Integer]
|
266
|
+
def float: () -> Sized[Float]
|
267
|
+
def rational: () -> Sized[symbolic_call]
|
268
|
+
def complex: () -> Sized[symbolic_call]
|
269
|
+
def string: () -> Sized[String]
|
270
|
+
def symbol: () -> Sized[Symbol]
|
271
|
+
def array: (Type) -> Sized[Array[untyped]]
|
272
|
+
def encoding: () -> Sized[symbolic_call]
|
273
|
+
def bool: () -> Sized[bool]
|
274
|
+
def untyped: () -> Sized[untyped]
|
258
275
|
def temp_method_object: () -> ::Method
|
259
276
|
end
|
260
277
|
|
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.2.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-03-
|
11
|
+
date: 2024-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/raap/method_property.rb
|
61
61
|
- lib/raap/method_type.rb
|
62
62
|
- lib/raap/method_value.rb
|
63
|
+
- lib/raap/minitest.rb
|
63
64
|
- lib/raap/rbs.rb
|
64
65
|
- lib/raap/result.rb
|
65
66
|
- lib/raap/sized.rb
|