summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2022-10-01 17:53:39 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2022-10-08 17:59:11 +0900
commit3531086095aed9d2898de686bc67ab3a6c2192de (patch)
tree4113b11d14bf2274076b469ceeef1f72f1ac9cba /test/ruby
parent4bfdf6d06ddbcf21345461038f2a9e3012f77268 (diff)
"expr_value" can be error
So that "IF" node is kept in the case below ``` def m if end ``` [Feature #19013]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6512
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_ast.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index cda325c1fd..ebb080b101 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -1007,4 +1007,39 @@ dummy
body: nil))))))
EXP
end
+
+ def test_error_tolerant_expr_value_can_be_error
+ node = RubyVM::AbstractSyntaxTree.parse(<<~STR, error_tolerant: true)
+ def m
+ if
+ end
+ STR
+
+ str = ""
+ PP.pp(node, str)
+ assert_equal(<<~EXP, str)
+ (SCOPE@1:0-3:3
+ tbl: []
+ args: nil
+ body:
+ (DEFN@1:0-3:3
+ mid: :m
+ body:
+ (SCOPE@1:0-3:3
+ tbl: []
+ args:
+ (ARGS@1:5-1:5
+ pre_num: 0
+ pre_init: nil
+ opt: nil
+ first_post: nil
+ post_num: 0
+ post_init: nil
+ rest: nil
+ kw: nil
+ kwrest: nil
+ block: nil)
+ body: (IF@2:2-3:3 (ERROR@3:0-3:3) nil nil))))
+ EXP
+ end
end