diff options
Diffstat (limited to 'spec/ruby/library/matrix')
-rw-r--r-- | spec/ruby/library/matrix/antisymmetric_spec.rb | 53 | ||||
-rw-r--r-- | spec/ruby/library/matrix/exponent_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/library/matrix/multiply_spec.rb | 5 | ||||
-rw-r--r-- | spec/ruby/library/matrix/unitary_spec.rb | 7 |
4 files changed, 33 insertions, 34 deletions
diff --git a/spec/ruby/library/matrix/antisymmetric_spec.rb b/spec/ruby/library/matrix/antisymmetric_spec.rb index 3eb0f8b726..200df703cb 100644 --- a/spec/ruby/library/matrix/antisymmetric_spec.rb +++ b/spec/ruby/library/matrix/antisymmetric_spec.rb @@ -1,37 +1,36 @@ require_relative '../../spec_helper' + require 'matrix' -ruby_version_is "2.6" do - 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 be_true - end +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 be_true + end - it "returns true for a 0x0 empty matrix" do - Matrix.empty.antisymmetric?.should be_true - end + it "returns true for a 0x0 empty matrix" do + Matrix.empty.antisymmetric?.should be_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 be_false - 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 be_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_error(Matrix::ErrDimensionMismatch) - 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_error(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/exponent_spec.rb b/spec/ruby/library/matrix/exponent_spec.rb index a05826ab72..b76e18b4cd 100644 --- a/spec/ruby/library/matrix/exponent_spec.rb +++ b/spec/ruby/library/matrix/exponent_spec.rb @@ -34,7 +34,7 @@ describe "Matrix#**" do end end - ruby_version_is '3.0.2' do # https://bugs.ruby-lang.org/issues/17521 + ruby_version_is '3.1.0' do # https://bugs.ruby-lang.org/issues/17521 describe "that is 0" do it "returns the identity for square matrices" do m = Matrix[ [1, 1], [1, 1] ] diff --git a/spec/ruby/library/matrix/multiply_spec.rb b/spec/ruby/library/matrix/multiply_spec.rb index 585f268931..206868af92 100644 --- a/spec/ruby/library/matrix/multiply_spec.rb +++ b/spec/ruby/library/matrix/multiply_spec.rb @@ -1,4 +1,5 @@ require_relative '../../spec_helper' + require_relative 'fixtures/classes' require 'matrix' @@ -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 diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index af4b2bb442..c214ee9b2f 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -1,4 +1,5 @@ require_relative '../../spec_helper' + require 'matrix' describe "Matrix.unitary?" do @@ -12,10 +13,8 @@ describe "Matrix.unitary?" do Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].should.unitary? end - version_is((Matrix::const_defined?(:VERSION) ? Matrix::VERSION : "0.1.0"), "0.3.0") do - 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 "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 |