diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-19 07:13:01 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-19 07:13:01 +0000 |
commit | 610b5d79759706fb2688b652da1c21006f9d4af2 (patch) | |
tree | 869b868b1ba82da7c5508e4815030c963a1ad3e6 /sample | |
parent | 91de9894fc5898b78878f8d4e9588794dd5bccc9 (diff) |
* variable.c (rb_cvar_set): class variables become private to the
particular class/module. [Ruby2]
* variable.c (rb_cvar_get): ditto.
* io.c (rb_io_sync): need not to check writable. [ruby-core:02674]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r-- | sample/test.rb | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/sample/test.rb b/sample/test.rb index d61b1e7098..ac0dfd0aea 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1979,7 +1979,7 @@ $_ = foobar test_ok($_ == foobar) class Gods - @@rule = "Uranus" + @@rule = "Uranus" # private to Gods def ruler0 @@rule end @@ -1995,25 +1995,29 @@ class Gods end module Olympians - @@rule ="Zeus" - def ruler3 + @@rule ="Zeus" + def ruler3 @@rule - end + end end class Titans < Gods - @@rule = "Cronus" - include Olympians # OK to cause warning (intentional) + @@rule = "Cronus" # do not affect @@rule in Gods + include Olympians + def ruler4 + @@rule + end end -test_ok(Gods.new.ruler0 == "Cronus") -test_ok(Gods.ruler1 == "Cronus") -test_ok(Gods.ruler2 == "Cronus") -test_ok(Titans.ruler1 == "Cronus") -test_ok(Titans.ruler2 == "Cronus") +test_ok(Gods.new.ruler0 == "Uranus") +test_ok(Gods.ruler1 == "Uranus") +test_ok(Gods.ruler2 == "Uranus") +test_ok(Titans.ruler1 == "Uranus") +test_ok(Titans.ruler2 == "Uranus") atlas = Titans.new -test_ok(atlas.ruler0 == "Cronus") +test_ok(atlas.ruler0 == "Uranus") test_ok(atlas.ruler3 == "Zeus") +test_ok(atlas.ruler4 == "Cronus") test_check "trace" $x = 1234 |