test_numeric.rb: default_external

* test/ruby/test_numeric.rb (test_coerce): manage
  Encoding.default_external.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-01-15 09:52:23 +00:00
Родитель 251de3209b
Коммит 82ab2d6d6a
1 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -1,4 +1,5 @@
require 'test/unit'
require_relative 'envutil'
class TestNumeric < Test::Unit::TestCase
class DummyNumeric < Numeric
@ -20,10 +21,18 @@ class TestNumeric < Test::Unit::TestCase
assert_raise_with_message(TypeError, /can't be coerced into /) {1|:foo}
assert_raise_with_message(TypeError, /can't be coerced into /) {1^:foo}
assert_raise_with_message(TypeError, /:\u{3042}/) {1+:"\u{3042}"}
assert_raise_with_message(TypeError, /:\u{3042}/) {1&:"\u{3042}"}
assert_raise_with_message(TypeError, /:\u{3042}/) {1|:"\u{3042}"}
assert_raise_with_message(TypeError, /:\u{3042}/) {1^:"\u{3042}"}
EnvUtil.with_default_external(Encoding::UTF_8) do
assert_raise_with_message(TypeError, /:\u{3042}/) {1+:"\u{3042}"}
assert_raise_with_message(TypeError, /:\u{3042}/) {1&:"\u{3042}"}
assert_raise_with_message(TypeError, /:\u{3042}/) {1|:"\u{3042}"}
assert_raise_with_message(TypeError, /:\u{3042}/) {1^:"\u{3042}"}
end
EnvUtil.with_default_external(Encoding::US_ASCII) do
assert_raise_with_message(TypeError, /:"\\u3042"/) {1+:"\u{3042}"}
assert_raise_with_message(TypeError, /:"\\u3042"/) {1&:"\u{3042}"}
assert_raise_with_message(TypeError, /:"\\u3042"/) {1|:"\u{3042}"}
assert_raise_with_message(TypeError, /:"\\u3042"/) {1^:"\u{3042}"}
end
end
def test_dummynumeric