1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
yugui 2008-09-14 07:15:55 +00:00
parent 387d645af0
commit 406500cc8b
4 changed files with 98 additions and 1 deletions

View file

@ -1,3 +1,14 @@
Sun Sep 14 16:15:22 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* 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.
Sun Sep 14 16:07:04 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (process_options): associates the locale encoding with $0 as

View file

@ -1200,7 +1200,7 @@ class Vector
other.compare_by(@elements)
end
alias eqn? ==
alias eql? ==
#
# For internal use.

View file

@ -0,0 +1,43 @@
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

View file

@ -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 !@v1.eql?(@v4)
assert !@v1.eql?(@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