diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-15 23:13:16 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-15 23:13:16 +0900 |
commit | e8c62836a6292bf2f691de458b24ea50c51b452a (patch) | |
tree | efa07f54f1a6eeebffb1f3a9813197e646f2c56c /test | |
parent | eeb99fb52500b571b1239442a7d17d335cfde060 (diff) | |
download | ruby-e8c62836a6292bf2f691de458b24ea50c51b452a.tar.gz |
IO#set_encoding_by_bom should err when encoding is already set
Except for ASCII-8BIT. [Bug #16422]
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io_m17n.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 022ff330b5..e5b0ef0585 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -2102,6 +2102,9 @@ EOT File.open(path, "rb") {|f| assert_equal(Encoding.find(name), f.set_encoding_by_bom) } + File.open(path, "rb", encoding: "iso-8859-1") {|f| + assert_raise(ArgumentError) {f.set_encoding_by_bom} + } } end end @@ -2114,6 +2117,10 @@ EOT bug3407 = '[ruby-core:30641]' result = File.read(path, encoding: 'BOM|UTF-8') assert_equal("a", result.b, bug3407) + + File.open(path, "rb", encoding: "iso-8859-1") {|f| + assert_raise(ArgumentError) {f.set_encoding_by_bom} + } } end @@ -2148,6 +2155,9 @@ EOT File.open(path, "rb") {|f| assert_nil(f.set_encoding_by_bom) } + File.open(path, "rb", encoding: "iso-8859-1") {|f| + assert_raise(ArgumentError) {f.set_encoding_by_bom} + } } end |