summaryrefslogtreecommitdiff
path: root/test/ruby/test_fixnum.rb
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-29 01:07:15 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-29 01:07:15 +0000
commit640420f7044405cec4b1e6486caca4def5f80a45 (patch)
treefe7c8c31a09aaf3ccf0f483c9926c0528bde2513 /test/ruby/test_fixnum.rb
parent0d530b2392585cc535fb905f9ba4467257ef289c (diff)
* numeric.c (bit_coerce): A Fixnum and a Bignum are only permitted for
bitwise arithmetic with a Fixnum. #1792 * test/ruby/test_fixnum.rb: add tests for the above change. * bignum.c (bit_coerce): A Fixnum and a Bignum are only permitted for bitwise arithmetic with a Bignum. #1792 * test/ruby/test_bignum.rb: add tests for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_fixnum.rb')
-rw-r--r--test/ruby/test_fixnum.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb
index 2aee65c211..95a273bb94 100644
--- a/test/ruby/test_fixnum.rb
+++ b/test/ruby/test_fixnum.rb
@@ -229,4 +229,46 @@ class TestFixnum < Test::Unit::TestCase
assert(!(1.send(:<=, 0.0)))
assert_raise(ArgumentError) { 1.send(:<=, nil) }
end
+
+ class DummyNumeric < Numeric
+ def to_int
+ 1
+ end
+ end
+
+ def test_and_with_float
+ assert_raise(TypeError) { 1 & 1.5 }
+ end
+
+ def test_and_with_rational
+ assert_raise(TypeError, "#1792") { 1 & Rational(3, 2) }
+ end
+
+ def test_and_with_nonintegral_numeric
+ assert_raise(TypeError, "#1792") { 1 & DummyNumeric.new }
+ end
+
+ def test_or_with_float
+ assert_raise(TypeError) { 1 | 1.5 }
+ end
+
+ def test_or_with_rational
+ assert_raise(TypeError, "#1792") { 1 | Rational(3, 2) }
+ end
+
+ def test_or_with_nonintegral_numeric
+ assert_raise(TypeError, "#1792") { 1 | DummyNumeric.new }
+ end
+
+ def test_xor_with_float
+ assert_raise(TypeError) { 1 ^ 1.5 }
+ end
+
+ def test_xor_with_rational
+ assert_raise(TypeError, "#1792") { 1 ^ Rational(3, 2) }
+ end
+
+ def test_xor_with_nonintegral_numeric
+ assert_raise(TypeError, "#1792") { 1 ^ DummyNumeric.new }
+ end
end