diff options
author | Benoit Daloze <[email protected]> | 2019-07-27 12:40:09 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2019-07-27 12:40:09 +0200 |
commit | 5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch) | |
tree | 05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/library/matrix | |
parent | a06301b103371b0b7da8eaca26ba744961769f99 (diff) |
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/library/matrix')
34 files changed, 93 insertions, 93 deletions
diff --git a/spec/ruby/library/matrix/antisymmetric_spec.rb b/spec/ruby/library/matrix/antisymmetric_spec.rb index 534fab60ea..3eb0f8b726 100644 --- a/spec/ruby/library/matrix/antisymmetric_spec.rb +++ b/spec/ruby/library/matrix/antisymmetric_spec.rb @@ -28,7 +28,7 @@ ruby_version_is "2.6" do Matrix.empty(0, 2), Matrix.empty(2, 0), ].each do |rectangular_matrix| - lambda { + -> { rectangular_matrix.antisymmetric? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/build_spec.rb b/spec/ruby/library/matrix/build_spec.rb index 6819b9b617..6d8017a3df 100644 --- a/spec/ruby/library/matrix/build_spec.rb +++ b/spec/ruby/library/matrix/build_spec.rb @@ -29,14 +29,14 @@ describe "Matrix.build" do 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_error(TypeError) + -> { Matrix.build(nil, nil){1} }.should raise_error(TypeError) + -> { Matrix.build(1..2){1} }.should raise_error(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_error(ArgumentError) + -> { Matrix.build(+1,-1){1} }.should raise_error(ArgumentError) end it "returns empty Matrix if one argument is zero" do diff --git a/spec/ruby/library/matrix/column_spec.rb b/spec/ruby/library/matrix/column_spec.rb index 46cd57f2b3..1f3c80964a 100644 --- a/spec/ruby/library/matrix/column_spec.rb +++ b/spec/ruby/library/matrix/column_spec.rb @@ -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_error + -> { @m.column(-4){ raise } }.should_not raise_error end end diff --git a/spec/ruby/library/matrix/constructor_spec.rb b/spec/ruby/library/matrix/constructor_spec.rb index 2479923fb5..70d77babbb 100644 --- a/spec/ruby/library/matrix/constructor_spec.rb +++ b/spec/ruby/library/matrix/constructor_spec.rb @@ -5,10 +5,10 @@ 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_error(TypeError) + -> { Matrix[nil] }.should raise_error(TypeError) + -> { Matrix[1..2] }.should raise_error(TypeError) + -> { Matrix[[1, 2], 3] }.should raise_error(TypeError) end it "creates an empty Matrix with no arguments" do @@ -18,9 +18,9 @@ describe "Matrix.[]" do end it "raises for non-rectangular matrices" do - lambda{ Matrix[ [0], [0,1] ] }.should \ + ->{ Matrix[ [0], [0,1] ] }.should \ raise_error(Matrix::ErrDimensionMismatch) - lambda{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should \ + ->{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should \ raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/diagonal_spec.rb b/spec/ruby/library/matrix/diagonal_spec.rb index f066a21c47..ef9738e73e 100644 --- a/spec/ruby/library/matrix/diagonal_spec.rb +++ b/spec/ruby/library/matrix/diagonal_spec.rb @@ -64,7 +64,7 @@ describe "Matrix.diagonal?" do Matrix.empty(0, 2), Matrix.empty(2, 0), ].each do |rectangular_matrix| - lambda { + -> { rectangular_matrix.diagonal? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/divide_spec.rb b/spec/ruby/library/matrix/divide_spec.rb index 205bc5d892..2e3bb85bf6 100644 --- a/spec/ruby/library/matrix/divide_spec.rb +++ b/spec/ruby/library/matrix/divide_spec.rb @@ -30,7 +30,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_error(Matrix::ErrDimensionMismatch) end it "returns an instance of Matrix" do @@ -46,9 +46,9 @@ 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_error(TypeError) + -> { @a / "a" }.should raise_error(TypeError) + -> { @a / [ [1, 2] ] }.should raise_error(TypeError) + -> { @a / Object.new }.should raise_error(TypeError) end end diff --git a/spec/ruby/library/matrix/each_spec.rb b/spec/ruby/library/matrix/each_spec.rb index 214aae1a3a..f3b0f01867 100644 --- a/spec/ruby/library/matrix/each_spec.rb +++ b/spec/ruby/library/matrix/each_spec.rb @@ -31,13 +31,13 @@ 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 { + -> { @m.each(nil){} }.should raise_error(ArgumentError) - lambda { + -> { @m.each(:left){} }.should raise_error(ArgumentError) end diff --git a/spec/ruby/library/matrix/each_with_index_spec.rb b/spec/ruby/library/matrix/each_with_index_spec.rb index 36a1309292..a005b88621 100644 --- a/spec/ruby/library/matrix/each_with_index_spec.rb +++ b/spec/ruby/library/matrix/each_with_index_spec.rb @@ -38,13 +38,13 @@ 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 { + -> { @m.each_with_index(nil){} }.should raise_error(ArgumentError) - lambda { + -> { @m.each_with_index(:left){} }.should raise_error(ArgumentError) end diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb index f8964070d9..8438f63133 100644 --- a/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb +++ b/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb @@ -3,16 +3,16 @@ 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 { + -> { Matrix::EigenvalueDecomposition.new(42) }.should raise_error(TypeError) end it "raises an error if matrix is not square" do - lambda { + -> { Matrix::EigenvalueDecomposition.new(Matrix[[1, 2]]) }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/empty_spec.rb b/spec/ruby/library/matrix/empty_spec.rb index ce23d926d6..5f294711db 100644 --- a/spec/ruby/library/matrix/empty_spec.rb +++ b/spec/ruby/library/matrix/empty_spec.rb @@ -15,7 +15,7 @@ describe "Matrix#empty?" do end it "doesn't accept any parameter" do - lambda{ + ->{ Matrix[ [1, 2] ].empty?(42) }.should raise_error(ArgumentError) end @@ -38,23 +38,23 @@ describe "Matrix.empty" do end it "does not accept more than two parameters" do - lambda{ + ->{ Matrix.empty(1, 2, 3) }.should raise_error(ArgumentError) end it "raises an error if both dimensions are > 0" do - lambda{ + ->{ Matrix.empty(1, 2) }.should raise_error(ArgumentError) end it "raises an error if any dimension is < 0" do - lambda{ + ->{ Matrix.empty(-2, 0) }.should raise_error(ArgumentError) - lambda{ + ->{ Matrix.empty(0, -2) }.should raise_error(ArgumentError) end diff --git a/spec/ruby/library/matrix/exponent_spec.rb b/spec/ruby/library/matrix/exponent_spec.rb index c496d9d3cc..447c962967 100644 --- a/spec/ruby/library/matrix/exponent_spec.rb +++ b/spec/ruby/library/matrix/exponent_spec.rb @@ -17,8 +17,8 @@ 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_error(Matrix::ErrDimensionMismatch) + -> { m ** 0 }.should raise_error(Matrix::ErrDimensionMismatch) end describe "that is <= 0" do @@ -30,8 +30,8 @@ describe "Matrix#**" do it "raises a ErrDimensionMismatch 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_error(Matrix::ErrNotRegular) + -> { m ** 0 }.should raise_error(Matrix::ErrNotRegular) end end end diff --git a/spec/ruby/library/matrix/find_index_spec.rb b/spec/ruby/library/matrix/find_index_spec.rb index 27672e526b..c2bfa6d61a 100644 --- a/spec/ruby/library/matrix/find_index_spec.rb +++ b/spec/ruby/library/matrix/find_index_spec.rb @@ -130,16 +130,16 @@ 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 { + -> { @m.find_index(1, nil){} }.should raise_error(ArgumentError) - lambda { + -> { @m.find_index(1, :left){} }.should raise_error(ArgumentError) - lambda { + -> { @m.find_index(:diagonal, 1){} }.should raise_error(ArgumentError) end diff --git a/spec/ruby/library/matrix/hermitian_spec.rb b/spec/ruby/library/matrix/hermitian_spec.rb index dda5280d64..177ca64d83 100644 --- a/spec/ruby/library/matrix/hermitian_spec.rb +++ b/spec/ruby/library/matrix/hermitian_spec.rb @@ -21,7 +21,7 @@ describe "Matrix.hermitian?" do Matrix.empty(0, 2), Matrix.empty(2, 0), ].each do |rectangular_matrix| - lambda { + -> { rectangular_matrix.hermitian? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb b/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb index ca2ddf18c6..9d733066c1 100644 --- a/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb @@ -13,7 +13,7 @@ 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) end diff --git a/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb b/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb index 00dc47ddb9..36afb349e6 100644 --- a/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb @@ -3,10 +3,10 @@ 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 { + -> { Matrix::LUPDecomposition.new(42) }.should raise_error(TypeError) end diff --git a/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb b/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb index 43d49de9c7..66242627e9 100644 --- a/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb @@ -6,7 +6,7 @@ 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) end @@ -31,7 +31,7 @@ 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) end @@ -44,7 +44,7 @@ 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) end diff --git a/spec/ruby/library/matrix/minus_spec.rb b/spec/ruby/library/matrix/minus_spec.rb index 25191893a6..95cf4a6072 100644 --- a/spec/ruby/library/matrix/minus_spec.rb +++ b/spec/ruby/library/matrix/minus_spec.rb @@ -17,20 +17,20 @@ 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_error(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_error(Matrix::ErrOperationNotDefined) + -> { @a - 1.2 }.should raise_error(Matrix::ErrOperationNotDefined) + -> { @a - bignum_value }.should raise_error(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_error(TypeError) + -> { @a - "a" }.should raise_error(TypeError) + -> { @a - [ [1, 2] ] }.should raise_error(TypeError) + -> { @a - Object.new }.should raise_error(TypeError) end describe "for a subclass of Matrix" do diff --git a/spec/ruby/library/matrix/multiply_spec.rb b/spec/ruby/library/matrix/multiply_spec.rb index 9b401a4dad..585f268931 100644 --- a/spec/ruby/library/matrix/multiply_spec.rb +++ b/spec/ruby/library/matrix/multiply_spec.rb @@ -32,7 +32,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_error(Matrix::ErrDimensionMismatch) end it "returns a zero matrix if (nx0) * (0xn)" do @@ -52,10 +52,10 @@ 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_error(TypeError) + -> { @a * "a" }.should raise_error(TypeError) + -> { @a * [ [1, 2] ] }.should raise_error(TypeError) + -> { @a * Object.new }.should raise_error(TypeError) end describe "for a subclass of Matrix" do diff --git a/spec/ruby/library/matrix/normal_spec.rb b/spec/ruby/library/matrix/normal_spec.rb index 437a3c82c9..ebd73aaf40 100644 --- a/spec/ruby/library/matrix/normal_spec.rb +++ b/spec/ruby/library/matrix/normal_spec.rb @@ -18,7 +18,7 @@ describe "Matrix.normal?" do Matrix.empty(0, 2), Matrix.empty(2, 0), ].each do |rectangular_matrix| - lambda { + -> { rectangular_matrix.normal? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/orthogonal_spec.rb b/spec/ruby/library/matrix/orthogonal_spec.rb index 81df1d15ee..07b098a58d 100644 --- a/spec/ruby/library/matrix/orthogonal_spec.rb +++ b/spec/ruby/library/matrix/orthogonal_spec.rb @@ -18,7 +18,7 @@ describe "Matrix.orthogonal?" do Matrix.empty(0, 2), Matrix.empty(2, 0), ].each do |rectangular_matrix| - lambda { + -> { rectangular_matrix.orthogonal? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/permutation_spec.rb b/spec/ruby/library/matrix/permutation_spec.rb index f6666588de..825a9d982c 100644 --- a/spec/ruby/library/matrix/permutation_spec.rb +++ b/spec/ruby/library/matrix/permutation_spec.rb @@ -24,7 +24,7 @@ describe "Matrix#permutation?" do Matrix.empty(0, 2), Matrix.empty(2, 0), ].each do |rectangular_matrix| - lambda { + -> { rectangular_matrix.permutation? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/plus_spec.rb b/spec/ruby/library/matrix/plus_spec.rb index cad04f80a3..2706bad060 100644 --- a/spec/ruby/library/matrix/plus_spec.rb +++ b/spec/ruby/library/matrix/plus_spec.rb @@ -17,20 +17,20 @@ 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_error(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_error(ExceptionForMatrix::ErrOperationNotDefined) + -> { @a + 1.2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined) + -> { @a + bignum_value }.should raise_error(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_error(TypeError) + -> { @a + "a" }.should raise_error(TypeError) + -> { @a + [ [1, 2] ] }.should raise_error(TypeError) + -> { @a + Object.new }.should raise_error(TypeError) end describe "for a subclass of Matrix" do diff --git a/spec/ruby/library/matrix/regular_spec.rb b/spec/ruby/library/matrix/regular_spec.rb index 5dd4484ce4..3699d0ef8b 100644 --- a/spec/ruby/library/matrix/regular_spec.rb +++ b/spec/ruby/library/matrix/regular_spec.rb @@ -20,11 +20,11 @@ describe "Matrix#regular?" do end it "raises an error for rectangular matrices" do - lambda { + -> { Matrix[[1], [2], [3]].regular? }.should raise_error(Matrix::ErrDimensionMismatch) - lambda { + -> { Matrix.empty(3,0).regular? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/row_spec.rb b/spec/ruby/library/matrix/row_spec.rb index 1cf2c6ae2c..00b1f02a8e 100644 --- a/spec/ruby/library/matrix/row_spec.rb +++ b/spec/ruby/library/matrix/row_spec.rb @@ -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_error + -> { @m.row(-4){ raise } }.should_not raise_error end end diff --git a/spec/ruby/library/matrix/shared/determinant.rb b/spec/ruby/library/matrix/shared/determinant.rb index 47a58c62a6..9e0528c24b 100644 --- a/spec/ruby/library/matrix/shared/determinant.rb +++ b/spec/ruby/library/matrix/shared/determinant.rb @@ -27,11 +27,11 @@ 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) - lambda { + -> { Matrix.empty(3,0).send(@method) }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/shared/inverse.rb b/spec/ruby/library/matrix/shared/inverse.rb index e1e5ae5758..c8a6b90da5 100644 --- a/spec/ruby/library/matrix/shared/inverse.rb +++ b/spec/ruby/library/matrix/shared/inverse.rb @@ -25,7 +25,7 @@ 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) end diff --git a/spec/ruby/library/matrix/shared/trace.rb b/spec/ruby/library/matrix/shared/trace.rb index 2a42839f5d..57b89863f8 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_error(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/singular_spec.rb b/spec/ruby/library/matrix/singular_spec.rb index 362f4cbb35..7bba36a54a 100644 --- a/spec/ruby/library/matrix/singular_spec.rb +++ b/spec/ruby/library/matrix/singular_spec.rb @@ -19,11 +19,11 @@ describe "Matrix#singular?" do end it "raises an error for rectangular matrices" do - lambda { + -> { Matrix[[1], [2], [3]].singular? }.should raise_error(Matrix::ErrDimensionMismatch) - lambda { + -> { Matrix.empty(3,0).singular? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/symmetric_spec.rb b/spec/ruby/library/matrix/symmetric_spec.rb index 7b7bce29fc..6f2a99276a 100644 --- a/spec/ruby/library/matrix/symmetric_spec.rb +++ b/spec/ruby/library/matrix/symmetric_spec.rb @@ -21,7 +21,7 @@ describe "Matrix.symmetric?" do Matrix.empty(0, 2), Matrix.empty(2, 0), ].each do |rectangular_matrix| - lambda { + -> { rectangular_matrix.symmetric? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index 921ea3dda3..9c2a106ea5 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -20,7 +20,7 @@ describe "Matrix.unitary?" do Matrix.empty(0, 2), Matrix.empty(2, 0), ].each do |rectangular_matrix| - lambda { + -> { rectangular_matrix.unitary? }.should raise_error(Matrix::ErrDimensionMismatch) end diff --git a/spec/ruby/library/matrix/vector/cross_product_spec.rb b/spec/ruby/library/matrix/vector/cross_product_spec.rb index 5194782edd..c2698ade4c 100644 --- a/spec/ruby/library/matrix/vector/cross_product_spec.rb +++ b/spec/ruby/library/matrix/vector/cross_product_spec.rb @@ -7,7 +7,7 @@ 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) end diff --git a/spec/ruby/library/matrix/vector/each2_spec.rb b/spec/ruby/library/matrix/vector/each2_spec.rb index 844b903336..10d2fc404d 100644 --- a/spec/ruby/library/matrix/vector/each2_spec.rb +++ b/spec/ruby/library/matrix/vector/each2_spec.rb @@ -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_error(ArgumentError) + -> { @v.each2(){} }.should raise_error(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_error(Vector::ErrDimensionMismatch) + -> { @v.each2(Vector[1,2,3,4]){} }.should raise_error(Vector::ErrDimensionMismatch) end it "yields arguments in sequence" do diff --git a/spec/ruby/library/matrix/vector/inner_product_spec.rb b/spec/ruby/library/matrix/vector/inner_product_spec.rb index 584226c450..1cf8771e04 100644 --- a/spec/ruby/library/matrix/vector/inner_product_spec.rb +++ b/spec/ruby/library/matrix/vector/inner_product_spec.rb @@ -11,7 +11,7 @@ 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) end diff --git a/spec/ruby/library/matrix/vector/normalize_spec.rb b/spec/ruby/library/matrix/vector/normalize_spec.rb index 4ff9597c82..527c9260de 100644 --- a/spec/ruby/library/matrix/vector/normalize_spec.rb +++ b/spec/ruby/library/matrix/vector/normalize_spec.rb @@ -8,10 +8,10 @@ describe "Vector#normalize" do end it "raises an error for zero vectors" do - lambda { + -> { Vector[].normalize }.should raise_error(Vector::ZeroVectorError) - lambda { + -> { Vector[0, 0, 0].normalize }.should raise_error(Vector::ZeroVectorError) end |