Commit 212e85d1
212e85d1645eMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 14 files · +2 added · -12 deleted
Description
test: collapse 6 default_arg_* tests into one default_args.rb
Each of default_arg_{ctor,method,inherited,partial,self_call,
callee_scope}.rb varied only the dispatch path; the class shapes
mostly didn't collide (Foo was reused in self_call and
callee_scope for unrelated purposes — renamed here to
SelfDefault and CalleeFoo so the test name carries the intent).
The basic-method and inherited-dispatch sections now share one
Greeter class with a GreeterChild subclass instead of two parallel
Greeter / Parent definitions.
6 .rb → 1. ~6s saved on Windows test step at the ~1.2s/test rate.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 212e85d1645e
- Parent
- bd3485cf0752
test/default_arg_callee_scope.rbdeleted
# When a callee method's default-arg expression reads from an# instance variable OR calls a same-class method without an# explicit receiver, the inlined expansion at the caller's site# must resolve against the call's *receiver* (and the callee's# class), not the caller's `self`. Naive inlining either fails to# compile or routes through the wrong vtable.# (1) Default reads `@ivar` — must resolve against the recv's# instance, not the caller's.class Wrapper def initialize(seed) @base = seed end def grab(target = @base * 10) target endendclass Caller def initialize @w = Wrapper.new(3) end def go @w.grab # default `@base * 10` → 3 * 10 = 30 endendputs Caller.new.go # 30# (2) Default calls a same-class bare method — must dispatch to# the *callee's* class, not the caller's. Caller defines its own# method by the same name, but Foo's default should still call# Foo's version.class Foo def target 1 end def foo(opt = target) opt endendclass Bar def target 2 # different value — must NOT be picked up end def check Foo.new.foo endendputs Bar.new.check # 1 (Foo#target, not Bar#target)test/default_arg_callee_scope.rb.expecteddeleted
Loading diff…
test/default_arg_ctor.rbdeleted
Loading diff…
test/default_arg_ctor.rb.expecteddeleted
Loading diff…
test/default_arg_inherited.rbdeleted
Loading diff…
test/default_arg_inherited.rb.expecteddeleted
Loading diff…
test/default_arg_method.rbdeleted
Loading diff…
test/default_arg_method.rb.expecteddeleted
Loading diff…
test/default_arg_partial.rbdeleted
Loading diff…
test/default_arg_partial.rb.expecteddeleted
Loading diff…
test/default_arg_self_call.rbdeleted
Loading diff…
test/default_arg_self_call.rb.expecteddeleted
Loading diff…
test/default_args.rbaddedView file
Loading diff…
test/default_args.rb.expectedaddedView file
Loading diff…