Files
ruby/test/prism/api/parse_comments_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

36 lines
900 B
Ruby

# frozen_string_literal: true
require_relative "../test_helper"
module Ruby::Prism
class ParseCommentsTest < TestCase
def test_parse_comments
comments = Ruby::Prism.parse_comments("# foo")
assert_kind_of Array, comments
assert_equal 1, comments.length
assert_equal 1, comments[0].location.start_line
assert_equal "# foo", comments[0].slice
end
def test_parse_file_comments
comments = Ruby::Prism.parse_file_comments(__FILE__)
assert_kind_of Array, comments
assert_equal 1, comments.length
end
def test_parse_file_comments_error
error = assert_raise Errno::ENOENT do
Ruby::Prism.parse_file_comments("idontexist.rb")
end
assert_equal "No such file or directory - idontexist.rb", error.message
assert_raise TypeError do
Ruby::Prism.parse_file_comments(nil)
end
end
end
end