mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
406500cc8b
(Vector#eqn?): removed. Defined by mistake. Fixes [ruby-dev:36294]. Reported by weda <weda AT issp.u-tokyo.ac.jp> and an anonymous user. * test/matrix/test_matrix.rb: added. * test/matrix/test_vector.rb: added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
43 lines
930 B
Ruby
43 lines
930 B
Ruby
require 'test/unit'
|
|
require 'matrix'
|
|
|
|
class TestMatrix < Test::Unit::TestCase
|
|
def setup
|
|
@m1 = Matrix[[1,2,3], [4,5,6]]
|
|
@m2 = Matrix[[1,2,3], [4,5,6]]
|
|
@m3 = @m1.clone
|
|
@m4 = Matrix[[1,0, 2.0, 3.0], [4.0, 5.0, 6.0]]
|
|
@n1 = Matrix[[2,3,4], [5,6,7]]
|
|
end
|
|
|
|
def test_identity
|
|
assert_same @m1, @m1
|
|
assert_not_same @m1, @m2
|
|
assert_not_same @m1, @m3
|
|
assert_not_same @m1, @m4
|
|
assert_not_same @m1, @n1
|
|
end
|
|
|
|
def test_equality
|
|
assert_equal @m1, @m1
|
|
assert_equal @m1, @m2
|
|
assert_equal @m1, @m3
|
|
assert_not_equal @m1, @m4
|
|
assert_not_equal @m1, @n1
|
|
end
|
|
|
|
def test_hash_equality
|
|
assert @m1.eql?(@m1)
|
|
assert @m1.eql?(@m2)
|
|
assert @m1.eql?(@m3)
|
|
assert !@m1.eql?(@m4)
|
|
assert !@m1.eql?(@n1)
|
|
|
|
hash = { @m1 => :value }
|
|
assert hash.key?(@m1)
|
|
assert hash.key?(@m2)
|
|
assert hash.key?(@m3)
|
|
assert !hash.key?(@m4)
|
|
assert !hash.key?(@n1)
|
|
end
|
|
end
|