summaryrefslogtreecommitdiff
path: root/test/ruby/test_case.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_case.rb')
-rw-r--r--test/ruby/test_case.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb
index 41a22038a0..98498dada6 100644
--- a/test/ruby/test_case.rb
+++ b/test/ruby/test_case.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require_relative 'envutil.rb'
class TestCase < Test::Unit::TestCase
def test_case
@@ -45,5 +46,42 @@ class TestCase < Test::Unit::TestCase
else
assert(false)
end
+
+ case "+"
+ when *%w/. +/
+ assert(true)
+ else
+ assert(false)
+ end
+
+ case
+ when *[], false
+ assert(false)
+ else
+ assert(true)
+ end
+
+ case
+ when *false, []
+ assert(true)
+ else
+ assert(false)
+ end
+
+ assert_raise(NameError) do
+ case
+ when false, *x, false
+ end
+ end
+ end
+
+ def test_deoptimization
+ assert_in_out_err(['-e', <<-EOS], '', %w[42], [])
+ class Symbol; undef ===; def ===(o); p 42; true; end; end; case :foo; when :foo; end
+ EOS
+
+ assert_in_out_err(['-e', <<-EOS], '', %w[42], [])
+ class Fixnum; undef ===; def ===(o); p 42; true; end; end; case 1; when 1; end
+ EOS
end
end