diff options
author | TSUYUSATO Kitsune <make.just.on@gmail.com> | 2023-11-14 17:05:16 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-11-14 14:34:48 +0000 |
commit | 336d81a6718c64cade9f1dfcfdf159fbfa92ba3a (patch) | |
tree | ed5d0ed6e8e5c84503be2419106d519f23ec4365 /test/prism/errors_test.rb | |
parent | 499786de4658de5d9c1ebe68ec99fbbfdf63f8e1 (diff) | |
download | ruby-336d81a6718c64cade9f1dfcfdf159fbfa92ba3a.tar.gz |
[ruby/prism] Check value expressions on creating a node
https://github.com/ruby/prism/commit/d60948bac3
Diffstat (limited to 'test/prism/errors_test.rb')
-rw-r--r-- | test/prism/errors_test.rb | 92 |
1 files changed, 84 insertions, 8 deletions
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb index 9a63b32e30..5d4b95a224 100644 --- a/test/prism/errors_test.rb +++ b/test/prism/errors_test.rb @@ -1550,6 +1550,8 @@ module Prism 1 unless (return) 1 while (return) 1 until (return) + (return) => a + (return) in a RUBY message = 'Unexpected void value expression' assert_errors expression(source), source, [ @@ -1557,6 +1559,66 @@ module Prism [message, 24..30], [message, 41..47], [message, 58..64], + [message, 67..73], + [message, 81..87] + ], compare_ripper: false # Ripper does not check 'void value expression'. + end + + def test_void_value_expression_in_expression + source = <<~RUBY + (return) ? 1 : 1 + (return)..1 + 1..(return) + (return)...1 + 1...(return) + (..(return)) + (...(return)) + ((return)..) + ((return)...) + RUBY + message = 'Unexpected void value expression' + assert_errors expression(source), source, [ + [message, 1..7], + [message, 18..24], + [message, 33..39], + [message, 42..48], + [message, 59..65], + [message, 71..77], + [message, 85..91], + [message, 96..102], + [message, 109..115] + ], compare_ripper: false # Ripper does not check 'void value expression'. + end + + def test_void_value_expression_in_hash + source = <<~RUBY + { return => 1 } + { 1 => return } + { a: return } + { **return } + RUBY + message = 'Unexpected void value expression' + assert_errors expression(source), source, [ + [message, 2..8], + [message, 23..29], + [message, 37..43], + [message, 50..56], + ], compare_ripper: false # Ripper does not check 'void value expression'. + end + + def test_void_value_expression_in_call + source = <<~RUBY + (return).foo + (return).(1) + (return)[1] + (return)[1] = 2 + RUBY + message = 'Unexpected void value expression' + assert_errors expression(source), source, [ + [message, 1..7], + [message, 14..20], + [message, 27..33], + [message, 39..45], ], compare_ripper: false # Ripper does not check 'void value expression'. end @@ -1584,19 +1646,33 @@ module Prism ], compare_ripper: false # Ripper does not check 'void value expression'. end - def test_void_value_expression_in_hash + def test_void_value_expression_in_unary_call source = <<~RUBY - { return => 1 } - { 1 => return } - { a: return } - { **return } + +(return) + not return RUBY message = 'Unexpected void value expression' assert_errors expression(source), source, [ [message, 2..8], - [message, 23..29], - [message, 37..43], - [message, 50..56], + [message, 14..20], + ], compare_ripper: false # Ripper does not check 'void value expression'. + end + + def test_void_value_expression_in_binary_call + source = <<~RUBY + 1 + (return) + (return) + 1 + 1 and (return) + (return) and 1 + 1 or (return) + (return) or 1 + RUBY + message = 'Unexpected void value expression' + assert_errors expression(source), source, [ + [message, 5..11], + [message, 14..20], + [message, 42..48], + [message, 71..77], ], compare_ripper: false # Ripper does not check 'void value expression'. end |