diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-14 07:15:55 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-14 07:15:55 +0000 |
commit | 406500cc8bdd4178ed1462f89565620352d585ec (patch) | |
tree | bf9489caeecbfa8d0f92f19f7e7c8b7161290374 /test/matrix/test_vector.rb | |
parent | 387d645af066d28624e8ed826fe8a50333a8afb4 (diff) |
* lib/matrix.rb (Vector#eql?): typo of the method name as "eqn?".
(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
Diffstat (limited to 'test/matrix/test_vector.rb')
-rw-r--r-- | test/matrix/test_vector.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/matrix/test_vector.rb b/test/matrix/test_vector.rb new file mode 100644 index 0000000000..d8f5c778c3 --- /dev/null +++ b/test/matrix/test_vector.rb @@ -0,0 +1,43 @@ +require 'test/unit' +require 'matrix' + +class TestVector < Test::Unit::TestCase + def setup + @v1 = Vector[1,2,3] + @v2 = Vector[1,2,3] + @v3 = @v1.clone + @v4 = Vector[1,0, 2.0, 3.0] + @w1 = Vector[2,3,4] + end + + def test_identity + assert_same @v1, @v1 + assert_not_same @v1, @v2 + assert_not_same @v1, @v3 + assert_not_same @v1, @v4 + assert_not_same @v1, @w1 + end + + def test_equality + assert_equal @v1, @v1 + assert_equal @v1, @v2 + assert_equal @v1, @v3 + assert_not_equal @v1, @v4 + assert_not_equal @v1, @w1 + end + + def test_hash_equality + assert @v1.eql?(@v1) + assert @v1.eql?(@v2) + assert @v1.eql?(@v3) + assert [email protected]?(@v4) + assert [email protected]?(@w1) + + hash = { @v1 => :value } + assert hash.key?(@v1) + assert hash.key?(@v2) + assert hash.key?(@v3) + assert !hash.key?(@v4) + assert !hash.key?(@w1) + end +end |