summaryrefslogtreecommitdiff
path: root/test/ruby/test_settracefunc.rb
diff options
context:
space:
mode:
authorXavier Noria <[email protected]>2025-04-08 22:29:05 +0200
committerJean Boussier <[email protected]>2025-04-10 10:20:31 +0200
commitc5c0bb5afcbbc054c9e8f4e4b9209253d42f7326 (patch)
tree358f37c3f96a62b67b54e8e0ded384c2555519b6 /test/ruby/test_settracefunc.rb
parent0d6263bd416338a339651fb97fe4d62701704c4b (diff)
Restore the original order of const_added and inherited callbacks
Originally, if a class was defined with the class keyword, the cref had a const_added callback, and the superclass an inherited callback, const_added was called first, and inherited second. This was discussed in https://bugs.ruby-lang.org/issues/21143 and an attempt at changing this order was made. While both constant assignment and inheritance have happened before these callbacks are invoked, it was deemed nice to have the same order as in C = Class.new This was mostly for alignment: In that last use case things happen at different times and therefore the order of execution is kind of obvious, whereas when the class keyword is involved, the order is opaque to the user and it is up to the interpreter. However, soon in https://bugs.ruby-lang.org/issues/21193 Matz decided to play safe and keep the existing order. This reverts commits: de097fbe5f3df105bd2a26e72db06b0f5139bc1a de48e47ddf78aba02fd9623bc7ce685540a10743
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13085
Diffstat (limited to 'test/ruby/test_settracefunc.rb')
-rw-r--r--test/ruby/test_settracefunc.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 5542ad248a..55c07abbea 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -168,14 +168,14 @@ class TestSetTraceFunc < Test::Unit::TestCase
events.shift)
assert_equal(["line", 4, __method__, self.class],
events.shift)
- assert_equal(["c-call", 4, :inherited, Class],
- events.shift)
- assert_equal(["c-return", 4, :inherited, Class],
- events.shift)
assert_equal(["c-call", 4, :const_added, Module],
events.shift)
assert_equal(["c-return", 4, :const_added, Module],
events.shift)
+ assert_equal(["c-call", 4, :inherited, Class],
+ events.shift)
+ assert_equal(["c-return", 4, :inherited, Class],
+ events.shift)
assert_equal(["class", 4, nil, nil],
events.shift)
assert_equal(["line", 5, nil, nil],
@@ -411,10 +411,10 @@ class TestSetTraceFunc < Test::Unit::TestCase
[["c-return", 2, :add_trace_func, Thread],
["line", 3, __method__, self.class],
- ["c-call", 3, :inherited, Class],
- ["c-return", 3, :inherited, Class],
["c-call", 3, :const_added, Module],
["c-return", 3, :const_added, Module],
+ ["c-call", 3, :inherited, Class],
+ ["c-return", 3, :inherited, Class],
["class", 3, nil, nil],
["line", 4, nil, nil],
["c-call", 4, :method_added, Module],
@@ -558,10 +558,10 @@ class TestSetTraceFunc < Test::Unit::TestCase
[:line, 5, 'xyzzy', self.class, method, self, :inner, :nothing],
[:c_return, 4, "xyzzy", Array, :reverse_each, [1], nil, [1]],
[:line, 7, 'xyzzy', self.class, method, self, :outer, :nothing],
- [:c_call, 7, "xyzzy", Class, :inherited, Object, nil, :nothing],
- [:c_return, 7, "xyzzy", Class, :inherited, Object, nil, nil],
[:c_call, 7, "xyzzy", Module, :const_added, TestSetTraceFunc, nil, :nothing],
[:c_return, 7, "xyzzy", Module, :const_added, TestSetTraceFunc, nil, nil],
+ [:c_call, 7, "xyzzy", Class, :inherited, Object, nil, :nothing],
+ [:c_return, 7, "xyzzy", Class, :inherited, Object, nil, nil],
[:class, 7, "xyzzy", nil, nil, xyzzy.class, nil, :nothing],
[:line, 8, "xyzzy", nil, nil, xyzzy.class, nil, :nothing],
[:line, 9, "xyzzy", nil, nil, xyzzy.class, :XYZZY_outer, :nothing],