summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/t/proc.rb17
-rw-r--r--test/t/range.rb14
-rw-r--r--test/t/string.rb10
3 files changed, 36 insertions, 5 deletions
diff --git a/test/t/proc.rb b/test/t/proc.rb
index 151e1df86..1be73c99a 100644
--- a/test/t/proc.rb
+++ b/test/t/proc.rb
@@ -55,6 +55,23 @@ assert('Proc#call', '15.2.17.4.3') do
assert_equal 5, a2
end
+assert('Proc#call proc args pos block') do
+ pr = proc {|a,b,&c|
+ [a, b, c.class, c&&c.call(:x)]
+ }
+ assert_equal [nil, nil, Proc, :proc], (pr.call(){ :proc })
+ assert_equal [1, nil, Proc, :proc], (pr.call(1){ :proc })
+ assert_equal [1, 2, Proc, :proc], (pr.call(1, 2){ :proc })
+ assert_equal [1, 2, Proc, :proc], (pr.call(1, 2, 3){ :proc })
+ assert_equal [1, 2, Proc, :proc], (pr.call(1, 2, 3, 4){ :proc })
+
+ assert_equal [nil, nil, Proc, :x], (pr.call(){|x| x})
+ assert_equal [1, nil, Proc, :x], (pr.call(1){|x| x})
+ assert_equal [1, 2, Proc, :x], (pr.call(1, 2){|x| x})
+ assert_equal [1, 2, Proc, :x], (pr.call(1, 2, 3){|x| x})
+ assert_equal [1, 2, Proc, :x], (pr.call(1, 2, 3, 4){|x| x})
+end
+
assert('Proc#return_does_not_break_self') do
class TestClass
attr_accessor :block
diff --git a/test/t/range.rb b/test/t/range.rb
index deaa3997f..b35da40ab 100644
--- a/test/t/range.rb
+++ b/test/t/range.rb
@@ -74,6 +74,20 @@ assert('Range#member?', '15.2.14.4.11') do
assert_false a.member?(20)
end
+assert('Range#to_s', '15.2.14.4.12') do
+ assert_equal "0..1", (0..1).to_s
+ assert_equal "0...1", (0...1).to_s
+ assert_equal "a..b", ("a".."b").to_s
+ assert_equal "a...b", ("a"..."b").to_s
+end
+
+assert('Range#inspect', '15.2.14.4.13') do
+ assert_equal "0..1", (0..1).inspect
+ assert_equal "0...1", (0...1).inspect
+ assert_equal "\"a\"..\"b\"", ("a".."b").inspect
+ assert_equal "\"a\"...\"b\"", ("a"..."b").inspect
+end
+
assert('Range#eql?', '15.2.14.4.14') do
assert_true (1..10).eql? (1..10)
assert_false (1..10).eql? (1..100)
diff --git a/test/t/string.rb b/test/t/string.rb
index 04f90fb45..a2a020a79 100644
--- a/test/t/string.rb
+++ b/test/t/string.rb
@@ -475,6 +475,11 @@ assert('String#upcase!', '15.2.10.5.43') do
assert_equal 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', b
end
+assert('String#inspect', '15.2.10.5.46') do
+ ("\1" * 100).inspect # should not raise an exception - regress #1210
+ assert_equal "\"\\000\"", "\0".inspect
+end
+
# Not ISO specified
assert('String interpolation (mrb_str_concat for shared strings)') do
@@ -506,8 +511,3 @@ assert('String#each_byte') do
assert_equal bytes1, bytes2
end
-
-assert('String#inspect') do
- ("\1" * 100).inspect # should not raise an exception - regress #1210
- assert_equal "\"\\000\"", "\0".inspect
-end