diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-05 01:38:47 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-05 01:38:47 +0000 |
| commit | a5737e58a7d5f2ae861a80c8216e027940ca87f7 (patch) | |
| tree | 6a80afa2e5bfd3c393835c64acbf9a7663d29fd3 /test/ruby/test_basicinstructions.rb | |
| parent | 3b2f10a705f0ee49c2817963c0cbe01275452103 (diff) | |
| download | ruby-a5737e58a7d5f2ae861a80c8216e027940ca87f7.tar.gz ruby-a5737e58a7d5f2ae861a80c8216e027940ca87f7.tar.xz ruby-a5737e58a7d5f2ae861a80c8216e027940ca87f7.zip | |
* compile.c (iseq_compile_each): &&= and ||= should return rhs.
[ruby-dev:39163] (#1996), [ruby-core:25143]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_basicinstructions.rb')
| -rw-r--r-- | test/ruby/test_basicinstructions.rb | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb index b3145be8b..8da193f11 100644 --- a/test/ruby/test_basicinstructions.rb +++ b/test/ruby/test_basicinstructions.rb @@ -499,52 +499,73 @@ class TestBasicInstructions < Test::Unit::TestCase end class OP - attr_accessor :x + attr_reader :x + def x=(x) + @x = x + :Bug1996 + end + Bug1996 = '[ruby-dev:39163], [ruby-core:25143]' end def test_opassign x = nil - x ||= 1 + assert_equal 1, x ||= 1 assert_equal 1, x - x &&= 2 + assert_equal 2, x &&= 2 assert_equal 2, x - x ||= 3 + assert_equal 2, x ||= 3 assert_equal 2, x - x &&= 4 + assert_equal 4, x &&= 4 + assert_equal 4, x + assert_equal 5, x += 1 + assert_equal 5, x + assert_equal 4, x -= 1 assert_equal 4, x y = OP.new y.x = nil - y.x ||= 1 + assert_equal 1, y.x ||= 1, OP::Bug1996 assert_equal 1, y.x - y.x &&= 2 + assert_equal 2, y.x &&= 2, OP::Bug1996 assert_equal 2, y.x - y.x ||= 3 + assert_equal 2, y.x ||= 3 assert_equal 2, y.x - y.x &&= 4 + assert_equal 4, y.x &&= 4, OP::Bug1996 + assert_equal 4, y.x + assert_equal 5, y.x += 1, OP::Bug1996 + assert_equal 5, y.x + assert_equal 4, y.x -= 1, OP::Bug1996 assert_equal 4, y.x z = OP.new z.x = y z.x.x = nil - z.x.x ||= 1 + assert_equal 1, z.x.x ||= 1, OP::Bug1996 assert_equal 1, z.x.x - z.x.x &&= 2 + assert_equal 2, z.x.x &&= 2, OP::Bug1996 assert_equal 2, z.x.x - z.x.x ||= 3 + assert_equal 2, z.x.x ||= 3 assert_equal 2, z.x.x - z.x.x &&= 4 + assert_equal 4, z.x.x &&= 4, OP::Bug1996 + assert_equal 4, z.x.x + assert_equal 5, z.x.x += 1, OP::Bug1996 + assert_equal 5, z.x.x + assert_equal 4, z.x.x -= 1, OP::Bug1996 assert_equal 4, z.x.x a = [] a[0] = nil - a[0] ||= 1 + assert_equal 1, a[0] ||= 1 assert_equal 1, a[0] - a[0] &&= 2 + assert_equal 2, a[0] &&= 2 assert_equal 2, a[0] - a[0] ||= 3 + assert_equal 2, a[0] ||= 3 assert_equal 2, a[0] - a[0] &&= 4 + assert_equal 4, a[0] &&= 4 + assert_equal 4, a[0] + assert_equal 5, a[0] += 1 + assert_equal 5, a[0] + assert_equal 4, a[0] -= 1 assert_equal 4, a[0] end |
