From bd494ae79b18e260b0123bf40ddc1c694d7b25b8 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 15 Jul 2019 12:59:53 +0900 Subject: [PATCH] add tests for "break" in lambda. --- test/ruby/test_lambda.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index 3ac2e4cb98..a30ea483e4 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -157,6 +157,21 @@ class TestLambdaParameters < Test::Unit::TestCase assert_equal(42, return_in_callee(42), feature8693) end + def break_in_current(val) + 1.tap(&->(*) {break 0}) + val + end + + def break_in_callee(val) + yield_block(&->(*) {break 0}) + val + end + + def test_break + assert_equal(42, break_in_current(42)) + assert_equal(42, break_in_callee(42)) + end + def test_do_lambda_source_location exp_lineno = __LINE__ + 3 lmd = ->(x,