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:
Daniel Colson 2025-10-23 17:47:58 -04:00 committed by GitHub
parent 1d83553952
commit f33cd1289e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-10-23 21:48:31 +00:00
Merged-By: tekknolagi <donotemailthisaddress@bernsteinbear.com>

View File

@ -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