summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2022-10-01 17:44:28 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2022-10-08 17:59:11 +0900
commit4bfdf6d06ddbcf21345461038f2a9e3012f77268 (patch)
treec218b83b15c56b3a3727c5bd6a2d399564f01349 /test
parent4f24f3ea94e43d1021fdd8548480f130f5112b99 (diff)
Move `error` from top_stmts and top_stmt to stmt
By this change, syntax error is recovered smaller units. In the case below, "DEFN :bar" is same level with "CLASS :Foo" now. ``` 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/irb/test_color.rb5
-rw-r--r--test/ruby/test_ast.rb44
2 files changed, 27 insertions, 22 deletions
diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb
index dc394f9d68..8de03a5e8e 100644
--- a/test/irb/test_color.rb
+++ b/test/irb/test_color.rb
@@ -114,6 +114,11 @@ module TestIRB
"class bad; end" => "#{GREEN}class#{CLEAR} #{RED}#{REVERSE}bad#{CLEAR}; #{GREEN}end#{CLEAR}",
"def req(@a) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}@a#{CLEAR}) #{GREEN}end#{CLEAR}",
})
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0')
+ tests.merge!({
+ "def req(true) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}true#{CLEAR}#{RED}#{REVERSE})#{CLEAR} #{RED}#{REVERSE}end#{CLEAR}",
+ })
+ end
else
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
tests.merge!({
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index 033a09b4c0..cda325c1fd 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -981,30 +981,30 @@ dummy
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
+ (BLOCK@1:8-7:5 (BEGIN@1:8-1:8 nil)
+ (CLASS@2:2-4:5 (COLON2@2:8-2:11 nil :Foo) nil
+ (SCOPE@2:2-4:5
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))))))))
+ body: (BLOCK@2:11-4:5 (BEGIN@2:11-2:11 nil) (ERROR@3:4-4:5))))
+ (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