summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2022-10-01 17:19:34 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2022-10-08 17:59:11 +0900
commit4f24f3ea94e43d1021fdd8548480f130f5112b99 (patch)
tree8cfe7d2e7dd0dcdabc31aa7a781858b9364a1291 /test
parent342d4c16d963408905fd08118d1908fe197f2364 (diff)
Treat "end" as reserved word with consideration of indent
"end" after "." or "::" is treated as local variable or method, see `EXPR_DOT_bit` for detail. However this "changes" where `bar` method is defined. In the example below it is not module Z but class Foo. ``` module Z class Foo foo. end def bar end end ``` [Feature #19013]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6512
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_ast.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index 2f05bf97a1..033a09b4c0 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -956,4 +956,55 @@ dummy
body: (VCALL@2:2-2:3 :a))))
EXP
end
+
+ def test_error_tolerant_treat_end_as_keyword_based_on_indent
+ node = RubyVM::AbstractSyntaxTree.parse(<<~STR, error_tolerant: true)
+ module Z
+ class Foo
+ foo.
+ end
+
+ def bar
+ end
+ end
+ STR
+
+ str = ""
+ PP.pp(node, str)
+ assert_equal(<<~EXP, str)
+ (SCOPE@1:0-8:3
+ tbl: []
+ args: nil
+ body:
+ (MODULE@1:0-8:3 (COLON2@1:7-1:8 nil :Z)
+ (SCOPE@1:0-8:3
+ tbl: []
+ args: nil
+ body:
+ (BLOCK@1:8-8:3 (BEGIN@1:8-1:8 nil)
+ (CLASS@2:2-8:3 (COLON2@2:8-2:11 nil :Foo) nil
+ (SCOPE@2:2-8:3
+ tbl: []
+ args: nil
+ body:
+ (DEFN@6:2-7:5
+ mid: :bar
+ body:
+ (SCOPE@6:2-7:5
+ tbl: []
+ args:
+ (ARGS@6:9-6:9
+ 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: nil))))))))
+ EXP
+ end
end