aboutsummaryrefslogtreecommitdiffstats
path: root/test/matrix
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-20 02:18:12 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-20 02:18:12 +0000
commitaa95a42190fbe9f9990a60d722366a5e4d89920b (patch)
tree2f874207010641795868ae654ccfb1058b0025a1 /test/matrix
parente33b1690d06f867e45750bd8e3e8b06d78b5bc26 (diff)
downloadruby-aa95a42190fbe9f9990a60d722366a5e4d89920b.tar.gz
lib/matrix: Add explicit coercion #to_matrix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/matrix')
-rw-r--r--test/matrix/test_matrix.rb4
-rw-r--r--test/matrix/test_vector.rb4
2 files changed, 8 insertions, 0 deletions
diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb
index 425ec25a52..0831ac6362 100644
--- a/test/matrix/test_matrix.rb
+++ b/test/matrix/test_matrix.rb
@@ -218,6 +218,10 @@ class TestMatrix < Test::Unit::TestCase
assert_equal([[1], [1]], m2.to_a)
end
+ def test_to_matrix
+ assert @m1.equal? @m1.to_matrix
+ end
+
def test_columns
assert_equal(@m1, Matrix.columns([[1, 4], [2, 5], [3, 6]]))
end
diff --git a/test/matrix/test_vector.rb b/test/matrix/test_vector.rb
index 687706b5e9..52785120b1 100644
--- a/test/matrix/test_vector.rb
+++ b/test/matrix/test_vector.rb
@@ -177,6 +177,10 @@ class TestVector < Test::Unit::TestCase
assert_equal("Vector[1, 2, 3]", @v1.to_s)
end
+ def test_to_matrix
+ assert_equal Matrix[[1], [2], [3]], @v1.to_matrix
+ end
+
def test_inspect
assert_equal("Vector[1, 2, 3]", @v1.inspect)
end