summaryrefslogtreecommitdiff
path: root/spec/ruby/library/matrix/trace_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/matrix/trace_spec.rb')
-rw-r--r--spec/ruby/library/matrix/trace_spec.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/spec/ruby/library/matrix/trace_spec.rb b/spec/ruby/library/matrix/trace_spec.rb
index 290e7cb1f7..831278c838 100644
--- a/spec/ruby/library/matrix/trace_spec.rb
+++ b/spec/ruby/library/matrix/trace_spec.rb
@@ -1,7 +1,12 @@
require_relative '../../spec_helper'
-require_relative 'shared/trace'
require 'matrix'
describe "Matrix#trace" do
- it_behaves_like :trace, :trace
+ it "returns the sum of diagonal elements in a square Matrix" do
+ Matrix[[7,6], [3,9]].trace.should == 16
+ end
+
+ it "returns the sum of diagonal elements in a rectangular Matrix" do
+ ->{ Matrix[[1,2,3], [4,5,6]].trace}.should.raise(Matrix::ErrDimensionMismatch)
+ end
end