summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_array.rb2
-rw-r--r--test/ruby/test_bignum.rb2
-rw-r--r--test/ruby/test_complex.rb3
-rw-r--r--test/ruby/test_enum.rb2
-rw-r--r--test/ruby/test_enumerator.rb12
-rw-r--r--test/ruby/test_exception.rb4
-rw-r--r--test/ruby/test_time.rb5
7 files changed, 30 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index ea551db..74da8c1 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1543,6 +1543,8 @@ class TestArray < Test::Unit::TestCase
[[:first_one, :ok], :not_ok].to_h
}
assert_equal "wrong element type Symbol at 1 (expected array)", e.message
+ array = [eval("class C\u{1f5ff}; self; end").new]
+ assert_raise_with_message(TypeError, /C\u{1f5ff}/) {array.to_h}
e = assert_raise(ArgumentError) {
[[:first_one, :ok], [1, 2], [:not_ok]].to_h
}
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index 012a562..d057e39 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -568,6 +568,8 @@ class TestBignum < Test::Unit::TestCase
def test_coerce
assert_equal([T64P, T31P], T31P.coerce(T64P))
assert_raise(TypeError) { T31P.coerce(nil) }
+ obj = eval("class C\u{1f5ff}; self; end").new
+ assert_raise_with_message(TypeError, /C\u{1f5ff}/) { T31P.coerce(obj) }
end
def test_abs
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 8da0e51..de3bb05 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -427,6 +427,9 @@ class Complex_Test < Test::Unit::TestCase
assert_equal([Complex(Rational(2)),Complex(1)],
Complex(1).coerce(Rational(2)))
assert_equal([Complex(2),Complex(1)], Complex(1).coerce(Complex(2)))
+
+ obj = eval("class C\u{1f5ff}; self; end").new
+ assert_raise_with_message(TypeError, /C\u{1f5ff}/) { Complex(1).coerce(obj) }
end
class ObjectX
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index 26c8815..10692e6 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -457,6 +457,8 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([[1, 3], [2, 4], [3, nil], [1, nil], [2, nil]], @obj.zip(ary))
def ary.to_ary; [5, 6]; end
assert_equal([[1, 5], [2, 6], [3, nil], [1, nil], [2, nil]], @obj.zip(ary))
+ obj = eval("class C\u{1f5ff}; self; end").new
+ assert_raise_with_message(TypeError, /C\u{1f5ff}/) {(1..1).zip(obj)}
end
def test_take
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index b5ced3b..91c91a4 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -433,6 +433,18 @@ class TestEnumerator < Test::Unit::TestCase
assert_raise(RuntimeError) {
g.__send__ :initialize, proc { |y| y << 4 << 5 }
}
+
+ g = Enumerator::Generator.new(proc {|y| y << 4 << 5; :foo })
+ a = []
+ assert_equal(:foo, g.each {|x| a << x })
+ assert_equal([4, 5], a)
+
+ assert_raise(LocalJumpError) {Enumerator::Generator.new}
+ assert_raise(TypeError) {Enumerator::Generator.new(1)}
+ obj = eval("class C\u{1f5ff}; self; end").new
+ assert_raise_with_message(TypeError, /C\u{1f5ff}/) {
+ Enumerator::Generator.new(obj)
+ }
end
def test_generator_args
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index b4567d9..af69d86 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -302,6 +302,10 @@ class TestException < Test::Unit::TestCase
assert_raise_with_message(TypeError, /C\u{4032}/) do
[*o]
end
+ obj = eval("class C\u{1f5ff}; self; end").new
+ assert_raise_with_message(TypeError, /C\u{1f5ff}/) do
+ Class.new {include obj}
+ end
end
def test_errat
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index f4fb5bf..97c6288 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -417,6 +417,11 @@ class TestTime < Test::Unit::TestCase
}
}
assert_raise(ArgumentError) { m.sleep(-1) }
+ assert_raise(TypeError) { m.sleep("") }
+ assert_raise(TypeError) { sleep("") }
+ obj = eval("class C\u{1f5ff}; self; end").new
+ assert_raise_with_message(TypeError, /C\u{1f5ff}/) {m.sleep(obj)}
+ assert_raise_with_message(TypeError, /C\u{1f5ff}/) {sleep(obj)}
end
def test_to_f