diff options
Diffstat (limited to 'test/ruby/test_enum.rb')
| -rw-r--r-- | test/ruby/test_enum.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index f7c8f012d8..32ec4f5779 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -69,11 +69,11 @@ class TestEnumerable < Test::Unit::TestCase assert_equal(['z', 42, nil], [:a, 'b', 'z', :c, 42, nil].grep_v(/[a-d]/), bug17030) assert_equal('match', $1, bug17030) - regexp = Regexp.new('x') - assert_equal([], @obj.grep(regexp), bug17030) # sanity check - def regexp.===(other) - true - end + regexp = Class.new(Regexp) { + def ===(other) + true + end + }.new('x') assert_equal([1, 2, 3, 1, 2], @obj.grep(regexp), bug17030) o = Object.new @@ -843,6 +843,8 @@ class TestEnumerable < Test::Unit::TestCase end def test_callcc + omit 'requires callcc support' unless respond_to?(:callcc) + assert_raise(RuntimeError) do c = nil @obj.sort_by {|x| callcc {|c2| c ||= c2 }; x } @@ -1346,4 +1348,12 @@ class TestEnumerable < Test::Unit::TestCase klass.new.grep(/(b.)/) { svars << $1 } assert_equal(["ba", "ba"], svars) end + + def test_all_fast + data = { "key" => { "key2" => 1 } } + kk = vv = nil + data.all? { |(k, v)| kk, vv = k, v } + assert_equal(kk, "key") + assert_equal(vv, { "key2" => 1 }) + end end |
