diff options
author | Jeremy Evans <code@jeremyevans.net> | 2020-03-27 15:08:52 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2020-04-10 00:29:05 -0700 |
commit | 900e83b50115afda3f79712310e4cb95e4508972 (patch) | |
tree | 07c581a76af2b2e135f034eb52a9e81401e6e131 /bootstraptest/test_insns.rb | |
parent | defc0ee9d172c2caa8742cc682a8aa389942d6ef (diff) | |
download | ruby-900e83b50115afda3f79712310e4cb95e4508972.tar.gz |
Turn class variable warnings into exceptions
This changes the following warnings:
* warning: class variable access from toplevel
* warning: class variable @foo of D is overtaken by C
into RuntimeErrors. Handle defined?(@@foo) at toplevel
by returning nil instead of raising an exception (the previous
behavior warned before returning nil when defined? was used).
Refactor the specs to avoid the warnings even in older versions.
The specs were checking for the warnings, but the purpose of
the related specs as evidenced from their description is to
test for behavior, not for warnings.
Fixes [Bug #14541]
Diffstat (limited to 'bootstraptest/test_insns.rb')
-rw-r--r-- | bootstraptest/test_insns.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb index 1269d7d013..cb54d0d3f7 100644 --- a/bootstraptest/test_insns.rb +++ b/bootstraptest/test_insns.rb @@ -64,8 +64,8 @@ tests = [ [ 'setinstancevariable', %q{ @x = true }, ], [ 'getinstancevariable', %q{ @x = true; @x }, ], - [ 'setclassvariable', %q{ @@x = true }, ], - [ 'getclassvariable', %q{ @@x = true; @@x }, ], + [ 'setclassvariable', %q{ class A; @@x = true; end }, ], + [ 'getclassvariable', %q{ class A; @@x = true; @@x end }, ], [ 'setconstant', %q{ X = true }, ], [ 'setconstant', %q{ Object::X = true }, ], |