diff options
| author | Daniel Colson <danieljamescolson@gmail.com> | 2025-10-23 17:47:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-23 14:47:58 -0700 |
| commit | f33cd1289e75c7091e61e54792a2b7e1f84ea697 (patch) | |
| tree | 549d45526a7de152770fa4b4f679f40ce724fa50 /test/ruby/test_zjit.rb | |
| parent | 1d835539524cab6cd8b9210f34690e5e5e705f39 (diff) | |
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
Diffstat (limited to 'test/ruby/test_zjit.rb')
| -rw-r--r-- | test/ruby/test_zjit.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 13c7817017..e76e140ba1 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -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 |
