raap 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94f0ec4ff924c5089f8e307002dd5f3cd778f04e686acd8b46466139c3c1aebd
4
- data.tar.gz: e9a06fb3c71cfc6cd605031fe8cb899a123dc82a94ef00586d39e8329c45beac
3
+ metadata.gz: 5780226ede8755c1ef7f82e18b7e8d96a63d2ab6eb253bc8964f5745776f993f
4
+ data.tar.gz: 6e9dd39a302f555cac12ecb6232a7c2f39d206911fcee7a30650d5fe4a9cbc63
5
5
  SHA512:
6
- metadata.gz: ed0d647fefa8591c0a03981232c84d64bf7c70bcf9207d2dd6471a9f3369747b5dd3adcc3cd60a8e1d65f0e1543ed7a5f5108eef6523c7d306cfc399d0bc63e4
7
- data.tar.gz: 537c5dfbb65bb12064e46c47fb75a60321ee0f16296f1272ef27d68927f4f9f3d5875ea6f3ac2225c76a2d274fbe393bff20f573b8d138b52a6ced8027528e1f
6
+ metadata.gz: 2841e75bc0b03742cc0d9268f9ec2ae69f2f9c6e1f579ec6e794db5e9b8f80d763fac4ce28abd7361e19ada8f6289e594b6a9a3cdc63b1806181a69a9f49bb6a
7
+ data.tar.gz: a3057811c5d13ac4f891fc2c2082b91f33a1a8d35d3c9b6e1ccb1871c268127811caa6f2708c878ef35ae4cc25143db62c4e5801ded32cfad9a1db50387753a6
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 3.3
2
+ TargetRubyVersion: 3.0
3
3
  NewCops: enable
4
4
  Include:
5
5
  - 'lib/**/*.rb'
data/README.md CHANGED
@@ -70,7 +70,7 @@ $ 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
73
+ $ raap 'MyClass' '!MyClass#skip' # Run methods MyClass without #skip
74
74
  ```
75
75
 
76
76
  ```
@@ -81,6 +81,13 @@ MyClass
81
81
  $ raap $(cat test/raap.txt) # You can manage the methods to be tested in a file
82
82
  ```
83
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
+
84
91
  ## Size
85
92
 
86
93
  Random values are determined based on size.
data/Rakefile CHANGED
@@ -4,7 +4,9 @@ require "bundler/gem_tasks"
4
4
  require "minitest/test_task"
5
5
  require "rubocop/rake_task"
6
6
 
7
- Minitest::TestTask.create
7
+ Minitest::TestTask.create do |t|
8
+ t.test_prelude = 'require "test/test_helper"'
9
+ end
8
10
 
9
11
  RuboCop::RakeTask.new
10
12
 
data/lib/raap/cli.rb CHANGED
@@ -104,7 +104,7 @@ module RaaP
104
104
 
105
105
  # Search skip tag
106
106
  @argv.each do |tag|
107
- if tag.start_with?('!') && (tag.include?('#') || tag.include?('.'))
107
+ if tag.start_with?('!')
108
108
  t = tag[1..] or raise
109
109
  t = "::#{t}" unless t.start_with?('::')
110
110
  t or raise
@@ -118,13 +118,13 @@ module RaaP
118
118
 
119
119
  case
120
120
  when tag.include?('#')
121
- run_by(kind: :instance, tag:)
121
+ run_by(kind: :instance, tag: tag)
122
122
  when tag.include?('.')
123
- run_by(kind: :singleton, tag:)
123
+ run_by(kind: :singleton, tag: tag)
124
124
  when tag.end_with?('*')
125
- run_by_type_name_with_search(tag:)
125
+ run_by_type_name_with_search(tag: tag)
126
126
  else
127
- run_by_type_name(tag:)
127
+ run_by_type_name(tag: tag)
128
128
  end
129
129
  end
130
130
 
@@ -198,9 +198,10 @@ module RaaP
198
198
 
199
199
  RaaP.logger.info("# #{type}")
200
200
  @results << {
201
- method:,
201
+ method: method,
202
202
  properties: method.method_types.map do |method_type|
203
- property(receiver_type:, type_params_decl:, type_args:, method_type:, method_name:)
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)
204
205
  end
205
206
  }
206
207
  end
@@ -238,9 +239,10 @@ module RaaP
238
239
 
239
240
  RaaP.logger.info("# #{type_name}.#{method_name}")
240
241
  @results << {
241
- method:,
242
+ method: method,
242
243
  properties: method.method_types.map do |method_type|
243
- property(receiver_type: Type.new("singleton(#{type.name})"), type_params_decl:, type_args:, method_type:, method_name:)
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)
244
246
  end
245
247
  }
246
248
  end
@@ -257,9 +259,10 @@ module RaaP
257
259
 
258
260
  RaaP.logger.info("# #{type_name}##{method_name}")
259
261
  @results << {
260
- method:,
262
+ method: method,
261
263
  properties: method.method_types.map do |method_type|
262
- property(receiver_type: Type.new(type.name), type_params_decl:, type_args:, method_type:, method_name:)
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)
263
266
  end
264
267
  }
265
268
  end
@@ -283,12 +286,12 @@ module RaaP
283
286
  status = 0
284
287
  reason = nil
285
288
  prop = MethodProperty.new(
286
- receiver_type:,
287
- method_name:,
289
+ receiver_type: receiver_type,
290
+ method_name: method_name,
288
291
  method_type: MethodType.new(
289
292
  method_type,
290
- type_params_decl:,
291
- type_args:,
293
+ type_params_decl: type_params_decl,
294
+ type_args: type_args,
292
295
  self_type: rtype,
293
296
  instance_type: ::RBS::Types::ClassInstance.new(name: rtype.name, args: type_args, location: nil),
294
297
  class_type: ::RBS::Types::ClassSingleton.new(name: rtype.name, location: nil),
@@ -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
 
@@ -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:, stats:).tap do |ret|
26
+ call(size: size, stats: stats).tap do |ret|
27
27
  case ret
28
28
  when Result::Success
29
29
  stats.success += 1
@@ -55,8 +55,8 @@ module RaaP
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:, return_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:, return_value:)
84
+ Result::Success.new(symbolic_call: symbolic_call, return_value: return_value)
85
85
  in [:failure]
86
- Result::Failure.new(symbolic_call:, return_value:)
86
+ Result::Failure.new(symbolic_call: symbolic_call, return_value: return_value)
87
87
  in [:exception, exception]
88
- Result::Exception.new(symbolic_call:, exception:)
88
+ Result::Exception.new(symbolic_call: symbolic_call, exception: exception)
89
89
  end
90
90
  rescue TypeError => exception
91
- Result::Failure.new(symbolic_call:, return_value:, exception:)
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:, exception:)
96
+ Result::Skip.new(symbolic_call: symbolic_call, exception: exception)
97
97
  rescue NameError => e
98
- RaaP.logger.error("[#{e.class}] #{e.detailed_message}")
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:, exception:)
106
+ Result::Skip.new(symbolic_call: symbolic_call, exception: exception)
107
107
  rescue => exception
108
- Result::Exception.new(symbolic_call:, exception:)
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,
@@ -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:, instance_type:, class_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
@@ -13,7 +13,7 @@ module RaaP
13
13
  method_type = RaaP::MethodType.new(type)
14
14
  size_step.each do |size|
15
15
  # TODO assert_send_type
16
- args, kwargs, _block = method_type.pick_arguments(size:)
16
+ args, kwargs, _block = method_type.pick_arguments(size: size)
17
17
  return_value = yield(*args, **kwargs)
18
18
  i = BindCall.inspect(return_value)
19
19
  c = BindCall.class(return_value)
@@ -30,7 +30,7 @@ module RaaP
30
30
  end
31
31
  end
32
32
  size_step.each do |size|
33
- values = types.map { |t| t.pick(size:) }
33
+ values = types.map { |t| t.pick(size: size) }
34
34
  assert yield(*values)
35
35
  end
36
36
  end
@@ -121,8 +121,8 @@ module RaaP
121
121
  symbolic_call
122
122
  end
123
123
 
124
- def walk(&)
125
- _walk(@symbolic_call, true, &)
124
+ def walk(&block)
125
+ _walk(@symbolic_call, true, &block)
126
126
  end
127
127
 
128
128
  def _walk(symbolic_call, is_last, &block)
data/lib/raap/type.rb CHANGED
@@ -52,21 +52,21 @@ module RaaP
52
52
  method_type = MethodType.new(maped_rbs_method_type)
53
53
 
54
54
  begin
55
- args, kwargs, block = method_type.arguments_to_symbolic_call(size:)
55
+ args, kwargs, block = method_type.arguments_to_symbolic_call(size: size)
56
56
  [:call, base, :new, args, kwargs, block]
57
57
  rescue
58
58
  $stderr.puts "Fail with `#{rbs_method_type}`"
59
59
  raise
60
60
  end
61
61
  else
62
- [:call, Value::Module, :new, [type.to_s], { size: }, nil]
62
+ [:call, Value::Module, :new, [type.to_s], { size: size }, nil]
63
63
  end
64
64
  end
65
65
 
66
66
  # Special class case
67
67
  register("::Array") do
68
68
  instance = __skip__ = type
69
- 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
70
70
  array(t)
71
71
  end
72
72
  register("::Binding") { sized { binding } }
@@ -87,7 +87,7 @@ module RaaP
87
87
  register("::NilClass") { sized { nil } }
88
88
  register("::Proc") { sized { Proc.new {} } }
89
89
  register("::Rational") { rational }
90
- register("::Regexp") { sized { |size| Regexp.new(string.pick(size:)) } }
90
+ register("::Regexp") { sized { |size| Regexp.new(string.pick(size: size)) } }
91
91
  register("::String") { string }
92
92
  register("::Struct") { sized { Struct.new(:foo, :bar).new } }
93
93
  register("::Symbol") { symbol }
@@ -118,11 +118,11 @@ module RaaP
118
118
  end
119
119
 
120
120
  def pick(size: 10)
121
- to_symbolic_caller(size:).eval
121
+ to_symbolic_caller(size: size).eval
122
122
  end
123
123
 
124
124
  def to_symbolic_caller(size: 10)
125
- SymbolicCaller.new(to_symbolic_call(size:))
125
+ SymbolicCaller.new(to_symbolic_call(size: size))
126
126
  end
127
127
 
128
128
  def to_symbolic_call(size: 10)
@@ -131,20 +131,20 @@ module RaaP
131
131
 
132
132
  case type
133
133
  when ::RBS::Types::Tuple
134
- type.types.map { |t| Type.new(t).to_symbolic_call(size:) }
134
+ type.types.map { |t| Type.new(t).to_symbolic_call(size: size) }
135
135
  when ::RBS::Types::Union
136
- 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) }
137
137
  when ::RBS::Types::Intersection
138
138
  if type.free_variables.empty?
139
- [:call, Value::Intersection, :new, [type.to_s], { size: }, nil]
139
+ [:call, Value::Intersection, :new, [type.to_s], { size: size }, nil]
140
140
  else
141
- [:call, Value::Intersection, :new, [type], { size: }, nil]
141
+ [:call, Value::Intersection, :new, [type], { size: size }, nil]
142
142
  end
143
143
  when ::RBS::Types::Interface
144
144
  if type.free_variables.empty?
145
- [:call, Value::Interface, :new, [type.to_s], { size: }, nil]
145
+ [:call, Value::Interface, :new, [type.to_s], { size: size }, nil]
146
146
  else
147
- [:call, Value::Interface, :new, [type], { size: }, nil]
147
+ [:call, Value::Interface, :new, [type], { size: size }, nil]
148
148
  end
149
149
  when ::RBS::Types::Variable
150
150
  [:call, Value::Variable, :new, [type.to_s], {}, nil]
@@ -162,7 +162,7 @@ module RaaP
162
162
  when ::RBS::Types::Alias
163
163
  case gen = GENERATORS[type.name.absolute!.to_s]
164
164
  in Proc then instance_exec(&gen)
165
- 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)
166
166
  end
167
167
  when ::RBS::Types::Bases::Class
168
168
  RaaP.logger.warn("Unresolved `class` type, use Object instead.")
@@ -176,19 +176,19 @@ module RaaP
176
176
  Object.const_get(type.name.to_s)
177
177
  when ::RBS::Types::ClassInstance
178
178
  case gen = GENERATORS[type.name.absolute!.to_s]
179
- in Proc then instance_exec(&gen).pick(size:)
180
- 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)
181
181
  end
182
182
  when ::RBS::Types::Record
183
183
  type.fields.transform_values { |t| Type.new(t).to_symbolic_call(size: size / 2) }
184
184
  when ::RBS::Types::Proc
185
- 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) }
186
186
  when ::RBS::Types::Literal
187
187
  type.literal
188
188
  when ::RBS::Types::Bases::Bool
189
- bool.pick(size:)
189
+ bool.pick(size: size)
190
190
  when ::RBS::Types::Bases::Any
191
- Type.random.to_symbolic_call(size:)
191
+ Type.random.to_symbolic_call(size: size)
192
192
  when ::RBS::Types::Bases::Nil
193
193
  nil
194
194
  else
@@ -201,7 +201,7 @@ module RaaP
201
201
  def to_symbolic_call_from_initialize(type, size:)
202
202
  type_name = type.name.absolute!
203
203
  const = Object.const_get(type_name.to_s)
204
- Type.call_new_from(const, type, size:)
204
+ Type.call_new_from(const, type, size: size)
205
205
  end
206
206
 
207
207
  def parse(type)
@@ -216,7 +216,7 @@ module RaaP
216
216
  end
217
217
 
218
218
  def integer
219
- sized { |size| float.pick(size:).round }
219
+ sized { |size| float.pick(size: size).round }
220
220
  end
221
221
 
222
222
  def none_zero_integer
@@ -240,16 +240,16 @@ module RaaP
240
240
 
241
241
  def rational
242
242
  sized do |size|
243
- a = integer.pick(size:)
244
- b = none_zero_integer.pick(size:)
243
+ a = integer.pick(size: size)
244
+ b = none_zero_integer.pick(size: size)
245
245
  [:call, Kernel, :Rational, [a, b], {}, nil]
246
246
  end
247
247
  end
248
248
 
249
249
  def complex
250
250
  sized do |size|
251
- a = integer.pick(size:)
252
- b = none_zero_integer.pick(size:)
251
+ a = integer.pick(size: size)
252
+ b = none_zero_integer.pick(size: size)
253
253
  [:call, Kernel, :Complex, [a, b], {}, nil]
254
254
  end
255
255
  end
@@ -274,13 +274,13 @@ module RaaP
274
274
 
275
275
  def symbol
276
276
  sized do |size|
277
- string.pick(size:).to_sym
277
+ string.pick(size: size).to_sym
278
278
  end
279
279
  end
280
280
 
281
281
  def array(type)
282
282
  sized do |size|
283
- Array.new(integer.pick(size:).abs) do
283
+ Array.new(integer.pick(size: size).abs) do
284
284
  type.to_symbolic_call(size: size / 2)
285
285
  end
286
286
  end
@@ -291,7 +291,7 @@ module RaaP
291
291
  def dict(key_type, value_type)
292
292
  sized do |size|
293
293
  csize = size / 2
294
- Array.new(integer.pick(size:).abs).to_h do
294
+ Array.new(integer.pick(size: size).abs).to_h do
295
295
  [
296
296
  key_type.to_symbolic_call(size: csize),
297
297
  value_type.to_symbolic_call(size: csize)
@@ -27,8 +27,8 @@ module RaaP
27
27
  sub = build
28
28
  ::RBS::MethodType.new(
29
29
  type_params: [],
30
- type: method_type.type.sub(sub).then { |ty| sub(ty, self_type:, instance_type:, class_type:) },
31
- block: method_type.block&.sub(sub)&.then { |bl| sub(bl, self_type:, instance_type:, class_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) },
32
32
  location: method_type.location
33
33
  )
34
34
  end
@@ -49,7 +49,7 @@ module RaaP
49
49
  when ::RBS::Types::Bases::Class
50
50
  class_type || ty
51
51
  else
52
- sub(ty, self_type:, instance_type:, class_type:)
52
+ sub(ty, self_type: self_type, instance_type: instance_type, class_type: class_type)
53
53
  end
54
54
  end
55
55
  end
@@ -20,14 +20,14 @@ module RaaP
20
20
  method_type = method.method_types.sample or ::Kernel.raise
21
21
  type_params = definition.type_params_decl.concat(method_type.type_params.drop(definition.type_params_decl.length))
22
22
  ts = TypeSubstitution.new(type_params, type.args)
23
- subed_method_type = ts.method_type_sub(method_type, self_type:, instance_type:, class_type:)
23
+ subed_method_type = ts.method_type_sub(method_type, self_type: self_type, instance_type: instance_type, class_type: class_type)
24
24
 
25
25
  BindCall.define_method(base_class, name) do |*_, &b|
26
26
  @fixed_return_value ||= {}
27
27
  @fixed_return_value[name] ||= if self_type == subed_method_type.type.return_type
28
28
  self
29
29
  else
30
- Type.new(subed_method_type.type.return_type).pick(size:)
30
+ Type.new(subed_method_type.type.return_type).pick(size: size)
31
31
  end
32
32
  # @type var b: Proc?
33
33
  if b
@@ -35,7 +35,7 @@ module RaaP
35
35
  @fixed_block_arguments[name] ||= if subed_method_type.block
36
36
  size.times.map do
37
37
  FunctionType.new(subed_method_type.block.type)
38
- .pick_arguments(size:)
38
+ .pick_arguments(size: size)
39
39
  end
40
40
  else
41
41
  []
@@ -51,10 +51,10 @@ module RaaP
51
51
 
52
52
  def new(type, size: 3)
53
53
  temp_class = ::Class.new(Interface) do |c|
54
- define_method_from_interface(c, type, size:)
54
+ define_method_from_interface(c, type, size: size)
55
55
  end
56
56
  instance = temp_class.allocate
57
- instance.__send__(:initialize, type, size:)
57
+ instance.__send__(:initialize, type, size: size)
58
58
  instance
59
59
  end
60
60
  end
@@ -29,11 +29,11 @@ module RaaP
29
29
  end
30
30
 
31
31
  interfaces.each do |interface|
32
- Interface.define_method_from_interface(self, interface, size:)
32
+ Interface.define_method_from_interface(self, interface, size: size)
33
33
  end
34
34
  end
35
35
  type = ::RBS::Types::ClassInstance.new(name: TypeName(base.name), args: [], location: nil)
36
- SymbolicCaller.new(Type.call_new_from(c, type, size:)).eval
36
+ SymbolicCaller.new(Type.call_new_from(c, type, size: size)).eval
37
37
  end
38
38
  end
39
39
  end
@@ -35,7 +35,7 @@ module RaaP
35
35
  if !ts.include?('::BasicObject') || ts.any? { |t| t.split('::').last&.start_with?('_') }
36
36
  ts.unshift('Object')
37
37
  end
38
- Type.new(ts.uniq.join(' & ')).pick(size:)
38
+ Type.new(ts.uniq.join(' & ')).pick(size: size)
39
39
  end
40
40
  end
41
41
  const = ::Object.const_get(@type.name.absolute!.to_s)
data/lib/raap/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RaaP
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
data/lib/raap.rb CHANGED
@@ -9,6 +9,7 @@ require 'logger'
9
9
 
10
10
  require_relative 'raap/version'
11
11
  require_relative 'raap/value'
12
+ require_relative 'shims'
12
13
 
13
14
  module RaaP
14
15
  class << self
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
@@ -10,7 +10,7 @@ gems:
10
10
  source:
11
11
  type: git
12
12
  name: ruby/gem_rbs_collection
13
- revision: bc4cbee282cfb013be8c44a3fe7a374491492400
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: bc4cbee282cfb013be8c44a3fe7a374491492400
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: bc4cbee282cfb013be8c44a3fe7a374491492400
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: bc4cbee282cfb013be8c44a3fe7a374491492400
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: bc4cbee282cfb013be8c44a3fe7a374491492400
97
+ revision: d2e93d426c927fdab90ef12e30a9875aa05d60d6
98
98
  remote: https://github.com/ruby/gem_rbs_collection.git
99
99
  repo_dir: gems
100
100
  - name: rbs
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.5.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-23 00:00:00.000000000 Z
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.3.0
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.5.3
105
+ rubygems_version: 3.2.33
105
106
  signing_key:
106
107
  specification_version: 4
107
108
  summary: RBS as a Property