diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-07-03 08:42:28 -0400 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-07-11 14:25:54 -0400 |
| commit | 32090e2b8d4bd1c0ddfd6b4ee82927e935534eed (patch) | |
| tree | 8f8d74075f2cf034b8f052b27cdf42e4f2cf55b6 /test | |
| parent | aca42a24783e3a7d17eafb43a031e397bfb70323 (diff) | |
[ruby/prism] Add Node#breadth_first_search
https://github.com/ruby/prism/commit/1ffb141199
Diffstat (limited to 'test')
| -rw-r--r-- | test/prism/result/breadth_first_search_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/prism/result/breadth_first_search_test.rb b/test/prism/result/breadth_first_search_test.rb new file mode 100644 index 0000000000..e2e043a902 --- /dev/null +++ b/test/prism/result/breadth_first_search_test.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +module Prism + class BreadthFirstSearchTest < TestCase + def test_breadth_first_search + result = Prism.parse("[1 + 2, 2]") + found = + result.value.breadth_first_search do |node| + node.is_a?(IntegerNode) && node.value == 2 + end + + refute_nil found + assert_equal 8, found.start_offset + end + end +end |
