summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2024-02-05 13:14:56 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2024-02-20 17:33:58 +0900
commit20dbc7a5f4098ec7612192c2b65bdc970eab6055 (patch)
treee62335330f0d8848207e8870215c87177fc944e2 /test
parent89cfc1520717257073012ec07105c551e4b8af7c (diff)
Skip `test_filepath` of "unparser/corpus/literal/def.txt"
The previous commit changes Ripper lex state behavior of `tLABEL`. For example, Ripper lex state for the second `bar` was changed by the previous commit. ``` def foo(bar: bar()) end ``` Before the commit, Ripper didn’t add label `bar` id to `vtable` because `formal_argument` function for Ripper didn’t return id but returned `VALUE lhs`. Therefore Ripper didn’t `SET_LEX_STATE(EXPR_END|EXPR_LABEL)` for following `bar` in `parse_ident` because `lvar_defined` for following `bar` was not true. Currently Ripper does `SET_LEX_STATE(EXPR_END|EXPR_LABEL)` then the result of this test case is changed like below. ``` Prism::ParseTest#test_filepath_unparser/corpus/literal/def.txt [ruby/test/prism/parse_test.rb:280]: <[[80, 13], :on_ident, “bar”, END|LABEL]> expected but was <[[80, 13], :on_ident, “bar”, ARG]>. ``` Parser sets lex state to `END|LABEL` on master branch. Therefore previous commit makes Ripper’s behavior aligned with parser’s behavior. ``` $ ruby -v -y -e "def foo(bar: bar())" -e "end" ruby 3.4.0dev (2024-02-11T23:52:05Z master 697ade7bda) [arm64-darwin21] ... Reading a token parser_dispatch_scan_event:11210 (1: 12|1|7) lex_state: ARG|LABELED -> ARG at line 11113 lex_state: ARG -> END|LABEL at line 11128 parser_dispatch_scan_event:11877 (1: 13|3|4) Next token is token “local variable or method” (1.13-1.16: bar) Shifting token “local variable or method” (1.13-1.16: bar) ```
Diffstat (limited to 'test')
-rw-r--r--test/prism/parse_test.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/test/prism/parse_test.rb b/test/prism/parse_test.rb
index 574a1c1714..55b8c0178e 100644
--- a/test/prism/parse_test.rb
+++ b/test/prism/parse_test.rb
@@ -207,6 +207,8 @@ module Prism
# https://bugs.ruby-lang.org/issues/19539
ripper_should_parse = false if relative == "heredocs_leading_whitespace.txt" && RUBY_VERSION < "3.3.0"
+ ripper_should_parse = false if relative == "unparser/corpus/literal/def.txt"
+
define_method "test_filepath_#{relative}" do
# First, read the source from the filepath. Use binmode to avoid converting CRLF on Windows,
# and explicitly set the external encoding to UTF-8 to override the binmode default.