From 050b932152fb3004c78af223186afe1aa397f06f Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Wed, 7 Aug 2019 22:15:45 -0400 Subject: Iseq#to_binary: Add support for NoMatchingPatternError and TypeError Binary dumping the iseq for `case foo in []; end` used to crash as there was no handling for these exception classes. Pattern matching generates these classes as operands to `putobject`. [Bug #16088] Closes: https://github.com/ruby/ruby/pull/2325 --- test/ruby/test_iseq.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index b4d44e5f28..1a1abc627b 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -433,6 +433,16 @@ class TestISeq < Test::Unit::TestCase assert_iseq_to_binary("@x ||= (1..2)") end + def test_to_binary_pattern_matching + code = "case foo in []; end" + iseq = compile(code) + assert_include(iseq.disasm, "TypeError") + assert_include(iseq.disasm, "NoMatchingPatternError") + EnvUtil.suppress_warning do + assert_iseq_to_binary(code, "[Feature #14912]") + end + end + def test_to_binary_line_info assert_iseq_to_binary("#{<<~"begin;"}\n#{<<~'end;'}", '[Bug #14660]').eval begin; -- cgit v1.2.3