Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions test/-ext-/symbol/test_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,20 @@ def test_attrset

def test_check_id_invalid_type
cx = EnvUtil.labeled_class("X\u{1f431}")
assert_raise_with_message(TypeError, /X\u{1F431}/) {
Bug::Symbol.pinneddown?(cx)
}
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(TypeError, /X\u{1F431}/) {
Bug::Symbol.pinneddown?(cx)
}
end
end

def test_check_symbol_invalid_type
cx = EnvUtil.labeled_class("X\u{1f431}")
assert_raise_with_message(TypeError, /X\u{1F431}/) {
Bug::Symbol.find(cx)
}
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(TypeError, /X\u{1F431}/) {
Bug::Symbol.find(cx)
}
end
end

def test_const_name_type
Expand Down
8 changes: 5 additions & 3 deletions test/ruby/test_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,11 @@ def xyzzy
def test_namescope_error_message
m = Module.new
o = m.module_eval "class A\u{3042}; self; end.new"
assert_raise_with_message(TypeError, /A\u{3042}/) {
o::Foo
}
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(TypeError, /A\u{3042}/) {
o::Foo
}
end
end

def test_redefinition_mismatch
Expand Down
4 changes: 3 additions & 1 deletion test/ruby/test_float.rb
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,9 @@ def o.to_f; inf = Float::INFINITY; inf/inf; end
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-32le"))}
assert_raise(Encoding::CompatibilityError) {Float("0".encode("iso-2022-jp"))}

assert_raise_with_message(ArgumentError, /\u{1f4a1}/) {Float("\u{1f4a1}")}
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(ArgumentError, /\u{1f4a1}/) {Float("\u{1f4a1}")}
end
end

def test_invalid_str
Expand Down
4 changes: 3 additions & 1 deletion test/ruby/test_integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ def obj.to_i; "str"; end
assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("utf-32le"))}
assert_raise(Encoding::CompatibilityError, bug6192) {Integer("0".encode("iso-2022-jp"))}

assert_raise_with_message(ArgumentError, /\u{1f4a1}/) {Integer("\u{1f4a1}")}
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(ArgumentError, /\u{1f4a1}/) {Integer("\u{1f4a1}")}
end

obj = Struct.new(:s).new(%w[42 not-an-integer])
def obj.to_str; s.shift; end
Expand Down
13 changes: 9 additions & 4 deletions test/ruby/test_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,10 @@ def o.bar; end
assert_raise(TypeError) { m.bind(Object.new) }

cx = EnvUtil.labeled_class("X\u{1f431}")
assert_raise_with_message(TypeError, /X\u{1f431}/) do
o.method(cx)
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(TypeError, /X\u{1f431}/) do
o.method(cx)
end
end
end

Expand Down Expand Up @@ -315,9 +317,12 @@ def o.bar; :bar; end
assert_raise(TypeError) do
Class.new.class_eval { define_method(:bar, o.method(:bar)) }
end

cx = EnvUtil.labeled_class("X\u{1f431}")
assert_raise_with_message(TypeError, /X\u{1F431}/) do
Class.new {define_method(cx) {}}
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(TypeError, /X\u{1F431}/) do
Class.new {define_method(cx) {}}
end
end
end

Expand Down
5 changes: 4 additions & 1 deletion test/ruby/test_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,11 @@ def test_const_set_invalid_name
assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-16le"), :foo) }
assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-32be"), :foo) }
assert_raise(NameError) { c1.const_set("X\u{3042}".encode("utf-32le"), :foo) }

cx = EnvUtil.labeled_class("X\u{3042}")
assert_raise_with_message(TypeError, /X\u{3042}/) { c1.const_set(cx, :foo) }
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(TypeError, /X\u{3042}/) { c1.const_set(cx, :foo) }
end
end

def test_const_get_invalid_name
Expand Down
20 changes: 12 additions & 8 deletions test/ruby/test_numeric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,24 @@ def test_coerce
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_internal(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}"}

assert_raise_with_message(TypeError, /:\u{3044}/) {1+"\u{3044}".to_sym}
assert_raise_with_message(TypeError, /:\u{3044}/) {1&"\u{3044}".to_sym}
assert_raise_with_message(TypeError, /:\u{3044}/) {1|"\u{3044}".to_sym}
assert_raise_with_message(TypeError, /:\u{3044}/) {1^"\u{3044}".to_sym}
end

EnvUtil.with_default_internal(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
assert_raise_with_message(TypeError, /:\u{3044}/) {1+"\u{3044}".to_sym}
assert_raise_with_message(TypeError, /:\u{3044}/) {1&"\u{3044}".to_sym}
assert_raise_with_message(TypeError, /:\u{3044}/) {1|"\u{3044}".to_sym}
assert_raise_with_message(TypeError, /:\u{3044}/) {1^"\u{3044}".to_sym}

bug10711 = '[ruby-core:67405] [Bug #10711]'
exp = "1.2 can't be coerced into Integer"
Expand Down
9 changes: 7 additions & 2 deletions test/ruby/test_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,19 @@ def test_rlimit_name
}
assert_raise(ArgumentError) { Process.getrlimit(:FOO) }
assert_raise(ArgumentError) { Process.getrlimit("FOO") }
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.getrlimit("\u{30eb 30d3 30fc}") }

EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.getrlimit("\u{30eb 30d3 30fc}") }
end
end

def test_rlimit_value
return unless rlimit_exist?
assert_raise(ArgumentError) { Process.setrlimit(:FOO, 0) }
assert_raise(ArgumentError) { Process.setrlimit(:CORE, :FOO) }
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.setrlimit("\u{30eb 30d3 30fc}", 0) }
EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.setrlimit("\u{30eb 30d3 30fc}", 0) }
end
assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) { Process.setrlimit(:CORE, "\u{30eb 30d3 30fc}") }
with_tmpchdir do
s = run_in_child(<<-'End')
Expand Down
10 changes: 7 additions & 3 deletions test/ruby/test_rational.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ def test_conv
assert_equal(Rational(111, 1000), Rational('1.11e-1'))
assert_raise(TypeError){Rational(nil)}
assert_raise(ArgumentError){Rational('')}
assert_raise_with_message(ArgumentError, /\u{221a 2668}/) {
Rational("\u{221a 2668}")
}

EnvUtil.with_default_internal(Encoding::UTF_8) do
assert_raise_with_message(ArgumentError, /\u{221a 2668}/) {
Rational("\u{221a 2668}")
}
end

assert_warning('') {
assert_predicate(Rational('1e-99999999999999999999'), :zero?)
}
Expand Down