diff options
author | Jeremy Evans <[email protected]> | 2020-03-27 15:08:52 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2020-04-10 00:29:05 -0700 |
commit | 900e83b50115afda3f79712310e4cb95e4508972 (patch) | |
tree | 07c581a76af2b2e135f034eb52a9e81401e6e131 /bootstraptest/test_syntax.rb | |
parent | defc0ee9d172c2caa8742cc682a8aa389942d6ef (diff) |
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]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2987
Diffstat (limited to 'bootstraptest/test_syntax.rb')
-rw-r--r-- | bootstraptest/test_syntax.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb index a111990a1f..fa27bf2aeb 100644 --- a/bootstraptest/test_syntax.rb +++ b/bootstraptest/test_syntax.rb @@ -268,8 +268,10 @@ assert_equal %q{}, %q{ defined?(@@a) } assert_equal %q{class variable}, %q{ - @@a = 1 - defined?(@@a) + class A + @@a = 1 + defined?(@@a) + end } assert_equal %q{}, %q{ defined?($a) |