mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
ZJIT: Add tests for non-leaf classvar get and set (#14924)
This commit adds tests that raise on `getclassvariable` and `setclassvariable` to exercise the non-leaf cases as suggested in https://github.com/ruby/ruby/pull/14918#discussion_r2453804603
This commit is contained in:
parent
1d83553952
commit
f33cd1289e
Notes:
git
2025-10-23 21:48:31 +00:00
Merged-By: tekknolagi <donotemailthisaddress@bernsteinbear.com>
@ -1675,6 +1675,20 @@ class TestZJIT < Test::Unit::TestCase
|
||||
}
|
||||
end
|
||||
|
||||
def test_getclassvariable_raises
|
||||
assert_compiles '"uninitialized class variable @@x in Foo"', %q{
|
||||
class Foo
|
||||
def self.test = @@x
|
||||
end
|
||||
|
||||
begin
|
||||
Foo.test
|
||||
rescue NameError => e
|
||||
e.message
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def test_setclassvariable
|
||||
assert_compiles '42', %q{
|
||||
class Foo
|
||||
@ -1686,6 +1700,21 @@ class TestZJIT < Test::Unit::TestCase
|
||||
}
|
||||
end
|
||||
|
||||
def test_setclassvariable_raises
|
||||
assert_compiles '"can\'t modify frozen #<Class:Foo>: Foo"', %q{
|
||||
class Foo
|
||||
def self.test = @@x = 42
|
||||
freeze
|
||||
end
|
||||
|
||||
begin
|
||||
Foo.test
|
||||
rescue FrozenError => e
|
||||
e.message
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def test_attr_reader
|
||||
assert_compiles '[4, 4]', %q{
|
||||
class C
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user