[PRISM] Resync
This commit is contained in:
parent
cb029fa4e8
commit
c73dd96fe4
@ -81,14 +81,6 @@ foo[bar] = baz
|
||||
|
||||
%w[\C:]
|
||||
|
||||
# foo[&bar] = 1
|
||||
|
||||
# foo.foo[&bar] = 1
|
||||
|
||||
# def foo(&)
|
||||
# bar[&] = 1
|
||||
# end
|
||||
|
||||
foo[] += 1
|
||||
|
||||
foo[] ||= 1
|
||||
@ -113,18 +105,6 @@ foo.foo[bar] ||= 1
|
||||
|
||||
foo.foo[bar] &&= 1
|
||||
|
||||
# foo[bar, &baz] += 1
|
||||
|
||||
# foo[bar, &baz] ||= 1
|
||||
|
||||
# foo[bar, &baz] &&= 1
|
||||
|
||||
# foo.foo[bar, &baz] += 1
|
||||
|
||||
# foo.foo[bar, &baz] ||= 1
|
||||
|
||||
# foo.foo[bar, &baz] &&= 1
|
||||
|
||||
def f(*); a[*]; end
|
||||
|
||||
def f(*); a[1, *]; end
|
||||
|
89
test/prism/index_write_test.rb
Normal file
89
test/prism/index_write_test.rb
Normal file
@ -0,0 +1,89 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "test_helper"
|
||||
|
||||
module Prism
|
||||
class IndexWriteTest < TestCase
|
||||
def test_keywords_3_3_0
|
||||
assert_parse_success(<<~RUBY, "3.3.0")
|
||||
foo[bar: 1] = 1
|
||||
foo[bar: 1] &&= 1
|
||||
foo[bar: 1] ||= 1
|
||||
foo[bar: 1] += 1
|
||||
RUBY
|
||||
|
||||
assert_parse_success(<<~RUBY, "3.3.0")
|
||||
def foo(**)
|
||||
bar[**] = 1
|
||||
bar[**] &&= 1
|
||||
bar[**] ||= 1
|
||||
bar[**] += 1
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
def test_block_3_3_0
|
||||
assert_parse_success(<<~RUBY, "3.3.0")
|
||||
foo[&bar] = 1
|
||||
foo[&bar] &&= 1
|
||||
foo[&bar] ||= 1
|
||||
foo[&bar] += 1
|
||||
RUBY
|
||||
|
||||
assert_parse_success(<<~RUBY, "3.3.0")
|
||||
def foo(&)
|
||||
bar[&] = 1
|
||||
bar[&] &&= 1
|
||||
bar[&] ||= 1
|
||||
bar[&] += 1
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
# def test_keywords_latest
|
||||
# assert_parse_failure(<<~RUBY)
|
||||
# foo[bar: 1] = 1
|
||||
# foo[bar: 1] &&= 1
|
||||
# foo[bar: 1] ||= 1
|
||||
# foo[bar: 1] += 1
|
||||
# RUBY
|
||||
|
||||
# assert_parse_failure(<<~RUBY)
|
||||
# def foo(**)
|
||||
# bar[**] = 1
|
||||
# bar[**] &&= 1
|
||||
# bar[**] ||= 1
|
||||
# bar[**] += 1
|
||||
# end
|
||||
# RUBY
|
||||
# end
|
||||
|
||||
# def test_block_latest
|
||||
# assert_parse_failure(<<~RUBY)
|
||||
# foo[&bar] = 1
|
||||
# foo[&bar] &&= 1
|
||||
# foo[&bar] ||= 1
|
||||
# foo[&bar] += 1
|
||||
# RUBY
|
||||
|
||||
# assert_parse_failure(<<~RUBY)
|
||||
# def foo(&)
|
||||
# bar[&] = 1
|
||||
# bar[&] &&= 1
|
||||
# bar[&] ||= 1
|
||||
# bar[&] += 1
|
||||
# end
|
||||
# RUBY
|
||||
# end
|
||||
|
||||
private
|
||||
|
||||
def assert_parse_success(source, version = "latest")
|
||||
assert Prism.parse_success?(source, version: version)
|
||||
end
|
||||
|
||||
def assert_parse_failure(source, version = "latest")
|
||||
assert Prism.parse_failure?(source, version: version)
|
||||
end
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user