diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-23 04:19:24 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-23 04:19:24 +0000 |
commit | 163ab0a4da61699c84bba46cd9d7bdd6c67ba1e5 (patch) | |
tree | b3d60ff105b63c425773e4b8ad58627730a2f7ef /test/ruby | |
parent | a13486997a65320f3abcded92e9edc9433a42a43 (diff) | |
download | ruby-163ab0a4da61699c84bba46cd9d7bdd6c67ba1e5.tar.gz |
* bignum.c (rb_str_to_inum): must be ASCII compatible encoding as
well as String#hex and String#oct. [ruby-core:43566][Bug #6192]
* string.c (rb_must_asciicompat): check if ASCII compatible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_integer.rb | 7 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 7f8212ebf0..3f4add7f15 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -90,6 +90,13 @@ class TestInteger < Test::Unit::TestCase assert_equal(2 ** 50, Integer(2.0 ** 50)) assert_raise(TypeError) { Integer(nil) } + + bug6192 = '[ruby-core:43566]' + assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("utf-16be"))} + assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("utf-16le"))} + assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("utf-32be"))} + assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("utf-32le"))} + assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("iso-2022-jp"))} end def test_int_p diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 622ba9ea63..f8336679b5 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1465,6 +1465,13 @@ class TestString < Test::Unit::TestCase assert_equal(0x4000000000000000, "4611686018427387904".to_i(10)) assert_equal(1, "1__2".to_i(10)) assert_equal(1, "1_z".to_i(10)) + + bug6192 = '[ruby-core:43566]' + assert_raise(Encoding::CompatibilityError, bug6192) {"0".encode("utf-16be").to_i} + assert_raise(Encoding::CompatibilityError, bug6192) {"0".encode("utf-16le").to_i} + assert_raise(Encoding::CompatibilityError, bug6192) {"0".encode("utf-32be").to_i} + assert_raise(Encoding::CompatibilityError, bug6192) {"0".encode("utf-32le").to_i} + assert_raise(Encoding::CompatibilityError, bug6192) {"0".encode("iso-2022-jp").to_i} end def test_to_s |