mirror of
https://github.com/ruby/ruby.git
synced 2026-10-29 00:46:26 +08:00
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>
42 lines
1.2 KiB
Ruby
42 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../test_helper"
|
|
|
|
module Ruby::Prism
|
|
class IntegerParseTest < TestCase
|
|
def test_integer_parse
|
|
assert_integer_parse(1)
|
|
assert_integer_parse(50)
|
|
assert_integer_parse(100)
|
|
assert_integer_parse(100, "1_0_0")
|
|
assert_integer_parse(8, "0_1_0")
|
|
|
|
assert_integer_parse(10, "0b1010")
|
|
assert_integer_parse(10, "0B1010")
|
|
assert_integer_parse(10, "0o12")
|
|
assert_integer_parse(10, "0O12")
|
|
assert_integer_parse(10, "012")
|
|
assert_integer_parse(10, "0d10")
|
|
assert_integer_parse(10, "0D10")
|
|
assert_integer_parse(10, "0xA")
|
|
assert_integer_parse(10, "0XA")
|
|
|
|
assert_integer_parse(2**32)
|
|
assert_integer_parse(2**64 + 2**32)
|
|
assert_integer_parse(2**128 + 2**64 + 2**32)
|
|
|
|
num = 99 ** 99
|
|
assert_integer_parse(num, "0b#{num.to_s(2)}")
|
|
assert_integer_parse(num, "0o#{num.to_s(8)}")
|
|
assert_integer_parse(num, "0d#{num.to_s(10)}")
|
|
assert_integer_parse(num, "0x#{num.to_s(16)}")
|
|
end
|
|
|
|
private
|
|
|
|
def assert_integer_parse(expected, source = expected.to_s)
|
|
assert_equal expected, Ruby::Prism.parse_statement(source).value
|
|
end
|
|
end
|
|
end
|