mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_bignum.rb, test/ruby/test_class.rb,
test/ruby/test_defined.rb, test/ruby/test_hash.rb, test/ruby/test_primitive.rb, test/ruby/test_variable.rb: add some tests (for coverage). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c758a90693
commit
45c2671e37
7 changed files with 38 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
|||
Fri Jan 22 01:07:16 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* test/ruby/test_bignum.rb, test/ruby/test_class.rb,
|
||||
test/ruby/test_defined.rb, test/ruby/test_hash.rb,
|
||||
test/ruby/test_primitive.rb, test/ruby/test_variable.rb: add some
|
||||
tests (for coverage).
|
||||
|
||||
Fri Jan 22 01:03:28 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* test/ruby/test_require.rb (test_define_class): expect TypeError
|
||||
|
|
|
@ -420,6 +420,7 @@ class TestBignum < Test::Unit::TestCase
|
|||
b = 1E+300.to_i
|
||||
assert_equal(b, (b ** 2).fdiv(b))
|
||||
assert(@big.fdiv(0.0 / 0.0).nan?)
|
||||
assert_in_delta(1E+300, (10**500).fdiv(1E+200), 1E+285)
|
||||
end
|
||||
|
||||
def test_obj_fdiv
|
||||
|
|
|
@ -209,4 +209,13 @@ class TestClass < Test::Unit::TestCase
|
|||
c = eval("class C\u{df}; self; end")
|
||||
assert_equal("TestClass::C\u{df}", c.name, '[ruby-core:24600]')
|
||||
end
|
||||
|
||||
def test_invalid_jump_from_class_definition
|
||||
assert_raise(SyntaxError) { eval("class C; next; end") }
|
||||
assert_raise(SyntaxError) { eval("class C; break; end") }
|
||||
assert_raise(SyntaxError) { eval("class C; redo; end") }
|
||||
assert_raise(SyntaxError) { eval("class C; retry; end") }
|
||||
assert_raise(SyntaxError) { eval("class C; return; end") }
|
||||
assert_raise(SyntaxError) { eval("class C; yield; end") }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,10 @@ class TestDefined < Test::Unit::TestCase
|
|||
end
|
||||
def baz(f)
|
||||
end
|
||||
attr_accessor :attr
|
||||
def attrasgn_test
|
||||
yield(defined?(self.attr = 1))
|
||||
end
|
||||
end
|
||||
|
||||
def defined_test
|
||||
|
@ -32,6 +36,7 @@ class TestDefined < Test::Unit::TestCase
|
|||
assert(defined?(::Array)) # toplevel constant
|
||||
assert(defined?(File::Constants)) # nested constant
|
||||
assert(defined?(Object.new)) # method
|
||||
assert(defined?(Object::new)) # method
|
||||
assert(!defined?(Object.print)) # private method
|
||||
assert(defined?(1 == 2)) # operator expression
|
||||
|
||||
|
@ -45,6 +50,8 @@ class TestDefined < Test::Unit::TestCase
|
|||
assert_nil(defined?(f.quux(x)))
|
||||
assert(defined?(print(x)))
|
||||
assert_nil(defined?(quux(x)))
|
||||
assert(defined?(f.attr = 1))
|
||||
f.attrasgn_test { |v| assert(v) }
|
||||
|
||||
assert(defined_test) # not iterator
|
||||
assert(!defined_test{}) # called as iterator
|
||||
|
|
|
@ -871,4 +871,8 @@ class TestHash < Test::Unit::TestCase
|
|||
def o.hash; 2<<100; end
|
||||
assert_equal({x=>1}.hash, {x=>1}.hash)
|
||||
end
|
||||
|
||||
def test_hash_poped
|
||||
assert_nothing_raised { eval("a = 1; {a => a}; a") }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -228,6 +228,12 @@ class TestRubyPrimitive < Test::Unit::TestCase
|
|||
assert_equal 7, a[0]
|
||||
a[0] ||= 3
|
||||
assert_equal 7, a[0]
|
||||
|
||||
a = [0, 1, nil, 3, 4]
|
||||
a[*[2]] ||= :foo
|
||||
assert_equal [0, 1, :foo, 3, 4], a
|
||||
a[*[1,3]] &&= [:bar]
|
||||
assert_equal [0, :bar, 4], a
|
||||
end
|
||||
|
||||
def test_opassign_and_or
|
||||
|
|
|
@ -81,4 +81,8 @@ class TestVariable < Test::Unit::TestCase
|
|||
def test_global_variable_0
|
||||
assert_in_out_err(["-e", "$0='t'*1000;print $0"], "", /\At+\z/, [])
|
||||
end
|
||||
|
||||
def test_global_variable_poped
|
||||
assert_nothing_raised { eval("$foo; 1") }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue