mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/lib/test/unit/assertions.rb defines assert_fixnum and assert_bignum.
* test/lib/test/unit/assertions.rb (assert_fixnum): Defined. (assert_bignum): Defined. * test/ruby/test_bignum.rb: Use assert_bignum. * test/ruby/test_integer_comb.rb: Use assert_fixnum and assert_bignum. * test/ruby/test_optimization.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0963d96e52
commit
5ea4824508
5 changed files with 42 additions and 23 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Mon May 2 01:00:04 2016 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* test/lib/test/unit/assertions.rb (assert_fixnum): Defined.
|
||||
(assert_bignum): Defined.
|
||||
|
||||
* test/ruby/test_bignum.rb: Use assert_bignum.
|
||||
|
||||
* test/ruby/test_integer_comb.rb: Use assert_fixnum and assert_bignum.
|
||||
|
||||
* test/ruby/test_optimization.rb: Ditto.
|
||||
|
||||
Mon May 2 00:41:53 2016 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* vm_trace.c (recalc_remove_ruby_vm_event_flags): Add a cast to
|
||||
|
|
|
@ -771,6 +771,14 @@ eom
|
|||
values
|
||||
end
|
||||
|
||||
def assert_fixnum(v, msg=nil)
|
||||
assert_instance_of(Fixnum, v, msg)
|
||||
end
|
||||
|
||||
def assert_bignum(v, msg=nil)
|
||||
assert_instance_of(Bignum, v, msg)
|
||||
end
|
||||
|
||||
class << (AssertFile = Struct.new(:failure_message).new)
|
||||
include Assertions
|
||||
def assert_file_predicate(predicate, *args)
|
||||
|
|
|
@ -51,18 +51,18 @@ class TestBignum < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_prepare
|
||||
assert_instance_of(Bignum, @big)
|
||||
assert_instance_of(Bignum, T_ZERO)
|
||||
assert_instance_of(Bignum, T_ONE)
|
||||
assert_instance_of(Bignum, T_MONE)
|
||||
assert_instance_of(Bignum, T31)
|
||||
assert_instance_of(Bignum, T31P)
|
||||
assert_instance_of(Bignum, T32)
|
||||
assert_instance_of(Bignum, T32P)
|
||||
assert_instance_of(Bignum, T64)
|
||||
assert_instance_of(Bignum, T64P)
|
||||
assert_instance_of(Bignum, T1024)
|
||||
assert_instance_of(Bignum, T1024P)
|
||||
assert_bignum(@big)
|
||||
assert_bignum(T_ZERO)
|
||||
assert_bignum(T_ONE)
|
||||
assert_bignum(T_MONE)
|
||||
assert_bignum(T31)
|
||||
assert_bignum(T31P)
|
||||
assert_bignum(T32)
|
||||
assert_bignum(T32P)
|
||||
assert_bignum(T64)
|
||||
assert_bignum(T64P)
|
||||
assert_bignum(T1024)
|
||||
assert_bignum(T1024P)
|
||||
end
|
||||
|
||||
def test_bignum
|
||||
|
@ -469,7 +469,7 @@ class TestBignum < Test::Unit::TestCase
|
|||
assert_raise(TypeError, ArgumentError) { T32**"foo" }
|
||||
|
||||
feature3429 = '[ruby-core:30735]'
|
||||
assert_instance_of(Bignum, (2 ** 7830457), feature3429)
|
||||
assert_bignum((2 ** 7830457), feature3429)
|
||||
end
|
||||
|
||||
def test_and
|
||||
|
|
|
@ -114,17 +114,17 @@ class TestIntegerComb < Test::Unit::TestCase
|
|||
FIXNUM_MAX = Integer::FIXNUM_MAX
|
||||
|
||||
def test_fixnum_range
|
||||
assert_instance_of(Bignum, FIXNUM_MIN-1)
|
||||
assert_instance_of(Fixnum, FIXNUM_MIN)
|
||||
assert_instance_of(Fixnum, FIXNUM_MAX)
|
||||
assert_instance_of(Bignum, FIXNUM_MAX+1)
|
||||
assert_bignum(FIXNUM_MIN-1)
|
||||
assert_fixnum(FIXNUM_MIN)
|
||||
assert_fixnum(FIXNUM_MAX)
|
||||
assert_bignum(FIXNUM_MAX+1)
|
||||
end
|
||||
|
||||
def check_class(n)
|
||||
if FIXNUM_MIN <= n && n <= FIXNUM_MAX
|
||||
assert_instance_of(Fixnum, n)
|
||||
assert_fixnum(n)
|
||||
else
|
||||
assert_instance_of(Bignum, n)
|
||||
assert_bignum(n)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||
def test_fixnum_plus
|
||||
a, b = 1, 2
|
||||
assert_equal 3, a + b
|
||||
assert_instance_of Fixnum, FIXNUM_MAX
|
||||
assert_instance_of Bignum, FIXNUM_MAX + 1
|
||||
assert_fixnum FIXNUM_MAX
|
||||
assert_bignum FIXNUM_MAX + 1
|
||||
|
||||
assert_equal 21, 10 + 11
|
||||
assert_redefine_method('Fixnum', '+', 'assert_equal 11, 10 + 11')
|
||||
|
@ -34,8 +34,8 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||
|
||||
def test_fixnum_minus
|
||||
assert_equal 5, 8 - 3
|
||||
assert_instance_of Fixnum, FIXNUM_MIN
|
||||
assert_instance_of Bignum, FIXNUM_MIN - 1
|
||||
assert_fixnum FIXNUM_MIN
|
||||
assert_bignum FIXNUM_MIN - 1
|
||||
|
||||
assert_equal 5, 8 - 3
|
||||
assert_redefine_method('Fixnum', '-', 'assert_equal 3, 8 - 3')
|
||||
|
|
Loading…
Reference in a new issue