diff options
-rw-r--r-- | numeric.c | 1 | ||||
-rw-r--r-- | test/ruby/test_float.rb | 3 |
2 files changed, 4 insertions, 0 deletions
@@ -233,6 +233,7 @@ rb_num_get_rounding_option(VALUE opts) str = rb_check_string_type(rounding); if (NIL_P(str)) goto invalid; } + rb_must_asciicompat(str); s = RSTRING_PTR(str); switch (RSTRING_LEN(str)) { case 2: diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 7cbf3b5a8f..a94bbce49e 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -764,6 +764,9 @@ class TestFloat < Test::Unit::TestCase assert_raise_with_message(ArgumentError, /xxx/) { 1.0.round(half: "\0xxx") } + assert_raise_with_message(Encoding::CompatibilityError, /ASCII incompatible/) { + 1.0.round(half: "up".force_encoding("utf-16be")) + } end def test_Float |