diff options
| author | ydah <t.yudai92@gmail.com> | 2024-09-10 00:13:24 +0900 |
|---|---|---|
| committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2024-09-11 09:28:55 +0900 |
| commit | 4e6091ce09154d735cca025a4d0130eecebbbc19 (patch) | |
| tree | cea93508f61b03a15b6f28b402ecaea980426aeb /test/ruby | |
| parent | 1adcc41b94d49899b1809fba119f74501fc992b1 (diff) | |
Implement WHILE and UNTIL NODE locations
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11579
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_ast.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index 8ecd384d58..8fcd2415a5 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -1380,6 +1380,22 @@ dummy assert_locations(node.children[-1].children[1].locations, [[1, 8, 1, 22], [1, 8, 1, 12], [1, 15, 1, 19]]) end + def test_while_locations + node = RubyVM::AbstractSyntaxTree.parse("while cond do 1 end") + assert_locations(node.children[-1].locations, [[1, 0, 1, 19], [1, 0, 1, 5], [1, 16, 1, 19]]) + + node = RubyVM::AbstractSyntaxTree.parse("1 while 2") + assert_locations(node.children[-1].locations, [[1, 0, 1, 9], [1, 2, 1, 7], nil]) + end + + def test_until_locations + node = RubyVM::AbstractSyntaxTree.parse("until cond do 1 end") + assert_locations(node.children[-1].locations, [[1, 0, 1, 19], [1, 0, 1, 5], [1, 16, 1, 19]]) + + node = RubyVM::AbstractSyntaxTree.parse("1 until 2") + assert_locations(node.children[-1].locations, [[1, 0, 1, 9], [1, 2, 1, 7], nil]) + end + private def assert_locations(locations, expected) ary = locations.map {|loc| loc && [loc.first_lineno, loc.first_column, loc.last_lineno, loc.last_column] } |
