diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-13 22:09:22 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-15 01:09:06 +0900 |
| commit | 864bb8680cee48a2bed85703dc2e4070728362d4 (patch) | |
| tree | c112ae4b3afc70ff40e8f82f54aca2823fe8a2be /test/ruby | |
| parent | e8896a31d48e5797df3878696dcb50aed85b87c2 (diff) | |
[Bug #19877] Named captures should take place from regexps in block
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8440
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_parse.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 5209a4839f..0f71e11f7e 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -970,6 +970,20 @@ x = __ENCODING__ assert_warning('') {eval("#{a} = 1; /(?<#{a}>)/ =~ ''")} end + def test_named_capture_in_block + [ + '(/(?<a>.*)/)', + '(;/(?<a>.*)/)', + '(%s();/(?<a>.*)/)', + '(%w();/(?<a>.*)/)', + '(1; (2; 3; (4; /(?<a>.*)/)))', + '(1+1; /(?<a>.*)/)', + ].each do |code| + token = Random.bytes(4).unpack1("H*") + assert_equal(token, eval("#{code} =~ #{token.dump}; a")) + end + end + def test_rescue_in_command_assignment bug = '[ruby-core:75621] [Bug #12402]' all_assertions(bug) do |a| |
