Files
ruby/test/prism/result/implicit_array_test.rb
Yusuke EndohandClaude Opus 5.5 9b23d39c44 [ruby/prism] Resync prism as Ruby::Prism
This is the output of

    ruby tool/sync_default_gems.rb prism
    git rm -r lib/prism.rb lib/prism

at https://github.com/ruby/prism/commit/0a5f9c9, with the new mapping:
lib/prism is now lib/ruby/prism, the namespace is rewritten to
Ruby::Prism, and lib/prism/prism.gemspec is no longer imported, so
prism is no longer installed as a default gem.

prism/srcs.mk.in (excluded from the sync) follows the template engine,
now Ruby::Prism::Template: it defines the Ruby module, which does not
exist in BASERUBY older than Ruby 4.0, before loading
templates/template.rb.

Ruby::Prism is the very parser that parsed the running code, no
matter which version of the prism gem is installed; the two can be
loaded side by side (the ruby binary is built with -fvisibility=hidden,
so the gem's pm_* and rb_cPrism* symbols do not collide with the
built-in ones).

[Bug #22379]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 04:27:15 +09:00

60 lines
1.5 KiB
Ruby

# frozen_string_literal: true
require_relative "../test_helper"
module Ruby::Prism
class ImplicitArrayTest < TestCase
def test_call_node
assert_implicit_array("a.a = *b")
assert_implicit_array("a.a = 1, 2, 3")
assert_implicit_array("a[a] = *b")
assert_implicit_array("a[a] = 1, 2, 3")
end
def test_class_variable_write_node
assert_implicit_array("@@a = *b")
assert_implicit_array("@@a = 1, 2, 3")
end
def test_constant_path_write_node
assert_implicit_array("A::A = *b")
assert_implicit_array("A::A = 1, 2, 3")
end
def test_constant_write_node
assert_implicit_array("A = *b")
assert_implicit_array("A = 1, 2, 3")
end
def test_global_variable_write_node
assert_implicit_array("$a = *b")
assert_implicit_array("$a = 1, 2, 3")
end
def test_instance_variable_write_node
assert_implicit_array("@a = *b")
assert_implicit_array("@a = 1, 2, 3")
end
def test_local_variable_write_node
assert_implicit_array("a = *b")
assert_implicit_array("a = 1, 2, 3")
end
def test_multi_write_node
assert_implicit_array("a, b, c = *b")
assert_implicit_array("a, b, c = 1, 2, 3")
end
private
def assert_implicit_array(source)
assert Ruby::Prism.parse_success?(source)
assert Ruby::Prism.parse_failure?("if #{source} then end")
assert_valid_syntax(source)
refute_valid_syntax("if #{source} then end")
end
end
end