summaryrefslogtreecommitdiff
path: root/spec/ruby/library/matrix
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/matrix')
-rw-r--r--spec/ruby/library/matrix/I_spec.rb6
-rw-r--r--spec/ruby/library/matrix/antisymmetric_spec.rb36
-rw-r--r--spec/ruby/library/matrix/build_spec.rb24
-rw-r--r--spec/ruby/library/matrix/clone_spec.rb12
-rw-r--r--spec/ruby/library/matrix/coerce_spec.rb6
-rw-r--r--spec/ruby/library/matrix/collect_spec.rb6
-rw-r--r--spec/ruby/library/matrix/column_size_spec.rb2
-rw-r--r--spec/ruby/library/matrix/column_spec.rb8
-rw-r--r--spec/ruby/library/matrix/column_vector_spec.rb10
-rw-r--r--spec/ruby/library/matrix/column_vectors_spec.rb6
-rw-r--r--spec/ruby/library/matrix/columns_spec.rb8
-rw-r--r--spec/ruby/library/matrix/conj_spec.rb6
-rw-r--r--spec/ruby/library/matrix/conjugate_spec.rb6
-rw-r--r--spec/ruby/library/matrix/constructor_spec.rb24
-rw-r--r--spec/ruby/library/matrix/det_spec.rb6
-rw-r--r--spec/ruby/library/matrix/determinant_spec.rb6
-rw-r--r--spec/ruby/library/matrix/diagonal_spec.rb26
-rw-r--r--spec/ruby/library/matrix/divide_spec.rb27
-rw-r--r--spec/ruby/library/matrix/each_spec.rb18
-rw-r--r--spec/ruby/library/matrix/each_with_index_spec.rb18
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb2
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb4
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb4
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb4
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb14
-rw-r--r--spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb2
-rw-r--r--spec/ruby/library/matrix/element_reference_spec.rb6
-rw-r--r--spec/ruby/library/matrix/empty_spec.rb36
-rw-r--r--spec/ruby/library/matrix/eql_spec.rb8
-rw-r--r--spec/ruby/library/matrix/equal_value_spec.rb6
-rw-r--r--spec/ruby/library/matrix/exponent_spec.rb29
-rw-r--r--spec/ruby/library/matrix/find_index_spec.rb26
-rw-r--r--spec/ruby/library/matrix/hash_spec.rb6
-rw-r--r--spec/ruby/library/matrix/hermitian_spec.rb22
-rw-r--r--spec/ruby/library/matrix/identity_spec.rb6
-rw-r--r--spec/ruby/library/matrix/imag_spec.rb6
-rw-r--r--spec/ruby/library/matrix/imaginary_spec.rb6
-rw-r--r--spec/ruby/library/matrix/inspect_spec.rb4
-rw-r--r--spec/ruby/library/matrix/inv_spec.rb8
-rw-r--r--spec/ruby/library/matrix/inverse_from_spec.rb2
-rw-r--r--spec/ruby/library/matrix/inverse_spec.rb8
-rw-r--r--spec/ruby/library/matrix/lower_triangular_spec.rb24
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb6
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb10
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/l_spec.rb4
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/p_spec.rb4
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/solve_spec.rb14
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb6
-rw-r--r--spec/ruby/library/matrix/lup_decomposition/u_spec.rb4
-rw-r--r--spec/ruby/library/matrix/map_spec.rb6
-rw-r--r--spec/ruby/library/matrix/minor_spec.rb6
-rw-r--r--spec/ruby/library/matrix/minus_spec.rb24
-rw-r--r--spec/ruby/library/matrix/multiply_spec.rb23
-rw-r--r--spec/ruby/library/matrix/new_spec.rb4
-rw-r--r--spec/ruby/library/matrix/normal_spec.rb16
-rw-r--r--spec/ruby/library/matrix/orthogonal_spec.rb16
-rw-r--r--spec/ruby/library/matrix/permutation_spec.rb22
-rw-r--r--spec/ruby/library/matrix/plus_spec.rb24
-rw-r--r--spec/ruby/library/matrix/rank_spec.rb2
-rw-r--r--spec/ruby/library/matrix/real_spec.rb19
-rw-r--r--spec/ruby/library/matrix/rect_spec.rb6
-rw-r--r--spec/ruby/library/matrix/rectangular_spec.rb6
-rw-r--r--spec/ruby/library/matrix/regular_spec.rb18
-rw-r--r--spec/ruby/library/matrix/round_spec.rb6
-rw-r--r--spec/ruby/library/matrix/row_size_spec.rb2
-rw-r--r--spec/ruby/library/matrix/row_spec.rb8
-rw-r--r--spec/ruby/library/matrix/row_vector_spec.rb8
-rw-r--r--spec/ruby/library/matrix/row_vectors_spec.rb6
-rw-r--r--spec/ruby/library/matrix/rows_spec.rb12
-rw-r--r--spec/ruby/library/matrix/scalar/Fail_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/Raise_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/divide_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/exponent_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/included_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/initialize_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/minus_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/multiply_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar/plus_spec.rb2
-rw-r--r--spec/ruby/library/matrix/scalar_spec.rb6
-rw-r--r--spec/ruby/library/matrix/shared/collect.rb8
-rw-r--r--spec/ruby/library/matrix/shared/conjugate.rb4
-rw-r--r--spec/ruby/library/matrix/shared/determinant.rb8
-rw-r--r--spec/ruby/library/matrix/shared/equal_value.rb22
-rw-r--r--spec/ruby/library/matrix/shared/identity.rb6
-rw-r--r--spec/ruby/library/matrix/shared/imaginary.rb4
-rw-r--r--spec/ruby/library/matrix/shared/inverse.rb10
-rw-r--r--spec/ruby/library/matrix/shared/rectangular.rb4
-rw-r--r--spec/ruby/library/matrix/shared/trace.rb2
-rw-r--r--spec/ruby/library/matrix/shared/transpose.rb4
-rw-r--r--spec/ruby/library/matrix/singular_spec.rb18
-rw-r--r--spec/ruby/library/matrix/square_spec.rb18
-rw-r--r--spec/ruby/library/matrix/symmetric_spec.rb18
-rw-r--r--spec/ruby/library/matrix/t_spec.rb6
-rw-r--r--spec/ruby/library/matrix/to_a_spec.rb2
-rw-r--r--spec/ruby/library/matrix/to_s_spec.rb2
-rw-r--r--spec/ruby/library/matrix/tr_spec.rb6
-rw-r--r--spec/ruby/library/matrix/trace_spec.rb6
-rw-r--r--spec/ruby/library/matrix/transpose_spec.rb6
-rw-r--r--spec/ruby/library/matrix/unit_spec.rb6
-rw-r--r--spec/ruby/library/matrix/unitary_spec.rb24
-rw-r--r--spec/ruby/library/matrix/upper_triangular_spec.rb24
-rw-r--r--spec/ruby/library/matrix/vector/cross_product_spec.rb6
-rw-r--r--spec/ruby/library/matrix/vector/each2_spec.rb14
-rw-r--r--spec/ruby/library/matrix/vector/eql_spec.rb6
-rw-r--r--spec/ruby/library/matrix/vector/inner_product_spec.rb6
-rw-r--r--spec/ruby/library/matrix/vector/normalize_spec.rb10
-rw-r--r--spec/ruby/library/matrix/zero_spec.rb18
107 files changed, 558 insertions, 510 deletions
diff --git a/spec/ruby/library/matrix/I_spec.rb b/spec/ruby/library/matrix/I_spec.rb
index f83cc3cec4..6eeffe8e98 100644
--- a/spec/ruby/library/matrix/I_spec.rb
+++ b/spec/ruby/library/matrix/I_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/identity', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/identity'
describe "Matrix.I" do
- it_behaves_like(:matrix_identity, :I)
+ it_behaves_like :matrix_identity, :I
end
diff --git a/spec/ruby/library/matrix/antisymmetric_spec.rb b/spec/ruby/library/matrix/antisymmetric_spec.rb
new file mode 100644
index 0000000000..b4b8858f32
--- /dev/null
+++ b/spec/ruby/library/matrix/antisymmetric_spec.rb
@@ -0,0 +1,36 @@
+require_relative '../../spec_helper'
+
+require 'matrix'
+
+describe "Matrix#antisymmetric?" do
+ it "returns true for an antisymmetric Matrix" do
+ Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should == true
+ end
+
+ it "returns true for a 0x0 empty matrix" do
+ Matrix.empty.antisymmetric?.should == true
+ end
+
+ it "returns false for non-antisymmetric matrices" do
+ [
+ Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
+ Matrix[[1, -2, 3], [2, 0, 6], [-3, -6, 0]], # wrong diagonal element
+ Matrix[[0, 2, -3], [2, 0, 6], [-3, 6, 0]] # only signs wrong
+ ].each do |matrix|
+ matrix.antisymmetric?.should == false
+ end
+ end
+
+ it "raises an error for rectangular matrices" do
+ [
+ Matrix[[0], [0]],
+ Matrix[[0, 0]],
+ Matrix.empty(0, 2),
+ Matrix.empty(2, 0),
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.antisymmetric?
+ }.should.raise(Matrix::ErrDimensionMismatch)
+ end
+ end
+end
diff --git a/spec/ruby/library/matrix/build_spec.rb b/spec/ruby/library/matrix/build_spec.rb
index 29fd72206f..49eb2e69a5 100644
--- a/spec/ruby/library/matrix/build_spec.rb
+++ b/spec/ruby/library/matrix/build_spec.rb
@@ -1,12 +1,12 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix.build" do
it "returns a Matrix object of the given size" do
m = Matrix.build(3, 4){1}
- m.should be_an_instance_of(Matrix)
+ m.should.instance_of?(Matrix)
m.row_size.should == 3
m.column_size.should == 4
end
@@ -24,32 +24,32 @@ describe "Matrix.build" do
it "returns an Enumerator is no block is given" do
enum = Matrix.build(2, 1)
- enum.should be_an_instance_of(Enumerator)
+ enum.should.instance_of?(Enumerator)
enum.each{1}.should == Matrix[[1], [1]]
end
it "requires integers as parameters" do
- lambda { Matrix.build("1", "2"){1} }.should raise_error(TypeError)
- lambda { Matrix.build(nil, nil){1} }.should raise_error(TypeError)
- lambda { Matrix.build(1..2){1} }.should raise_error(TypeError)
+ -> { Matrix.build("1", "2"){1} }.should.raise(TypeError)
+ -> { Matrix.build(nil, nil){1} }.should.raise(TypeError)
+ -> { Matrix.build(1..2){1} }.should.raise(TypeError)
end
it "requires non-negative integers" do
- lambda { Matrix.build(-1, 1){1} }.should raise_error(ArgumentError)
- lambda { Matrix.build(+1,-1){1} }.should raise_error(ArgumentError)
+ -> { Matrix.build(-1, 1){1} }.should.raise(ArgumentError)
+ -> { Matrix.build(+1,-1){1} }.should.raise(ArgumentError)
end
it "returns empty Matrix if one argument is zero" do
m = Matrix.build(0, 3){
raise "Should not yield"
}
- m.should be_empty
+ m.should.empty?
m.column_size.should == 3
m = Matrix.build(3, 0){
raise "Should not yield"
}
- m.should be_empty
+ m.should.empty?
m.row_size.should == 3
end
@@ -68,6 +68,6 @@ end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.build(3){1}.should be_an_instance_of(MatrixSub)
+ MatrixSub.build(3){1}.should.instance_of?(MatrixSub)
end
end
diff --git a/spec/ruby/library/matrix/clone_spec.rb b/spec/ruby/library/matrix/clone_spec.rb
index 8819fc9b40..51aefc6010 100644
--- a/spec/ruby/library/matrix/clone_spec.rb
+++ b/spec/ruby/library/matrix/clone_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#clone" do
@@ -9,17 +9,17 @@ describe "Matrix#clone" do
it "returns a shallow copy of the matrix" do
b = @a.clone
- @a.should_not equal(b)
- b.should be_kind_of(Matrix)
+ @a.should_not.equal?(b)
+ b.should.is_a?(Matrix)
b.should == @a
0.upto(@a.row_size - 1) do |i|
- @a.row(i).should_not equal(b.row(i))
+ @a.row(i).should_not.equal?(b.row(i))
end
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.clone.should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.clone.should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/coerce_spec.rb b/spec/ruby/library/matrix/coerce_spec.rb
index 6e653315a6..6032dd2f62 100644
--- a/spec/ruby/library/matrix/coerce_spec.rb
+++ b/spec/ruby/library/matrix/coerce_spec.rb
@@ -1,10 +1,8 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#coerce" do
- it "needs to be reviewed for spec completeness"
-
- it "allows the division of fixnum by a Matrix " do
+ it "allows the division of integer by a Matrix" do
(1/Matrix[[0,1],[-1,0]]).should == Matrix[[0,-1],[1,0]]
end
end
diff --git a/spec/ruby/library/matrix/collect_spec.rb b/spec/ruby/library/matrix/collect_spec.rb
index 1830aed103..bba640213b 100644
--- a/spec/ruby/library/matrix/collect_spec.rb
+++ b/spec/ruby/library/matrix/collect_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/collect', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/collect'
describe "Matrix#collect" do
- it_behaves_like(:collect, :collect)
+ it_behaves_like :collect, :collect
end
diff --git a/spec/ruby/library/matrix/column_size_spec.rb b/spec/ruby/library/matrix/column_size_spec.rb
index b1aae01bbc..041914e5b9 100644
--- a/spec/ruby/library/matrix/column_size_spec.rb
+++ b/spec/ruby/library/matrix/column_size_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#column_size" do
diff --git a/spec/ruby/library/matrix/column_spec.rb b/spec/ruby/library/matrix/column_spec.rb
index de84e33e8d..d5d8c80c1a 100644
--- a/spec/ruby/library/matrix/column_spec.rb
+++ b/spec/ruby/library/matrix/column_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#column" do
@@ -21,7 +21,7 @@ describe "Matrix#column" do
end
it "returns self when called with a block" do
- @m.column(0) { |x| x }.should equal(@m)
+ @m.column(0) { |x| x }.should.equal?(@m)
end
it "returns nil when out of bounds" do
@@ -29,7 +29,7 @@ describe "Matrix#column" do
end
it "never yields when out of bounds" do
- lambda { @m.column(3){ raise } }.should_not raise_error
- lambda { @m.column(-4){ raise } }.should_not raise_error
+ -> { @m.column(3){ raise } }.should_not.raise
+ -> { @m.column(-4){ raise } }.should_not.raise
end
end
diff --git a/spec/ruby/library/matrix/column_vector_spec.rb b/spec/ruby/library/matrix/column_vector_spec.rb
index f0cc46d646..d86c3f9e42 100644
--- a/spec/ruby/library/matrix/column_vector_spec.rb
+++ b/spec/ruby/library/matrix/column_vector_spec.rb
@@ -1,25 +1,25 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix.column_vector" do
it "returns a single column Matrix when called with an Array" do
m = Matrix.column_vector([4,5,6])
- m.should be_an_instance_of(Matrix)
+ m.should.instance_of?(Matrix)
m.should == Matrix[ [4],[5],[6] ]
end
it "returns an empty Matrix when called with an empty Array" do
m = Matrix.column_vector([])
- m.should be_an_instance_of(Matrix)
+ m.should.instance_of?(Matrix)
m.row_size.should == 0
m.column_size.should == 1
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.column_vector([4,5,6]).should be_an_instance_of(MatrixSub)
+ MatrixSub.column_vector([4,5,6]).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/column_vectors_spec.rb b/spec/ruby/library/matrix/column_vectors_spec.rb
index 8af64f83c8..7ac6871e7f 100644
--- a/spec/ruby/library/matrix/column_vectors_spec.rb
+++ b/spec/ruby/library/matrix/column_vectors_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#column_vectors" do
@@ -8,11 +8,11 @@ describe "Matrix#column_vectors" do
end
it "returns an Array" do
- Matrix[ [1,2], [3,4] ].column_vectors.should be_an_instance_of(Array)
+ Matrix[ [1,2], [3,4] ].column_vectors.should.instance_of?(Array)
end
it "returns an Array of Vectors" do
- @vectors.all? {|v| v.should be_an_instance_of(Vector)}
+ @vectors.all? {|v| v.should.instance_of?(Vector)}
end
it "returns each column as a Vector" do
diff --git a/spec/ruby/library/matrix/columns_spec.rb b/spec/ruby/library/matrix/columns_spec.rb
index b5fd5633bf..ac9587899d 100644
--- a/spec/ruby/library/matrix/columns_spec.rb
+++ b/spec/ruby/library/matrix/columns_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix.columns" do
@@ -10,7 +10,7 @@ describe "Matrix.columns" do
end
it "creates a Matrix from argument columns" do
- @m.should be_an_instance_of(Matrix)
+ @m.should.instance_of?(Matrix)
@m.column(0).to_a.should == @a
@m.column(1).to_a.should == @b
end
@@ -36,7 +36,7 @@ describe "Matrix.columns" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.columns([[1]]).should be_an_instance_of(MatrixSub)
+ MatrixSub.columns([[1]]).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/conj_spec.rb b/spec/ruby/library/matrix/conj_spec.rb
index 33221f7055..ecee95c255 100644
--- a/spec/ruby/library/matrix/conj_spec.rb
+++ b/spec/ruby/library/matrix/conj_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/conjugate', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/conjugate'
describe "Matrix#conj" do
- it_behaves_like(:matrix_conjugate, :conj)
+ it_behaves_like :matrix_conjugate, :conj
end
diff --git a/spec/ruby/library/matrix/conjugate_spec.rb b/spec/ruby/library/matrix/conjugate_spec.rb
index fd19f7689c..682bd41d94 100644
--- a/spec/ruby/library/matrix/conjugate_spec.rb
+++ b/spec/ruby/library/matrix/conjugate_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/conjugate', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/conjugate'
describe "Matrix#conjugate" do
- it_behaves_like(:matrix_conjugate, :conjugate)
+ it_behaves_like :matrix_conjugate, :conjugate
end
diff --git a/spec/ruby/library/matrix/constructor_spec.rb b/spec/ruby/library/matrix/constructor_spec.rb
index ae707166cd..026525f36d 100644
--- a/spec/ruby/library/matrix/constructor_spec.rb
+++ b/spec/ruby/library/matrix/constructor_spec.rb
@@ -1,14 +1,14 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix.[]" do
it "requires arrays as parameters" do
- lambda { Matrix[5] }.should raise_error(TypeError)
- lambda { Matrix[nil] }.should raise_error(TypeError)
- lambda { Matrix[1..2] }.should raise_error(TypeError)
- lambda { Matrix[[1, 2], 3] }.should raise_error(TypeError)
+ -> { Matrix[5] }.should.raise(TypeError)
+ -> { Matrix[nil] }.should.raise(TypeError)
+ -> { Matrix[1..2] }.should.raise(TypeError)
+ -> { Matrix[[1, 2], 3] }.should.raise(TypeError)
end
it "creates an empty Matrix with no arguments" do
@@ -18,15 +18,13 @@ describe "Matrix.[]" do
end
it "raises for non-rectangular matrices" do
- lambda{ Matrix[ [0], [0,1] ] }.should \
- raise_error(Matrix::ErrDimensionMismatch)
- lambda{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should \
- raise_error(Matrix::ErrDimensionMismatch)
+ ->{ Matrix[ [0], [0,1] ] }.should.raise(Matrix::ErrDimensionMismatch)
+ ->{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should.raise(Matrix::ErrDimensionMismatch)
end
it "accepts vector arguments" do
a = Matrix[Vector[1, 2], Vector[3, 4]]
- a.should be_an_instance_of(Matrix)
+ a.should.instance_of?(Matrix)
a.should == Matrix[ [1, 2], [3, 4] ]
end
@@ -38,7 +36,7 @@ describe "Matrix.[]" do
it "returns a Matrix object" do
- Matrix[ [1] ].should be_an_instance_of(Matrix)
+ Matrix[ [1] ].should.instance_of?(Matrix)
end
it "can create an nxn Matrix" do
@@ -59,7 +57,7 @@ describe "Matrix.[]" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub[ [20,30], [40.5, 9] ].should be_an_instance_of(MatrixSub)
+ MatrixSub[ [20,30], [40.5, 9] ].should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/det_spec.rb b/spec/ruby/library/matrix/det_spec.rb
index 698de34fd1..aa7086cacf 100644
--- a/spec/ruby/library/matrix/det_spec.rb
+++ b/spec/ruby/library/matrix/det_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/determinant', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/determinant'
require 'matrix'
describe "Matrix#det" do
- it_behaves_like(:determinant, :det)
+ it_behaves_like :determinant, :det
end
diff --git a/spec/ruby/library/matrix/determinant_spec.rb b/spec/ruby/library/matrix/determinant_spec.rb
index 9ad34c6fc3..825c9907b1 100644
--- a/spec/ruby/library/matrix/determinant_spec.rb
+++ b/spec/ruby/library/matrix/determinant_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/determinant', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/determinant'
require 'matrix'
describe "Matrix#determinant" do
- it_behaves_like(:determinant, :determinant)
+ it_behaves_like :determinant, :determinant
end
diff --git a/spec/ruby/library/matrix/diagonal_spec.rb b/spec/ruby/library/matrix/diagonal_spec.rb
index c88a92b5cd..ee84ac8c28 100644
--- a/spec/ruby/library/matrix/diagonal_spec.rb
+++ b/spec/ruby/library/matrix/diagonal_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix.diagonal" do
@@ -8,7 +8,7 @@ describe "Matrix.diagonal" do
end
it "returns an object of type Matrix" do
- @m.should be_kind_of(Matrix)
+ @m.should.is_a?(Matrix)
end
it "returns a square Matrix of the right size" do
@@ -34,27 +34,27 @@ describe "Matrix.diagonal" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.diagonal(1).should be_an_instance_of(MatrixSub)
+ MatrixSub.diagonal(1).should.instance_of?(MatrixSub)
end
end
end
describe "Matrix.diagonal?" do
it "returns true for a diagonal Matrix" do
- Matrix.diagonal([1, 2, 3]).diagonal?.should be_true
+ Matrix.diagonal([1, 2, 3]).diagonal?.should == true
end
it "returns true for a zero square Matrix" do
- Matrix.zero(3).diagonal?.should be_true
+ Matrix.zero(3).diagonal?.should == true
end
it "returns false for a non diagonal square Matrix" do
- Matrix[[0, 1], [0, 0]].diagonal?.should be_false
- Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].diagonal?.should be_false
+ Matrix[[0, 1], [0, 0]].diagonal?.should == false
+ Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].diagonal?.should == false
end
it "returns true for an empty 0x0 matrix" do
- Matrix.empty(0,0).diagonal?.should be_true
+ Matrix.empty(0,0).diagonal?.should == true
end
it "raises an error for rectangular matrices" do
@@ -63,10 +63,10 @@ describe "Matrix.diagonal?" do
Matrix[[0, 0]],
Matrix.empty(0, 2),
Matrix.empty(2, 0),
- ].each do |rectangual_matrix|
- lambda {
- rectangual_matrix.diagonal?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.diagonal?
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/divide_spec.rb b/spec/ruby/library/matrix/divide_spec.rb
index b602d7d10f..711a5189e4 100644
--- a/spec/ruby/library/matrix/divide_spec.rb
+++ b/spec/ruby/library/matrix/divide_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#/" do
@@ -14,13 +14,12 @@ describe "Matrix#/" do
(@a / @b).should be_close_to_matrix([[2.5, -1.5], [1.5, -0.5]])
end
- conflicts_with :Prime do
+ # Guard against the Mathn library
+ guard -> { !defined?(Math.rsqrt) } do
it "returns the result of dividing self by a Fixnum" do
(@a / 2).should == Matrix[ [0, 1], [1, 2] ]
end
- end
- conflicts_with :Prime do
it "returns the result of dividing self by a Bignum" do
(@a / bignum_value).should == Matrix[ [0, 0], [0, 0] ]
end
@@ -31,25 +30,25 @@ describe "Matrix#/" do
end
it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
- lambda { @a / Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
+ -> { @a / Matrix[ [1] ] }.should.raise(Matrix::ErrDimensionMismatch)
end
it "returns an instance of Matrix" do
- (@a / @b).should be_kind_of(Matrix)
+ (@a / @b).should.is_a?(Matrix)
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
m = MatrixSub.ins
- (m/m).should be_an_instance_of(MatrixSub)
- (m/1).should be_an_instance_of(MatrixSub)
+ (m/m).should.instance_of?(MatrixSub)
+ (m/1).should.instance_of?(MatrixSub)
end
end
it "raises a TypeError if other is of wrong type" do
- lambda { @a / nil }.should raise_error(TypeError)
- lambda { @a / "a" }.should raise_error(TypeError)
- lambda { @a / [ [1, 2] ] }.should raise_error(TypeError)
- lambda { @a / Object.new }.should raise_error(TypeError)
+ -> { @a / nil }.should.raise(TypeError)
+ -> { @a / "a" }.should.raise(TypeError)
+ -> { @a / [ [1, 2] ] }.should.raise(TypeError)
+ -> { @a / Object.new }.should.raise(TypeError)
end
end
diff --git a/spec/ruby/library/matrix/each_spec.rb b/spec/ruby/library/matrix/each_spec.rb
index 18875692e6..b4bfd3c76f 100644
--- a/spec/ruby/library/matrix/each_spec.rb
+++ b/spec/ruby/library/matrix/each_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#each" do
@@ -9,12 +9,12 @@ describe "Matrix#each" do
it "returns an Enumerator when called without a block" do
enum = @m.each
- enum.should be_an_instance_of(Enumerator)
+ enum.should.instance_of?(Enumerator)
enum.to_a.should == @result
end
it "returns self" do
- @m.each{}.should equal(@m)
+ @m.each{}.should.equal?(@m)
end
it "yields the elements starting with the those of the first row" do
@@ -31,15 +31,15 @@ describe "Matrix#each with an argument" do
end
it "raises an ArgumentError for unrecognized argument" do
- lambda {
+ -> {
@m.each("all"){}
- }.should raise_error(ArgumentError)
- lambda {
+ }.should.raise(ArgumentError)
+ -> {
@m.each(nil){}
- }.should raise_error(ArgumentError)
- lambda {
+ }.should.raise(ArgumentError)
+ -> {
@m.each(:left){}
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "yields the rights elements when passed :diagonal" do
diff --git a/spec/ruby/library/matrix/each_with_index_spec.rb b/spec/ruby/library/matrix/each_with_index_spec.rb
index 796a6c2a96..17e3f3f44c 100644
--- a/spec/ruby/library/matrix/each_with_index_spec.rb
+++ b/spec/ruby/library/matrix/each_with_index_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#each_with_index" do
@@ -16,12 +16,12 @@ describe "Matrix#each_with_index" do
it "returns an Enumerator when called without a block" do
enum = @m.each_with_index
- enum.should be_an_instance_of(Enumerator)
+ enum.should.instance_of?(Enumerator)
enum.to_a.should == @result
end
it "returns self" do
- @m.each_with_index{}.should equal(@m)
+ @m.each_with_index{}.should.equal?(@m)
end
it "yields the elements starting with the those of the first row" do
@@ -38,15 +38,15 @@ describe "Matrix#each_with_index with an argument" do
end
it "raises an ArgumentError for unrecognized argument" do
- lambda {
+ -> {
@m.each_with_index("all"){}
- }.should raise_error(ArgumentError)
- lambda {
+ }.should.raise(ArgumentError)
+ -> {
@m.each_with_index(nil){}
- }.should raise_error(ArgumentError)
- lambda {
+ }.should.raise(ArgumentError)
+ -> {
@m.each_with_index(:left){}
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "yields the rights elements when passed :diagonal" do
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb
index 3443eeaaf9..67f9dd1c19 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalue_matrix_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::EigenvalueDecomposition#eigenvalue_matrix" do
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb
index c175a29947..7552b7616c 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvalues_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::EigenvalueDecomposition#eigenvalues" do
@@ -8,7 +8,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvalues" do
[ Complex(1, -1), Complex(1, 1)]
end
- it "returns an array of real eigenvalues for a symetric matrix" do
+ it "returns an array of real eigenvalues for a symmetric matrix" do
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvalues.sort.map!{|x| x.round(10)}.should ==
[ -1, 3 ]
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb
index 709ec68d0c..09f229ee15 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvector_matrix_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::EigenvalueDecomposition#eigenvector_matrix" do
@@ -10,7 +10,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvector_matrix" do
[Complex(0, 1), Complex(0, -1)]]
end
- it "returns an real eigenvector matrix for a symetric matrix" do
+ it "returns an real eigenvector matrix for a symmetric matrix" do
# Fix me: should test for linearity, not for equality
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvector_matrix.should ==
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb
index 163bebe709..2b6ce74ea8 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/eigenvectors_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::EigenvalueDecomposition#eigenvectors" do
@@ -11,7 +11,7 @@ describe "Matrix::EigenvalueDecomposition#eigenvectors" do
]
end
- it "returns an array of real eigenvectors for a symetric matrix" do
+ it "returns an array of real eigenvectors for a symmetric matrix" do
# Fix me: should test for linearity, not for equality
Matrix[[1, 2],
[2, 1]].eigensystem.eigenvectors.should ==
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb
index 97d9be8f2d..cbda82a16a 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb
@@ -1,20 +1,20 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::EigenvalueDecomposition#initialize" do
it "raises an error if argument is not a matrix" do
- lambda {
+ -> {
Matrix::EigenvalueDecomposition.new([[]])
- }.should raise_error(TypeError)
- lambda {
+ }.should.raise(TypeError)
+ -> {
Matrix::EigenvalueDecomposition.new(42)
- }.should raise_error(TypeError)
+ }.should.raise(TypeError)
end
it "raises an error if matrix is not square" do
- lambda {
+ -> {
Matrix::EigenvalueDecomposition.new(Matrix[[1, 2]])
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
it "never hangs" do
diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb
index e9b849eb97..8be41a5720 100644
--- a/spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb
+++ b/spec/ruby/library/matrix/eigenvalue_decomposition/to_a_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::EigenvalueDecomposition#to_a" do
diff --git a/spec/ruby/library/matrix/element_reference_spec.rb b/spec/ruby/library/matrix/element_reference_spec.rb
index f4f63c0f65..c6804b3846 100644
--- a/spec/ruby/library/matrix/element_reference_spec.rb
+++ b/spec/ruby/library/matrix/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#[]" do
@@ -16,8 +16,8 @@ describe "Matrix#[]" do
end
it "returns nil for an invalid index pair" do
- @m[8,1].should be_nil
- @m[1,8].should be_nil
+ @m[8,1].should == nil
+ @m[1,8].should == nil
end
end
diff --git a/spec/ruby/library/matrix/empty_spec.rb b/spec/ruby/library/matrix/empty_spec.rb
index cead6126ff..7b0f0af9eb 100644
--- a/spec/ruby/library/matrix/empty_spec.rb
+++ b/spec/ruby/library/matrix/empty_spec.rb
@@ -1,23 +1,23 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#empty?" do
it "returns true when the Matrix is empty" do
- Matrix[ ].empty?.should be_true
- Matrix[ [], [], [] ].empty?.should be_true
- Matrix[ [], [], [] ].transpose.empty?.should be_true
+ Matrix[ ].empty?.should == true
+ Matrix[ [], [], [] ].empty?.should == true
+ Matrix[ [], [], [] ].transpose.empty?.should == true
end
it "returns false when the Matrix has elements" do
- Matrix[ [1, 2] ].empty?.should be_false
- Matrix[ [1], [2] ].empty?.should be_false
+ Matrix[ [1, 2] ].empty?.should == false
+ Matrix[ [1], [2] ].empty?.should == false
end
it "doesn't accept any parameter" do
- lambda{
+ ->{
Matrix[ [1, 2] ].empty?(42)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
end
@@ -38,31 +38,31 @@ describe "Matrix.empty" do
end
it "does not accept more than two parameters" do
- lambda{
+ ->{
Matrix.empty(1, 2, 3)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "raises an error if both dimensions are > 0" do
- lambda{
+ ->{
Matrix.empty(1, 2)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "raises an error if any dimension is < 0" do
- lambda{
+ ->{
Matrix.empty(-2, 0)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
- lambda{
+ ->{
Matrix.empty(0, -2)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.empty(0, 1).should be_an_instance_of(MatrixSub)
+ MatrixSub.empty(0, 1).should.instance_of?(MatrixSub)
end
end
diff --git a/spec/ruby/library/matrix/eql_spec.rb b/spec/ruby/library/matrix/eql_spec.rb
index e76d26753a..cda122f4d8 100644
--- a/spec/ruby/library/matrix/eql_spec.rb
+++ b/spec/ruby/library/matrix/eql_spec.rb
@@ -1,11 +1,11 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/equal_value', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/equal_value'
require 'matrix'
describe "Matrix#eql?" do
- it_behaves_like(:equal, :eql?)
+ it_behaves_like :equal, :eql?
it "returns false if some elements are == but not eql?" do
- Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should be_false
+ Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should == false
end
end
diff --git a/spec/ruby/library/matrix/equal_value_spec.rb b/spec/ruby/library/matrix/equal_value_spec.rb
index e14a38b872..10cf1e6c29 100644
--- a/spec/ruby/library/matrix/equal_value_spec.rb
+++ b/spec/ruby/library/matrix/equal_value_spec.rb
@@ -1,9 +1,9 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/equal_value', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/equal_value'
require 'matrix'
describe "Matrix#==" do
- it_behaves_like(:equal, :==)
+ it_behaves_like :equal, :==
it "returns true if some elements are == but not eql?" do
Matrix[[1, 2],[3, 4]].should == Matrix[[1, 2],[3, 4.0]]
diff --git a/spec/ruby/library/matrix/exponent_spec.rb b/spec/ruby/library/matrix/exponent_spec.rb
index 188a1b34d2..4cbe63587d 100644
--- a/spec/ruby/library/matrix/exponent_spec.rb
+++ b/spec/ruby/library/matrix/exponent_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#**" do
@@ -17,21 +17,32 @@ describe "Matrix#**" do
it "raises a ErrDimensionMismatch for non square matrices" do
m = Matrix[ [1, 1], [1, 2], [2, 3]]
- lambda { m ** 3 }.should raise_error(Matrix::ErrDimensionMismatch)
- lambda { m ** 0 }.should raise_error(Matrix::ErrDimensionMismatch)
+ -> { m ** 3 }.should.raise(Matrix::ErrDimensionMismatch)
+ -> { m ** 0 }.should.raise(Matrix::ErrDimensionMismatch)
end
- describe "that is <= 0" do
+ describe "that is < 0" do
it "returns the inverse of **(-n)" do
m = Matrix[ [1, 1], [1, 2] ]
(m ** -2).should == Matrix[ [5, -3], [-3, 2]]
(m ** -4).should == (m.inverse ** 4)
end
- it "raises a ErrDimensionMismatch for irregular matrices" do
+ it "raises a ErrNotRegular for irregular matrices" do
m = Matrix[ [1, 1], [1, 1] ]
- lambda { m ** -2 }.should raise_error(Matrix::ErrNotRegular)
- lambda { m ** 0 }.should raise_error(Matrix::ErrNotRegular)
+ -> { m ** -2 }.should.raise(Matrix::ErrNotRegular)
+ end
+ end
+
+ describe "that is 0" do
+ it "returns the identity for square matrices" do
+ m = Matrix[ [1, 1], [1, 1] ]
+ (m ** 0).should == Matrix.identity(2)
+ end
+
+ it "raises an ErrDimensionMismatch for non-square matrices" do
+ m = Matrix[ [1, 1] ]
+ -> { m ** 0 }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
@@ -45,7 +56,7 @@ describe "Matrix#**" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- (MatrixSub.ins ** 1).should be_an_instance_of(MatrixSub)
+ (MatrixSub.ins ** 1).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/find_index_spec.rb b/spec/ruby/library/matrix/find_index_spec.rb
index 8ea891644a..c7278fd449 100644
--- a/spec/ruby/library/matrix/find_index_spec.rb
+++ b/spec/ruby/library/matrix/find_index_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#find_index without any argument" do
@@ -8,12 +8,12 @@ describe "Matrix#find_index without any argument" do
it "returns an Enumerator when called without a block" do
enum = @m.find_index
- enum.should be_an_instance_of(Enumerator)
+ enum.should.instance_of?(Enumerator)
enum.to_a.should == [1, 2, 3, 4, 5, 6, 7, 8]
end
it "returns nil if the block is always false" do
- @m.find_index{false}.should be_nil
+ @m.find_index{false}.should == nil
end
it "returns the first index for which the block is true" do
@@ -48,7 +48,7 @@ describe "Matrix#find_index with a subselection argument" do
it "returns an Enumerator when called without a block" do
@tests.each do |matrix, h|
h.each do |selector, result|
- matrix.find_index(selector).should be_an_instance_of(Enumerator)
+ matrix.find_index(selector).should.instance_of?(Enumerator)
end
end
end
@@ -116,7 +116,7 @@ describe "Matrix#find_index with only a generic argument" do
end
it "returns nil if the value is not found" do
- @m.find_index(42).should be_nil
+ @m.find_index(42).should == nil
end
it "returns the first index for of the requested value" do
@@ -130,17 +130,17 @@ end
describe "Matrix#find_index with two arguments" do
it "raises an ArgumentError for an unrecognized last argument" do
- lambda {
+ -> {
@m.find_index(1, "all"){}
- }.should raise_error(ArgumentError)
- lambda {
+ }.should.raise(ArgumentError)
+ -> {
@m.find_index(1, nil){}
- }.should raise_error(ArgumentError)
- lambda {
+ }.should.raise(ArgumentError)
+ -> {
@m.find_index(1, :left){}
- }.should raise_error(ArgumentError)
- lambda {
+ }.should.raise(ArgumentError)
+ -> {
@m.find_index(:diagonal, 1){}
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
end
diff --git a/spec/ruby/library/matrix/hash_spec.rb b/spec/ruby/library/matrix/hash_spec.rb
index b2e5b579b7..27bf7b9751 100644
--- a/spec/ruby/library/matrix/hash_spec.rb
+++ b/spec/ruby/library/matrix/hash_spec.rb
@@ -1,10 +1,10 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#hash" do
- it "returns a Fixnum" do
- Matrix[ [1,2] ].hash.should be_an_instance_of(Fixnum)
+ it "returns an Integer" do
+ Matrix[ [1,2] ].hash.should.instance_of?(Integer)
end
it "returns the same value for the same matrix" do
diff --git a/spec/ruby/library/matrix/hermitian_spec.rb b/spec/ruby/library/matrix/hermitian_spec.rb
index cbfea433c2..94d0dbe6b6 100644
--- a/spec/ruby/library/matrix/hermitian_spec.rb
+++ b/spec/ruby/library/matrix/hermitian_spec.rb
@@ -1,17 +1,17 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix.hermitian?" do
it "returns true for a hermitian Matrix" do
- Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, -3), 5, 6]].hermitian?.should be_true
+ Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, -3), 5, 6]].hermitian?.should == true
end
it "returns true for a 0x0 empty matrix" do
- Matrix.empty.hermitian?.should be_true
+ Matrix.empty.hermitian?.should == true
end
- it "returns false for an assymetric Matrix" do
- Matrix[[1, 2],[-2, 1]].hermitian?.should be_false
+ it "returns false for an asymmetric Matrix" do
+ Matrix[[1, 2],[-2, 1]].hermitian?.should == false
end
it "raises an error for rectangular matrices" do
@@ -20,15 +20,15 @@ describe "Matrix.hermitian?" do
Matrix[[0, 0]],
Matrix.empty(0, 2),
Matrix.empty(2, 0),
- ].each do |rectangual_matrix|
- lambda {
- rectangual_matrix.hermitian?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.hermitian?
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
it "returns false for a matrix with complex values on the diagonal" do
- Matrix[[Complex(1,1)]].hermitian?.should be_false
- Matrix[[Complex(1,0)]].hermitian?.should be_true
+ Matrix[[Complex(1,1)]].hermitian?.should == false
+ Matrix[[Complex(1,0)]].hermitian?.should == true
end
end
diff --git a/spec/ruby/library/matrix/identity_spec.rb b/spec/ruby/library/matrix/identity_spec.rb
index bc7df98dde..646462bc47 100644
--- a/spec/ruby/library/matrix/identity_spec.rb
+++ b/spec/ruby/library/matrix/identity_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/identity', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/identity'
describe "Matrix.identity" do
- it_behaves_like(:matrix_identity, :identity)
+ it_behaves_like :matrix_identity, :identity
end
diff --git a/spec/ruby/library/matrix/imag_spec.rb b/spec/ruby/library/matrix/imag_spec.rb
index 41083879e4..1c988753d8 100644
--- a/spec/ruby/library/matrix/imag_spec.rb
+++ b/spec/ruby/library/matrix/imag_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/imaginary', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/imaginary'
describe "Matrix#imag" do
- it_behaves_like(:matrix_imaginary, :imag)
+ it_behaves_like :matrix_imaginary, :imag
end
diff --git a/spec/ruby/library/matrix/imaginary_spec.rb b/spec/ruby/library/matrix/imaginary_spec.rb
index 2a05f1d5c3..ceae4bbe8d 100644
--- a/spec/ruby/library/matrix/imaginary_spec.rb
+++ b/spec/ruby/library/matrix/imaginary_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/imaginary', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/imaginary'
describe "Matrix#imaginary" do
- it_behaves_like(:matrix_imaginary, :imaginary)
+ it_behaves_like :matrix_imaginary, :imaginary
end
diff --git a/spec/ruby/library/matrix/inspect_spec.rb b/spec/ruby/library/matrix/inspect_spec.rb
index bf623e1a85..508f478252 100644
--- a/spec/ruby/library/matrix/inspect_spec.rb
+++ b/spec/ruby/library/matrix/inspect_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#inspect" do
diff --git a/spec/ruby/library/matrix/inv_spec.rb b/spec/ruby/library/matrix/inv_spec.rb
index 0491aa7b07..82879a6d82 100644
--- a/spec/ruby/library/matrix/inv_spec.rb
+++ b/spec/ruby/library/matrix/inv_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../spec_helper', __FILE__)
-require File.expand_path('../shared/inverse', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'spec_helper'
+require_relative 'shared/inverse'
describe "Matrix#inv" do
- it_behaves_like(:inverse, :inv)
+ it_behaves_like :inverse, :inv
end
diff --git a/spec/ruby/library/matrix/inverse_from_spec.rb b/spec/ruby/library/matrix/inverse_from_spec.rb
index 958b3b7408..651d56a244 100644
--- a/spec/ruby/library/matrix/inverse_from_spec.rb
+++ b/spec/ruby/library/matrix/inverse_from_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#inverse_from" do
diff --git a/spec/ruby/library/matrix/inverse_spec.rb b/spec/ruby/library/matrix/inverse_spec.rb
index 33a1f2f5de..fa3fa7de8a 100644
--- a/spec/ruby/library/matrix/inverse_spec.rb
+++ b/spec/ruby/library/matrix/inverse_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../spec_helper', __FILE__)
-require File.expand_path('../shared/inverse', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'spec_helper'
+require_relative 'shared/inverse'
describe "Matrix#inverse" do
- it_behaves_like(:inverse, :inverse)
+ it_behaves_like :inverse, :inverse
end
diff --git a/spec/ruby/library/matrix/lower_triangular_spec.rb b/spec/ruby/library/matrix/lower_triangular_spec.rb
index 62b3df2104..7e8688fd9b 100644
--- a/spec/ruby/library/matrix/lower_triangular_spec.rb
+++ b/spec/ruby/library/matrix/lower_triangular_spec.rb
@@ -1,24 +1,24 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix.lower_triangular?" do
it "returns true for a square lower triangular Matrix" do
- Matrix[[1, 0, 0], [1, 2, 0], [1, 2, 3]].lower_triangular?.should be_true
- Matrix.diagonal([1, 2, 3]).lower_triangular?.should be_true
- Matrix[[1, 0], [1, 2], [1, 2], [1, 2]].lower_triangular?.should be_true
- Matrix[[1, 0, 0, 0], [1, 2, 0, 0]].lower_triangular?.should be_true
+ Matrix[[1, 0, 0], [1, 2, 0], [1, 2, 3]].lower_triangular?.should == true
+ Matrix.diagonal([1, 2, 3]).lower_triangular?.should == true
+ Matrix[[1, 0], [1, 2], [1, 2], [1, 2]].lower_triangular?.should == true
+ Matrix[[1, 0, 0, 0], [1, 2, 0, 0]].lower_triangular?.should == true
end
it "returns true for an empty Matrix" do
- Matrix.empty(3, 0).lower_triangular?.should be_true
- Matrix.empty(0, 3).lower_triangular?.should be_true
- Matrix.empty(0, 0).lower_triangular?.should be_true
+ Matrix.empty(3, 0).lower_triangular?.should == true
+ Matrix.empty(0, 3).lower_triangular?.should == true
+ Matrix.empty(0, 0).lower_triangular?.should == true
end
it "returns false for a non lower triangular square Matrix" do
- Matrix[[0, 1], [0, 0]].lower_triangular?.should be_false
- Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].lower_triangular?.should be_false
- Matrix[[0, 1], [0, 0], [0, 0], [0, 0]].lower_triangular?.should be_false
- Matrix[[0, 0, 0, 1], [0, 0, 0, 0]].lower_triangular?.should be_false
+ Matrix[[0, 1], [0, 0]].lower_triangular?.should == false
+ Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].lower_triangular?.should == false
+ Matrix[[0, 1], [0, 0], [0, 0], [0, 0]].lower_triangular?.should == false
+ Matrix[[0, 0, 0, 1], [0, 0, 0, 0]].lower_triangular?.should == false
end
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb b/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb
index f73c65ba8f..98ac5c71a3 100644
--- a/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::LUPDecomposition#determinant" do
@@ -13,9 +13,9 @@ describe "Matrix::LUPDecomposition#determinant" do
Matrix[[7, 8], [14, 46], [28, 82]],
].each do |m|
lup = m.lup
- lambda {
+ -> {
lup.determinant
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb b/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb
index 953389083f..b813757525 100644
--- a/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb
@@ -1,13 +1,13 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::LUPDecomposition#initialize" do
it "raises an error if argument is not a matrix" do
- lambda {
+ -> {
Matrix::LUPDecomposition.new([[]])
- }.should raise_error(TypeError)
- lambda {
+ }.should.raise(TypeError)
+ -> {
Matrix::LUPDecomposition.new(42)
- }.should raise_error(TypeError)
+ }.should.raise(TypeError)
end
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/l_spec.rb b/spec/ruby/library/matrix/lup_decomposition/l_spec.rb
index c50b5f712e..0a6797cc85 100644
--- a/spec/ruby/library/matrix/lup_decomposition/l_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/l_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::LUPDecomposition#l" do
@@ -13,6 +13,6 @@ describe "Matrix::LUPDecomposition#l" do
end
it "returns a lower triangular matrix" do
- @l.lower_triangular?.should be_true
+ @l.lower_triangular?.should == true
end
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/p_spec.rb b/spec/ruby/library/matrix/lup_decomposition/p_spec.rb
index 837b65a915..2c44399b79 100644
--- a/spec/ruby/library/matrix/lup_decomposition/p_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/p_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::LUPDecomposition#p" do
@@ -13,6 +13,6 @@ describe "Matrix::LUPDecomposition#p" do
end
it "returns a permutation matrix" do
- @p.permutation?.should be_true
+ @p.permutation?.should == true
end
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb b/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb
index c4ef42bcea..9927e96727 100644
--- a/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::LUPDecomposition#solve" do
@@ -6,9 +6,9 @@ describe "Matrix::LUPDecomposition#solve" do
it "raises an error for singular matrices" do
a = Matrix[[1, 2, 3], [1, 3, 5], [2, 5, 8]]
lu = Matrix::LUPDecomposition.new(a)
- lambda {
+ -> {
lu.solve(a)
- }.should raise_error(Matrix::ErrNotRegular)
+ }.should.raise(Matrix::ErrNotRegular)
end
describe "for non singular matrices" do
@@ -31,9 +31,9 @@ describe "Matrix::LUPDecomposition#solve" do
it "raises an error when given a matrix of the wrong size" do
values = Matrix[[1, 2, 3, 4], [0, 1, 2, 3]]
- lambda {
+ -> {
@lu.solve(values)
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
it "returns the right vector when given a vector of the appropriate size" do
@@ -44,9 +44,9 @@ describe "Matrix::LUPDecomposition#solve" do
it "raises an error when given a vector of the wrong size" do
values = Vector[14, 55]
- lambda {
+ -> {
@lu.solve(values)
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb b/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb
index 20be26eb9c..ab59677dd9 100644
--- a/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::LUPDecomposition#to_a" do
@@ -10,9 +10,9 @@ describe "Matrix::LUPDecomposition#to_a" do
end
it "returns an array of three matrices" do
- @to_a.should be_kind_of(Array)
+ @to_a.should.is_a?(Array)
@to_a.length.should == 3
- @to_a.each{|m| m.should be_kind_of(Matrix)}
+ @to_a.each{|m| m.should.is_a?(Matrix)}
end
it "returns [l, u, p] such that l*u == a*p" do
diff --git a/spec/ruby/library/matrix/lup_decomposition/u_spec.rb b/spec/ruby/library/matrix/lup_decomposition/u_spec.rb
index 97e8580c58..967bc669dc 100644
--- a/spec/ruby/library/matrix/lup_decomposition/u_spec.rb
+++ b/spec/ruby/library/matrix/lup_decomposition/u_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::LUPDecomposition#u" do
@@ -13,6 +13,6 @@ describe "Matrix::LUPDecomposition#u" do
end
it "returns an upper triangular matrix" do
- @u.upper_triangular?.should be_true
+ @u.upper_triangular?.should == true
end
end
diff --git a/spec/ruby/library/matrix/map_spec.rb b/spec/ruby/library/matrix/map_spec.rb
index e18ab6eb7a..bc07c48cda 100644
--- a/spec/ruby/library/matrix/map_spec.rb
+++ b/spec/ruby/library/matrix/map_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/collect', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/collect'
describe "Matrix#map" do
- it_behaves_like(:collect, :map)
+ it_behaves_like :collect, :map
end
diff --git a/spec/ruby/library/matrix/minor_spec.rb b/spec/ruby/library/matrix/minor_spec.rb
index e02e0de07d..6b29db568b 100644
--- a/spec/ruby/library/matrix/minor_spec.rb
+++ b/spec/ruby/library/matrix/minor_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#minor" do
@@ -79,7 +79,7 @@ describe "Matrix#minor" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.minor(0, 1, 0, 1).should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.minor(0, 1, 0, 1).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/minus_spec.rb b/spec/ruby/library/matrix/minus_spec.rb
index fe2d716882..7426aa2d2c 100644
--- a/spec/ruby/library/matrix/minus_spec.rb
+++ b/spec/ruby/library/matrix/minus_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#-" do
@@ -13,30 +13,30 @@ describe "Matrix#-" do
end
it "returns an instance of Matrix" do
- (@a - @b).should be_kind_of(Matrix)
+ (@a - @b).should.is_a?(Matrix)
end
it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
- lambda { @a - Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
+ -> { @a - Matrix[ [1] ] }.should.raise(Matrix::ErrDimensionMismatch)
end
it "raises a ExceptionForMatrix::ErrOperationNotDefined if other is a Numeric Type" do
- lambda { @a - 2 }.should raise_error(Matrix::ErrOperationNotDefined)
- lambda { @a - 1.2 }.should raise_error(Matrix::ErrOperationNotDefined)
- lambda { @a - bignum_value }.should raise_error(Matrix::ErrOperationNotDefined)
+ -> { @a - 2 }.should.raise(Matrix::ErrOperationNotDefined)
+ -> { @a - 1.2 }.should.raise(Matrix::ErrOperationNotDefined)
+ -> { @a - bignum_value }.should.raise(Matrix::ErrOperationNotDefined)
end
it "raises a TypeError if other is of wrong type" do
- lambda { @a - nil }.should raise_error(TypeError)
- lambda { @a - "a" }.should raise_error(TypeError)
- lambda { @a - [ [1, 2] ] }.should raise_error(TypeError)
- lambda { @a - Object.new }.should raise_error(TypeError)
+ -> { @a - nil }.should.raise(TypeError)
+ -> { @a - "a" }.should.raise(TypeError)
+ -> { @a - [ [1, 2] ] }.should.raise(TypeError)
+ -> { @a - Object.new }.should.raise(TypeError)
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
m = MatrixSub.ins
- (m-m).should be_an_instance_of(MatrixSub)
+ (m-m).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/multiply_spec.rb b/spec/ruby/library/matrix/multiply_spec.rb
index dae87f5434..6c495c5521 100644
--- a/spec/ruby/library/matrix/multiply_spec.rb
+++ b/spec/ruby/library/matrix/multiply_spec.rb
@@ -1,5 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#*" do
@@ -22,8 +23,8 @@ describe "Matrix#*" do
it "returns the result of multiplying the elements of self and a Bignum" do
(@a * bignum_value).should == Matrix[
- [9223372036854775808, 18446744073709551616],
- [27670116110564327424, 36893488147419103232]
+ [18446744073709551616, 36893488147419103232],
+ [55340232221128654848, 73786976294838206464]
]
end
@@ -32,7 +33,7 @@ describe "Matrix#*" do
end
it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
- lambda { @a * Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
+ -> { @a * Matrix[ [1] ] }.should.raise(Matrix::ErrDimensionMismatch)
end
it "returns a zero matrix if (nx0) * (0xn)" do
@@ -52,17 +53,17 @@ describe "Matrix#*" do
end
it "raises a TypeError if other is of wrong type" do
- lambda { @a * nil }.should raise_error(TypeError)
- lambda { @a * "a" }.should raise_error(TypeError)
- lambda { @a * [ [1, 2] ] }.should raise_error(TypeError)
- lambda { @a * Object.new }.should raise_error(TypeError)
+ -> { @a * nil }.should.raise(TypeError)
+ -> { @a * "a" }.should.raise(TypeError)
+ -> { @a * [ [1, 2] ] }.should.raise(TypeError)
+ -> { @a * Object.new }.should.raise(TypeError)
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
m = MatrixSub.ins
- (m*m).should be_an_instance_of(MatrixSub)
- (m*1).should be_an_instance_of(MatrixSub)
+ (m*m).should.instance_of?(MatrixSub)
+ (m*1).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/new_spec.rb b/spec/ruby/library/matrix/new_spec.rb
index 82d2bd88a7..bde9d9f4c8 100644
--- a/spec/ruby/library/matrix/new_spec.rb
+++ b/spec/ruby/library/matrix/new_spec.rb
@@ -1,8 +1,8 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix.new" do
it "is private" do
- Matrix.should have_private_method(:new)
+ Matrix.private_methods(false).should.include?(:new)
end
end
diff --git a/spec/ruby/library/matrix/normal_spec.rb b/spec/ruby/library/matrix/normal_spec.rb
index 140909dcc2..420d4b011f 100644
--- a/spec/ruby/library/matrix/normal_spec.rb
+++ b/spec/ruby/library/matrix/normal_spec.rb
@@ -1,14 +1,14 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix.normal?" do
# it "returns false for non normal matrices" do
- # Matrix[[0, 1], [1, 2]].normal?.should == false
+ # Matrix[[0, 1], [1, 2]].should_not.normal?
# end
it "returns true for normal matrices" do
- Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].normal?.should == true
- Matrix[[0, Complex(0, 2)], [Complex(0, -2), 0]].normal?.should == true
+ Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].should.normal?
+ Matrix[[0, Complex(0, 2)], [Complex(0, -2), 0]].should.normal?
end
it "raises an error for rectangular matrices" do
@@ -17,10 +17,10 @@ describe "Matrix.normal?" do
Matrix[[0, 0]],
Matrix.empty(0, 2),
Matrix.empty(2, 0),
- ].each do |rectangual_matrix|
- lambda {
- rectangual_matrix.normal?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.normal?
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/orthogonal_spec.rb b/spec/ruby/library/matrix/orthogonal_spec.rb
index 2e76b5924c..71ac831fe8 100644
--- a/spec/ruby/library/matrix/orthogonal_spec.rb
+++ b/spec/ruby/library/matrix/orthogonal_spec.rb
@@ -1,14 +1,14 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix.orthogonal?" do
it "returns false for non orthogonal matrices" do
- Matrix[[0, 1], [1, 2]].orthogonal?.should == false
- Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].orthogonal?.should == false
+ Matrix[[0, 1], [1, 2]].should_not.orthogonal?
+ Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].should_not.orthogonal?
end
it "returns true for orthogonal matrices" do
- Matrix[[0, 1], [1, 0]].orthogonal?.should == true
+ Matrix[[0, 1], [1, 0]].should.orthogonal?
end
it "raises an error for rectangular matrices" do
@@ -17,10 +17,10 @@ describe "Matrix.orthogonal?" do
Matrix[[0, 0]],
Matrix.empty(0, 2),
Matrix.empty(2, 0),
- ].each do |rectangual_matrix|
- lambda {
- rectangual_matrix.orthogonal?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.orthogonal?
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/permutation_spec.rb b/spec/ruby/library/matrix/permutation_spec.rb
index 7098c46015..43727edea1 100644
--- a/spec/ruby/library/matrix/permutation_spec.rb
+++ b/spec/ruby/library/matrix/permutation_spec.rb
@@ -1,20 +1,20 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#permutation?" do
it "returns true for a permutation Matrix" do
- Matrix[[0, 1, 0], [0, 0, 1], [1, 0, 0]].permutation?.should be_true
+ Matrix[[0, 1, 0], [0, 0, 1], [1, 0, 0]].permutation?.should == true
end
it "returns false for a non permutation square Matrix" do
- Matrix[[0, 1], [0, 0]].permutation?.should be_false
- Matrix[[-1, 0], [0, -1]].permutation?.should be_false
- Matrix[[1, 0], [1, 0]].permutation?.should be_false
- Matrix[[1, 0], [1, 1]].permutation?.should be_false
+ Matrix[[0, 1], [0, 0]].permutation?.should == false
+ Matrix[[-1, 0], [0, -1]].permutation?.should == false
+ Matrix[[1, 0], [1, 0]].permutation?.should == false
+ Matrix[[1, 0], [1, 1]].permutation?.should == false
end
it "returns true for an empty 0x0 matrix" do
- Matrix.empty(0,0).permutation?.should be_true
+ Matrix.empty(0,0).permutation?.should == true
end
it "raises an error for rectangular matrices" do
@@ -23,10 +23,10 @@ describe "Matrix#permutation?" do
Matrix[[0, 0]],
Matrix.empty(0, 2),
Matrix.empty(2, 0),
- ].each do |rectangual_matrix|
- lambda {
- rectangual_matrix.permutation?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.permutation?
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/plus_spec.rb b/spec/ruby/library/matrix/plus_spec.rb
index 59addfdf62..72a9ba8f8f 100644
--- a/spec/ruby/library/matrix/plus_spec.rb
+++ b/spec/ruby/library/matrix/plus_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#+" do
@@ -13,30 +13,30 @@ describe "Matrix#+" do
end
it "returns an instance of Matrix" do
- (@a + @b).should be_kind_of(Matrix)
+ (@a + @b).should.is_a?(Matrix)
end
it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
- lambda { @a + Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
+ -> { @a + Matrix[ [1] ] }.should.raise(Matrix::ErrDimensionMismatch)
end
it "raises a ExceptionForMatrix::ErrOperationNotDefined if other is a Numeric Type" do
- lambda { @a + 2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
- lambda { @a + 1.2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
- lambda { @a + bignum_value }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
+ -> { @a + 2 }.should.raise(ExceptionForMatrix::ErrOperationNotDefined)
+ -> { @a + 1.2 }.should.raise(ExceptionForMatrix::ErrOperationNotDefined)
+ -> { @a + bignum_value }.should.raise(ExceptionForMatrix::ErrOperationNotDefined)
end
it "raises a TypeError if other is of wrong type" do
- lambda { @a + nil }.should raise_error(TypeError)
- lambda { @a + "a" }.should raise_error(TypeError)
- lambda { @a + [ [1, 2] ] }.should raise_error(TypeError)
- lambda { @a + Object.new }.should raise_error(TypeError)
+ -> { @a + nil }.should.raise(TypeError)
+ -> { @a + "a" }.should.raise(TypeError)
+ -> { @a + [ [1, 2] ] }.should.raise(TypeError)
+ -> { @a + Object.new }.should.raise(TypeError)
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
m = MatrixSub.ins
- (m+m).should be_an_instance_of(MatrixSub)
+ (m+m).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/rank_spec.rb b/spec/ruby/library/matrix/rank_spec.rb
index 42b6de1ab8..d4403d23ed 100644
--- a/spec/ruby/library/matrix/rank_spec.rb
+++ b/spec/ruby/library/matrix/rank_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#rank" do
diff --git a/spec/ruby/library/matrix/real_spec.rb b/spec/ruby/library/matrix/real_spec.rb
index 98da7f8a7c..4589dc22a5 100644
--- a/spec/ruby/library/matrix/real_spec.rb
+++ b/spec/ruby/library/matrix/real_spec.rb
@@ -1,24 +1,25 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#real?" do
it "returns true for matrices with all real entries" do
- Matrix[ [1, 2], [3, 4] ].real?.should be_true
- Matrix[ [1.9, 2], [3, 4] ].real?.should be_true
+ Matrix[ [1, 2], [3, 4] ].real?.should == true
+ Matrix[ [1.9, 2], [3, 4] ].real?.should == true
end
it "returns true for empty matrices" do
- Matrix.empty.real?.should be_true
+ Matrix.empty.real?.should == true
end
it "returns false if one element is a Complex" do
- Matrix[ [Complex(1,1), 2], [3, 4] ].real?.should be_false
+ Matrix[ [Complex(1,1), 2], [3, 4] ].real?.should == false
end
- conflicts_with :CMath do
+ # Guard against the Mathn library
+ guard -> { !defined?(Math.rsqrt) } do
it "returns false if one element is a Complex whose imaginary part is 0" do
- Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should be_false
+ Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should == false
end
end
end
@@ -36,7 +37,7 @@ describe "Matrix#real" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.real.should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.real.should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/rect_spec.rb b/spec/ruby/library/matrix/rect_spec.rb
index d0a3b2705b..83a0404e47 100644
--- a/spec/ruby/library/matrix/rect_spec.rb
+++ b/spec/ruby/library/matrix/rect_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/rectangular', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/rectangular'
describe "Matrix#rect" do
- it_behaves_like(:matrix_rectangular, :rect)
+ it_behaves_like :matrix_rectangular, :rect
end
diff --git a/spec/ruby/library/matrix/rectangular_spec.rb b/spec/ruby/library/matrix/rectangular_spec.rb
index 7af446cb18..a235fac640 100644
--- a/spec/ruby/library/matrix/rectangular_spec.rb
+++ b/spec/ruby/library/matrix/rectangular_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/rectangular', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/rectangular'
describe "Matrix#rectangular" do
- it_behaves_like(:matrix_rectangular, :rectangular)
+ it_behaves_like :matrix_rectangular, :rectangular
end
diff --git a/spec/ruby/library/matrix/regular_spec.rb b/spec/ruby/library/matrix/regular_spec.rb
index 2f0af99c1e..4cb00819ac 100644
--- a/spec/ruby/library/matrix/regular_spec.rb
+++ b/spec/ruby/library/matrix/regular_spec.rb
@@ -1,31 +1,31 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#regular?" do
it "returns false for singular matrices" do
m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
- m.regular?.should be_false
+ m.regular?.should == false
m = Matrix[ [1,2,9], [3,4,9], [1,2,9] ]
- m.regular?.should be_false
+ m.regular?.should == false
end
it "returns true if the Matrix is regular" do
- Matrix[ [0,1], [1,0] ].regular?.should be_true
+ Matrix[ [0,1], [1,0] ].regular?.should == true
end
it "returns true for an empty 0x0 matrix" do
- Matrix.empty(0,0).regular?.should be_true
+ Matrix.empty(0,0).regular?.should == true
end
it "raises an error for rectangular matrices" do
- lambda {
+ -> {
Matrix[[1], [2], [3]].regular?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
- lambda {
+ -> {
Matrix.empty(3,0).regular?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
diff --git a/spec/ruby/library/matrix/round_spec.rb b/spec/ruby/library/matrix/round_spec.rb
index f502a35c68..cdec646fa1 100644
--- a/spec/ruby/library/matrix/round_spec.rb
+++ b/spec/ruby/library/matrix/round_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix#round" do
@@ -15,7 +15,7 @@ describe "Matrix#round" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.round.should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.round.should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/row_size_spec.rb b/spec/ruby/library/matrix/row_size_spec.rb
index ee685ba5fb..eb3aef2e2f 100644
--- a/spec/ruby/library/matrix/row_size_spec.rb
+++ b/spec/ruby/library/matrix/row_size_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#row_size" do
diff --git a/spec/ruby/library/matrix/row_spec.rb b/spec/ruby/library/matrix/row_spec.rb
index e165e48f5f..8a7662fdf2 100644
--- a/spec/ruby/library/matrix/row_spec.rb
+++ b/spec/ruby/library/matrix/row_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#row" do
@@ -21,7 +21,7 @@ describe "Matrix#row" do
end
it "returns self when called with a block" do
- @m.row(0) { |x| x }.should equal(@m)
+ @m.row(0) { |x| x }.should.equal?(@m)
end
it "returns nil when out of bounds" do
@@ -30,7 +30,7 @@ describe "Matrix#row" do
end
it "never yields when out of bounds" do
- lambda { @m.row(3){ raise } }.should_not raise_error
- lambda { @m.row(-4){ raise } }.should_not raise_error
+ -> { @m.row(3){ raise } }.should_not.raise
+ -> { @m.row(-4){ raise } }.should_not.raise
end
end
diff --git a/spec/ruby/library/matrix/row_vector_spec.rb b/spec/ruby/library/matrix/row_vector_spec.rb
index 60907e9247..f3919fb7d8 100644
--- a/spec/ruby/library/matrix/row_vector_spec.rb
+++ b/spec/ruby/library/matrix/row_vector_spec.rb
@@ -1,11 +1,11 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix.row_vector" do
it "returns a Matrix" do
- Matrix.row_vector([]).should be_an_instance_of(Matrix)
+ Matrix.row_vector([]).should.instance_of?(Matrix)
end
it "returns a single-row Matrix with the specified values" do
@@ -18,7 +18,7 @@ describe "Matrix.row_vector" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.row_vector([1]).should be_an_instance_of(MatrixSub)
+ MatrixSub.row_vector([1]).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/row_vectors_spec.rb b/spec/ruby/library/matrix/row_vectors_spec.rb
index 46f97bb748..4a0db67527 100644
--- a/spec/ruby/library/matrix/row_vectors_spec.rb
+++ b/spec/ruby/library/matrix/row_vectors_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#row_vectors" do
@@ -8,11 +8,11 @@ describe "Matrix#row_vectors" do
end
it "returns an Array" do
- Matrix[ [1,2], [3,4] ].row_vectors.should be_an_instance_of(Array)
+ Matrix[ [1,2], [3,4] ].row_vectors.should.instance_of?(Array)
end
it "returns an Array of Vectors" do
- @vectors.all? {|v| v.should be_an_instance_of(Vector)}
+ @vectors.all? {|v| v.should.instance_of?(Vector)}
end
it "returns each row as a Vector" do
diff --git a/spec/ruby/library/matrix/rows_spec.rb b/spec/ruby/library/matrix/rows_spec.rb
index d583a07b30..9c248cd8a4 100644
--- a/spec/ruby/library/matrix/rows_spec.rb
+++ b/spec/ruby/library/matrix/rows_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix.rows" do
@@ -10,7 +10,7 @@ describe "Matrix.rows" do
end
it "returns a Matrix" do
- @m.should be_kind_of(Matrix)
+ @m.should.is_a?(Matrix)
end
it "creates a matrix from argument rows" do
@@ -21,8 +21,8 @@ describe "Matrix.rows" do
it "copies the original rows by default" do
@a << 3
@b << 6
- @m.row(0).should_not equal(@a)
- @m.row(1).should_not equal(@b)
+ @m.row(0).should_not.equal?(@a)
+ @m.row(1).should_not.equal?(@b)
end
it "references the original rows if copy is false" do
@@ -35,7 +35,7 @@ describe "Matrix.rows" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.rows([[0, 1], [0, 1]]).should be_an_instance_of(MatrixSub)
+ MatrixSub.rows([[0, 1], [0, 1]]).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/scalar/Fail_spec.rb b/spec/ruby/library/matrix/scalar/Fail_spec.rb
index fbd0f3013a..9d8f9bd5e8 100644
--- a/spec/ruby/library/matrix/scalar/Fail_spec.rb
+++ b/spec/ruby/library/matrix/scalar/Fail_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar#Fail" do
diff --git a/spec/ruby/library/matrix/scalar/Raise_spec.rb b/spec/ruby/library/matrix/scalar/Raise_spec.rb
index 3e98fcb22a..27e11c1f77 100644
--- a/spec/ruby/library/matrix/scalar/Raise_spec.rb
+++ b/spec/ruby/library/matrix/scalar/Raise_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar#Raise" do
diff --git a/spec/ruby/library/matrix/scalar/divide_spec.rb b/spec/ruby/library/matrix/scalar/divide_spec.rb
index 6b8e0b6bcc..5d726943fe 100644
--- a/spec/ruby/library/matrix/scalar/divide_spec.rb
+++ b/spec/ruby/library/matrix/scalar/divide_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar#/" do
diff --git a/spec/ruby/library/matrix/scalar/exponent_spec.rb b/spec/ruby/library/matrix/scalar/exponent_spec.rb
index 55997793eb..8e9ef52ff2 100644
--- a/spec/ruby/library/matrix/scalar/exponent_spec.rb
+++ b/spec/ruby/library/matrix/scalar/exponent_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar#**" do
diff --git a/spec/ruby/library/matrix/scalar/included_spec.rb b/spec/ruby/library/matrix/scalar/included_spec.rb
index 58ee233eb3..cb3beb2ecd 100644
--- a/spec/ruby/library/matrix/scalar/included_spec.rb
+++ b/spec/ruby/library/matrix/scalar/included_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar.included" do
diff --git a/spec/ruby/library/matrix/scalar/initialize_spec.rb b/spec/ruby/library/matrix/scalar/initialize_spec.rb
index fd6ef00211..23145ad0de 100644
--- a/spec/ruby/library/matrix/scalar/initialize_spec.rb
+++ b/spec/ruby/library/matrix/scalar/initialize_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar#initialize" do
diff --git a/spec/ruby/library/matrix/scalar/minus_spec.rb b/spec/ruby/library/matrix/scalar/minus_spec.rb
index 19a7b4f1a1..c727ea1659 100644
--- a/spec/ruby/library/matrix/scalar/minus_spec.rb
+++ b/spec/ruby/library/matrix/scalar/minus_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar#-" do
diff --git a/spec/ruby/library/matrix/scalar/multiply_spec.rb b/spec/ruby/library/matrix/scalar/multiply_spec.rb
index 247cc1447c..1a2a83d83e 100644
--- a/spec/ruby/library/matrix/scalar/multiply_spec.rb
+++ b/spec/ruby/library/matrix/scalar/multiply_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar#*" do
diff --git a/spec/ruby/library/matrix/scalar/plus_spec.rb b/spec/ruby/library/matrix/scalar/plus_spec.rb
index 7cdaa1c7f3..c94689a702 100644
--- a/spec/ruby/library/matrix/scalar/plus_spec.rb
+++ b/spec/ruby/library/matrix/scalar/plus_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Matrix::Scalar#+" do
diff --git a/spec/ruby/library/matrix/scalar_spec.rb b/spec/ruby/library/matrix/scalar_spec.rb
index 3da8771471..5b93b60533 100644
--- a/spec/ruby/library/matrix/scalar_spec.rb
+++ b/spec/ruby/library/matrix/scalar_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix.scalar" do
@@ -10,7 +10,7 @@ describe "Matrix.scalar" do
end
it "returns a Matrix" do
- @a.should be_kind_of(Matrix)
+ @a.should.is_a?(Matrix)
end
it "returns a n x n matrix" do
@@ -41,7 +41,7 @@ describe "Matrix.scalar" do
end
it "returns a Matrix" do
- @a.should be_kind_of(Matrix)
+ @a.should.is_a?(Matrix)
end
it "returns a square matrix, where the first argument specifies the side of the square" do
diff --git a/spec/ruby/library/matrix/shared/collect.rb b/spec/ruby/library/matrix/shared/collect.rb
index 256cd6a190..3a4dbe3a36 100644
--- a/spec/ruby/library/matrix/shared/collect.rb
+++ b/spec/ruby/library/matrix/shared/collect.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../fixtures/classes', __FILE__)
+require_relative '../fixtures/classes'
require 'matrix'
describe :collect, shared: true do
@@ -7,7 +7,7 @@ describe :collect, shared: true do
end
it "returns an instance of Matrix" do
- @m.send(@method){|n| n * 2 }.should be_kind_of(Matrix)
+ @m.send(@method){|n| n * 2 }.should.is_a?(Matrix)
end
it "returns a Matrix where each element is the result of the block" do
@@ -15,12 +15,12 @@ describe :collect, shared: true do
end
it "returns an enumerator if no block is given" do
- @m.send(@method).should be_an_instance_of(Enumerator)
+ @m.send(@method).should.instance_of?(Enumerator)
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.send(@method){1}.should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.send(@method){1}.should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/shared/conjugate.rb b/spec/ruby/library/matrix/shared/conjugate.rb
index 180ff4fa98..ffdf5ebca1 100644
--- a/spec/ruby/library/matrix/shared/conjugate.rb
+++ b/spec/ruby/library/matrix/shared/conjugate.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../fixtures/classes', __FILE__)
+require_relative '../fixtures/classes'
require 'matrix'
describe :matrix_conjugate, shared: true do
@@ -14,7 +14,7 @@ describe :matrix_conjugate, shared: true do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.send(@method).should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.send(@method).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/shared/determinant.rb b/spec/ruby/library/matrix/shared/determinant.rb
index 47a58c62a6..b7c86393ba 100644
--- a/spec/ruby/library/matrix/shared/determinant.rb
+++ b/spec/ruby/library/matrix/shared/determinant.rb
@@ -27,12 +27,12 @@ describe :determinant, shared: true do
end
it "raises an error for rectangular matrices" do
- lambda {
+ -> {
Matrix[[1], [2], [3]].send(@method)
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
- lambda {
+ -> {
Matrix.empty(3,0).send(@method)
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
diff --git a/spec/ruby/library/matrix/shared/equal_value.rb b/spec/ruby/library/matrix/shared/equal_value.rb
index e2102e823a..9bc6ed908b 100644
--- a/spec/ruby/library/matrix/shared/equal_value.rb
+++ b/spec/ruby/library/matrix/shared/equal_value.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../fixtures/classes', __FILE__)
+require_relative '../fixtures/classes'
require 'matrix'
describe :equal, shared: true do
@@ -7,27 +7,27 @@ describe :equal, shared: true do
end
it "returns true for self" do
- @matrix.send(@method, @matrix).should be_true
+ @matrix.send(@method, @matrix).should == true
end
it "returns true for equal matrices" do
- @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_true
+ @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should == true
end
it "returns false for different matrices" do
- @matrix.send(@method, Matrix[ [42, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_false
- @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7] ]).should be_false
- @matrix.send(@method, Matrix[ [1, 2, 3], [2, 3, 4] ]).should be_false
+ @matrix.send(@method, Matrix[ [42, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should == false
+ @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7] ]).should == false
+ @matrix.send(@method, Matrix[ [1, 2, 3], [2, 3, 4] ]).should == false
end
it "returns false for different empty matrices" do
- Matrix.empty(42, 0).send(@method, Matrix.empty(6, 0)).should be_false
- Matrix.empty(0, 42).send(@method, Matrix.empty(0, 6)).should be_false
- Matrix.empty(0, 0).send(@method, Matrix.empty(6, 0)).should be_false
- Matrix.empty(0, 0).send(@method, Matrix.empty(0, 6)).should be_false
+ Matrix.empty(42, 0).send(@method, Matrix.empty(6, 0)).should == false
+ Matrix.empty(0, 42).send(@method, Matrix.empty(0, 6)).should == false
+ Matrix.empty(0, 0).send(@method, Matrix.empty(6, 0)).should == false
+ Matrix.empty(0, 0).send(@method, Matrix.empty(0, 6)).should == false
end
it "doesn't distinguish on subclasses" do
- MatrixSub.ins.send(@method, Matrix.I(2)).should be_true
+ MatrixSub.ins.send(@method, Matrix.I(2)).should == true
end
end
diff --git a/spec/ruby/library/matrix/shared/identity.rb b/spec/ruby/library/matrix/shared/identity.rb
index 20b35ae8e3..df957b5a75 100644
--- a/spec/ruby/library/matrix/shared/identity.rb
+++ b/spec/ruby/library/matrix/shared/identity.rb
@@ -1,9 +1,9 @@
-require File.expand_path('../../fixtures/classes', __FILE__)
+require_relative '../fixtures/classes'
require 'matrix'
describe :matrix_identity, shared: true do
it "returns a Matrix" do
- Matrix.send(@method, 2).should be_kind_of(Matrix)
+ Matrix.send(@method, 2).should.is_a?(Matrix)
end
it "returns a n x n identity matrix" do
@@ -13,7 +13,7 @@ describe :matrix_identity, shared: true do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.send(@method, 2).should be_an_instance_of(MatrixSub)
+ MatrixSub.send(@method, 2).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/shared/imaginary.rb b/spec/ruby/library/matrix/shared/imaginary.rb
index 61a65a62ec..16615213a2 100644
--- a/spec/ruby/library/matrix/shared/imaginary.rb
+++ b/spec/ruby/library/matrix/shared/imaginary.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../fixtures/classes', __FILE__)
+require_relative '../fixtures/classes'
require 'matrix'
describe :matrix_imaginary, shared: true do
@@ -14,7 +14,7 @@ describe :matrix_imaginary, shared: true do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.send(@method).should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.send(@method).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/shared/inverse.rb b/spec/ruby/library/matrix/shared/inverse.rb
index c6996df4a3..ac463cf680 100644
--- a/spec/ruby/library/matrix/shared/inverse.rb
+++ b/spec/ruby/library/matrix/shared/inverse.rb
@@ -1,10 +1,10 @@
-require File.expand_path('../../fixtures/classes', __FILE__)
+require_relative '../fixtures/classes'
require 'matrix'
describe :inverse, shared: true do
it "returns a Matrix" do
- Matrix[ [1,2], [2,1] ].send(@method).should be_an_instance_of(Matrix)
+ Matrix[ [1,2], [2,1] ].send(@method).should.instance_of?(Matrix)
end
it "returns the inverse of the Matrix" do
@@ -25,14 +25,14 @@ describe :inverse, shared: true do
end
it "raises a ErrDimensionMismatch if the Matrix is not square" do
- lambda{
+ ->{
Matrix[ [1,2,3], [1,2,3] ].send(@method)
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.send(@method).should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.send(@method).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/shared/rectangular.rb b/spec/ruby/library/matrix/shared/rectangular.rb
index 4206311586..0229e614c6 100644
--- a/spec/ruby/library/matrix/shared/rectangular.rb
+++ b/spec/ruby/library/matrix/shared/rectangular.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../fixtures/classes', __FILE__)
+require_relative '../fixtures/classes'
require 'matrix'
describe :matrix_rectangular, shared: true do
@@ -12,7 +12,7 @@ describe :matrix_rectangular, shared: true do
describe "for a subclass of Matrix" do
it "returns instances of that subclass" do
- MatrixSub.ins.send(@method).each{|m| m.should be_an_instance_of(MatrixSub) }
+ MatrixSub.ins.send(@method).each{|m| m.should.instance_of?(MatrixSub) }
end
end
end
diff --git a/spec/ruby/library/matrix/shared/trace.rb b/spec/ruby/library/matrix/shared/trace.rb
index 2a42839f5d..c4a5491b22 100644
--- a/spec/ruby/library/matrix/shared/trace.rb
+++ b/spec/ruby/library/matrix/shared/trace.rb
@@ -6,7 +6,7 @@ describe :trace, shared: true do
end
it "returns the sum of diagonal elements in a rectangular Matrix" do
- lambda{ Matrix[[1,2,3], [4,5,6]].trace}.should raise_error(Matrix::ErrDimensionMismatch)
+ ->{ Matrix[[1,2,3], [4,5,6]].trace}.should.raise(Matrix::ErrDimensionMismatch)
end
end
diff --git a/spec/ruby/library/matrix/shared/transpose.rb b/spec/ruby/library/matrix/shared/transpose.rb
index dba6c71041..a0b495359b 100644
--- a/spec/ruby/library/matrix/shared/transpose.rb
+++ b/spec/ruby/library/matrix/shared/transpose.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../fixtures/classes', __FILE__)
+require_relative '../fixtures/classes'
require 'matrix'
describe :matrix_transpose, shared: true do
@@ -13,7 +13,7 @@ describe :matrix_transpose, shared: true do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.ins.send(@method).should be_an_instance_of(MatrixSub)
+ MatrixSub.ins.send(@method).should.instance_of?(MatrixSub)
end
end
end
diff --git a/spec/ruby/library/matrix/singular_spec.rb b/spec/ruby/library/matrix/singular_spec.rb
index 83914befbe..00b93af495 100644
--- a/spec/ruby/library/matrix/singular_spec.rb
+++ b/spec/ruby/library/matrix/singular_spec.rb
@@ -1,31 +1,31 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#singular?" do
it "returns true for singular matrices" do
m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
- m.singular?.should be_true
+ m.singular?.should == true
m = Matrix[ [1,2,9], [3,4,9], [1,2,9] ]
- m.singular?.should be_true
+ m.singular?.should == true
end
it "returns false if the Matrix is regular" do
- Matrix[ [0,1], [1,0] ].singular?.should be_false
+ Matrix[ [0,1], [1,0] ].singular?.should == false
end
it "returns false for an empty 0x0 matrix" do
- Matrix.empty(0,0).singular?.should be_false
+ Matrix.empty(0,0).singular?.should == false
end
it "raises an error for rectangular matrices" do
- lambda {
+ -> {
Matrix[[1], [2], [3]].singular?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
- lambda {
+ -> {
Matrix.empty(3,0).singular?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
diff --git a/spec/ruby/library/matrix/square_spec.rb b/spec/ruby/library/matrix/square_spec.rb
index a117916a4c..b8cf4acf44 100644
--- a/spec/ruby/library/matrix/square_spec.rb
+++ b/spec/ruby/library/matrix/square_spec.rb
@@ -1,28 +1,28 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#square?" do
it "returns true when the Matrix is square" do
- Matrix[ [1,2], [2,4] ].square?.should be_true
- Matrix[ [100,3,5], [9.5, 4.9, 8], [2,0,77] ].square?.should be_true
+ Matrix[ [1,2], [2,4] ].square?.should == true
+ Matrix[ [100,3,5], [9.5, 4.9, 8], [2,0,77] ].square?.should == true
end
it "returns true when the Matrix has only one element" do
- Matrix[ [9] ].square?.should be_true
+ Matrix[ [9] ].square?.should == true
end
it "returns false when the Matrix is rectangular" do
- Matrix[ [1, 2] ].square?.should be_false
+ Matrix[ [1, 2] ].square?.should == false
end
it "returns false when the Matrix is rectangular" do
- Matrix[ [1], [2] ].square?.should be_false
+ Matrix[ [1], [2] ].square?.should == false
end
it "returns handles empty matrices" do
- Matrix[].square?.should be_true
- Matrix[[]].square?.should be_false
- Matrix.columns([[]]).square?.should be_false
+ Matrix[].square?.should == true
+ Matrix[[]].square?.should == false
+ Matrix.columns([[]]).square?.should == false
end
end
diff --git a/spec/ruby/library/matrix/symmetric_spec.rb b/spec/ruby/library/matrix/symmetric_spec.rb
index 53f962c0e2..4b86c19503 100644
--- a/spec/ruby/library/matrix/symmetric_spec.rb
+++ b/spec/ruby/library/matrix/symmetric_spec.rb
@@ -1,17 +1,17 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix.symmetric?" do
it "returns true for a symmetric Matrix" do
- Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, 3), 5, 6]].symmetric?.should be_true
+ Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, 3), 5, 6]].symmetric?.should == true
end
it "returns true for a 0x0 empty matrix" do
- Matrix.empty.symmetric?.should be_true
+ Matrix.empty.symmetric?.should == true
end
- it "returns false for an assymetric Matrix" do
- Matrix[[1, 2],[-2, 1]].symmetric?.should be_false
+ it "returns false for an asymmetric Matrix" do
+ Matrix[[1, 2],[-2, 1]].symmetric?.should == false
end
it "raises an error for rectangular matrices" do
@@ -20,10 +20,10 @@ describe "Matrix.symmetric?" do
Matrix[[0, 0]],
Matrix.empty(0, 2),
Matrix.empty(2, 0),
- ].each do |rectangual_matrix|
- lambda {
- rectangual_matrix.symmetric?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.symmetric?
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/t_spec.rb b/spec/ruby/library/matrix/t_spec.rb
index 1c57c25de3..6f1a5178e0 100644
--- a/spec/ruby/library/matrix/t_spec.rb
+++ b/spec/ruby/library/matrix/t_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/transpose', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/transpose'
describe "Matrix#transpose" do
- it_behaves_like(:matrix_transpose, :t)
+ it_behaves_like :matrix_transpose, :t
end
diff --git a/spec/ruby/library/matrix/to_a_spec.rb b/spec/ruby/library/matrix/to_a_spec.rb
index 70db580312..b5d55c5d67 100644
--- a/spec/ruby/library/matrix/to_a_spec.rb
+++ b/spec/ruby/library/matrix/to_a_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#to_a" do
diff --git a/spec/ruby/library/matrix/to_s_spec.rb b/spec/ruby/library/matrix/to_s_spec.rb
index eb175d486b..f529fe3bcd 100644
--- a/spec/ruby/library/matrix/to_s_spec.rb
+++ b/spec/ruby/library/matrix/to_s_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix#to_s" do
diff --git a/spec/ruby/library/matrix/tr_spec.rb b/spec/ruby/library/matrix/tr_spec.rb
index 4b07a70203..e17bd790d7 100644
--- a/spec/ruby/library/matrix/tr_spec.rb
+++ b/spec/ruby/library/matrix/tr_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/trace', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/trace'
require 'matrix'
describe "Matrix#tr" do
- it_behaves_like(:trace, :tr)
+ it_behaves_like :trace, :tr
end
diff --git a/spec/ruby/library/matrix/trace_spec.rb b/spec/ruby/library/matrix/trace_spec.rb
index 08adb256c0..290e7cb1f7 100644
--- a/spec/ruby/library/matrix/trace_spec.rb
+++ b/spec/ruby/library/matrix/trace_spec.rb
@@ -1,7 +1,7 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/trace', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/trace'
require 'matrix'
describe "Matrix#trace" do
- it_behaves_like(:trace, :trace)
+ it_behaves_like :trace, :trace
end
diff --git a/spec/ruby/library/matrix/transpose_spec.rb b/spec/ruby/library/matrix/transpose_spec.rb
index 2a30a80efc..79600dd439 100644
--- a/spec/ruby/library/matrix/transpose_spec.rb
+++ b/spec/ruby/library/matrix/transpose_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/transpose', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/transpose'
describe "Matrix#transpose" do
- it_behaves_like(:matrix_transpose, :transpose)
+ it_behaves_like :matrix_transpose, :transpose
end
diff --git a/spec/ruby/library/matrix/unit_spec.rb b/spec/ruby/library/matrix/unit_spec.rb
index 058d719043..6a41d729c7 100644
--- a/spec/ruby/library/matrix/unit_spec.rb
+++ b/spec/ruby/library/matrix/unit_spec.rb
@@ -1,6 +1,6 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../shared/identity', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'shared/identity'
describe "Matrix.unit" do
- it_behaves_like(:matrix_identity, :unit)
+ it_behaves_like :matrix_identity, :unit
end
diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb
index e322a5a3ce..4490e8f8d4 100644
--- a/spec/ruby/library/matrix/unitary_spec.rb
+++ b/spec/ruby/library/matrix/unitary_spec.rb
@@ -1,16 +1,20 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
+
require 'matrix'
describe "Matrix.unitary?" do
it "returns false for non unitary matrices" do
- Matrix[[0, 1], [1, 2]].unitary?.should == false
- Matrix[[0, Complex(0, 2)], [Complex(0, 2), 0]].unitary?.should == false
- Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].unitary?.should == false
- Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].unitary?.should == false
+ Matrix[[0, 1], [1, 2]].should_not.unitary?
+ Matrix[[0, Complex(0, 2)], [Complex(0, 2), 0]].should_not.unitary?
+ Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].should_not.unitary?
end
it "returns true for unitary matrices" do
- Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].unitary?.should == true
+ Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].should.unitary?
+ end
+
+ it "returns true for unitary matrices with a Complex and a negative #imag" do
+ Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].should.unitary?
end
it "raises an error for rectangular matrices" do
@@ -19,10 +23,10 @@ describe "Matrix.unitary?" do
Matrix[[0, 0]],
Matrix.empty(0, 2),
Matrix.empty(2, 0),
- ].each do |rectangual_matrix|
- lambda {
- rectangual_matrix.unitary?
- }.should raise_error(Matrix::ErrDimensionMismatch)
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.unitary?
+ }.should.raise(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/upper_triangular_spec.rb b/spec/ruby/library/matrix/upper_triangular_spec.rb
index be88150b85..0e2bf611e2 100644
--- a/spec/ruby/library/matrix/upper_triangular_spec.rb
+++ b/spec/ruby/library/matrix/upper_triangular_spec.rb
@@ -1,24 +1,24 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'matrix'
describe "Matrix.upper_triangular?" do
it "returns true for an upper triangular Matrix" do
- Matrix[[1, 2, 3], [0, 2, 3], [0, 0, 3]].upper_triangular?.should be_true
- Matrix.diagonal([1, 2, 3]).upper_triangular?.should be_true
- Matrix[[1, 2], [0, 2], [0, 0], [0, 0]].upper_triangular?.should be_true
- Matrix[[1, 2, 3, 4], [0, 2, 3, 4]].upper_triangular?.should be_true
+ Matrix[[1, 2, 3], [0, 2, 3], [0, 0, 3]].upper_triangular?.should == true
+ Matrix.diagonal([1, 2, 3]).upper_triangular?.should == true
+ Matrix[[1, 2], [0, 2], [0, 0], [0, 0]].upper_triangular?.should == true
+ Matrix[[1, 2, 3, 4], [0, 2, 3, 4]].upper_triangular?.should == true
end
it "returns false for a non upper triangular square Matrix" do
- Matrix[[0, 0], [1, 0]].upper_triangular?.should be_false
- Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].upper_triangular?.should be_false
- Matrix[[0, 0], [0, 0], [0, 0], [0, 1]].upper_triangular?.should be_false
- Matrix[[0, 0, 0, 0], [1, 0, 0, 0]].upper_triangular?.should be_false
+ Matrix[[0, 0], [1, 0]].upper_triangular?.should == false
+ Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].upper_triangular?.should == false
+ Matrix[[0, 0], [0, 0], [0, 0], [0, 1]].upper_triangular?.should == false
+ Matrix[[0, 0, 0, 0], [1, 0, 0, 0]].upper_triangular?.should == false
end
it "returns true for an empty matrix" do
- Matrix.empty(3,0).upper_triangular?.should be_true
- Matrix.empty(0,3).upper_triangular?.should be_true
- Matrix.empty(0,0).upper_triangular?.should be_true
+ Matrix.empty(3,0).upper_triangular?.should == true
+ Matrix.empty(0,3).upper_triangular?.should == true
+ Matrix.empty(0,0).upper_triangular?.should == true
end
end
diff --git a/spec/ruby/library/matrix/vector/cross_product_spec.rb b/spec/ruby/library/matrix/vector/cross_product_spec.rb
index f26cf585da..96a462c067 100644
--- a/spec/ruby/library/matrix/vector/cross_product_spec.rb
+++ b/spec/ruby/library/matrix/vector/cross_product_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Vector#cross_product" do
@@ -7,8 +7,8 @@ describe "Vector#cross_product" do
end
it "raises an error unless both vectors have dimension 3" do
- lambda {
+ -> {
Vector[1, 2, 3].cross_product(Vector[0, -4])
- }.should raise_error(Vector::ErrDimensionMismatch)
+ }.should.raise(Vector::ErrDimensionMismatch)
end
end
diff --git a/spec/ruby/library/matrix/vector/each2_spec.rb b/spec/ruby/library/matrix/vector/each2_spec.rb
index e9d89e21c4..86e7ed75aa 100644
--- a/spec/ruby/library/matrix/vector/each2_spec.rb
+++ b/spec/ruby/library/matrix/vector/each2_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Vector.each2" do
@@ -8,8 +8,8 @@ describe "Vector.each2" do
end
it "requires one argument" do
- lambda { @v.each2(@v2, @v2){} }.should raise_error(ArgumentError)
- lambda { @v.each2(){} }.should raise_error(ArgumentError)
+ -> { @v.each2(@v2, @v2){} }.should.raise(ArgumentError)
+ -> { @v.each2(){} }.should.raise(ArgumentError)
end
describe "given one argument" do
@@ -20,8 +20,8 @@ describe "Vector.each2" do
end
it "raises a DimensionMismatch error if the Vector size is different" do
- lambda { @v.each2(Vector[1,2]){} }.should raise_error(Vector::ErrDimensionMismatch)
- lambda { @v.each2(Vector[1,2,3,4]){} }.should raise_error(Vector::ErrDimensionMismatch)
+ -> { @v.each2(Vector[1,2]){} }.should.raise(Vector::ErrDimensionMismatch)
+ -> { @v.each2(Vector[1,2,3,4]){} }.should.raise(Vector::ErrDimensionMismatch)
end
it "yields arguments in sequence" do
@@ -37,12 +37,12 @@ describe "Vector.each2" do
end
it "returns self when given a block" do
- @v.each2(@v2){}.should equal(@v)
+ @v.each2(@v2){}.should.equal?(@v)
end
it "returns an enumerator if no block given" do
enum = @v.each2(@v2)
- enum.should be_an_instance_of(Enumerator)
+ enum.should.instance_of?(Enumerator)
enum.to_a.should == [[1, 4], [2, 5], [3, 6]]
end
end
diff --git a/spec/ruby/library/matrix/vector/eql_spec.rb b/spec/ruby/library/matrix/vector/eql_spec.rb
index 6cc69bbf7d..6e2cd47b8e 100644
--- a/spec/ruby/library/matrix/vector/eql_spec.rb
+++ b/spec/ruby/library/matrix/vector/eql_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Vector#eql?" do
@@ -7,10 +7,10 @@ describe "Vector#eql?" do
end
it "returns true for self" do
- @vector.eql?(@vector).should be_true
+ @vector.eql?(@vector).should == true
end
it "returns false when there are a pair corresponding elements which are not equal in the sense of Kernel#eql?" do
- @vector.eql?(Vector[1, 2, 3, 4, 5.0]).should be_false
+ @vector.eql?(Vector[1, 2, 3, 4, 5.0]).should == false
end
end
diff --git a/spec/ruby/library/matrix/vector/inner_product_spec.rb b/spec/ruby/library/matrix/vector/inner_product_spec.rb
index a953598b51..79dee10833 100644
--- a/spec/ruby/library/matrix/vector/inner_product_spec.rb
+++ b/spec/ruby/library/matrix/vector/inner_product_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Vector#inner_product" do
@@ -11,9 +11,9 @@ describe "Vector#inner_product" do
end
it "raises an error for mismatched vectors" do
- lambda {
+ -> {
Vector[1, 2, 3].inner_product(Vector[0, -4])
- }.should raise_error(Vector::ErrDimensionMismatch)
+ }.should.raise(Vector::ErrDimensionMismatch)
end
it "uses the conjugate of its argument" do
diff --git a/spec/ruby/library/matrix/vector/normalize_spec.rb b/spec/ruby/library/matrix/vector/normalize_spec.rb
index 14aac1f5e3..bb1f046786 100644
--- a/spec/ruby/library/matrix/vector/normalize_spec.rb
+++ b/spec/ruby/library/matrix/vector/normalize_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../../spec_helper', __FILE__)
+require_relative '../../../spec_helper'
require 'matrix'
describe "Vector#normalize" do
@@ -8,11 +8,11 @@ describe "Vector#normalize" do
end
it "raises an error for zero vectors" do
- lambda {
+ -> {
Vector[].normalize
- }.should raise_error(Vector::ZeroVectorError)
- lambda {
+ }.should.raise(Vector::ZeroVectorError)
+ -> {
Vector[0, 0, 0].normalize
- }.should raise_error(Vector::ZeroVectorError)
+ }.should.raise(Vector::ZeroVectorError)
end
end
diff --git a/spec/ruby/library/matrix/zero_spec.rb b/spec/ruby/library/matrix/zero_spec.rb
index f83d29e837..406bcad6ed 100644
--- a/spec/ruby/library/matrix/zero_spec.rb
+++ b/spec/ruby/library/matrix/zero_spec.rb
@@ -1,10 +1,10 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
require 'matrix'
describe "Matrix.zero" do
it "returns an object of type Matrix" do
- Matrix.zero(3).should be_kind_of(Matrix)
+ Matrix.zero(3).should.is_a?(Matrix)
end
it "creates a n x n matrix" do
@@ -30,23 +30,23 @@ describe "Matrix.zero" do
describe "for a subclass of Matrix" do
it "returns an instance of that subclass" do
- MatrixSub.zero(3).should be_an_instance_of(MatrixSub)
+ MatrixSub.zero(3).should.instance_of?(MatrixSub)
end
end
end
describe "Matrix.zero?" do
it "returns true for empty matrices" do
- Matrix.empty.zero?.should == true
- Matrix.empty(3,0).zero?.should == true
- Matrix.empty(0,3).zero?.should == true
+ Matrix.empty.should.zero?
+ Matrix.empty(3,0).should.zero?
+ Matrix.empty(0,3).should.zero?
end
it "returns true for matrices with zero entries" do
- Matrix.zero(2,3).zero?.should == true
+ Matrix.zero(2,3).should.zero?
end
it "returns false for matrices with non zero entries" do
- Matrix[[1]].zero?.should == false
+ Matrix[[1]].should_not.zero?
end
end