diff options
Diffstat (limited to 'spec/ruby/library/matrix/trace_spec.rb')
| -rw-r--r-- | spec/ruby/library/matrix/trace_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/ruby/library/matrix/trace_spec.rb b/spec/ruby/library/matrix/trace_spec.rb new file mode 100644 index 0000000000..831278c838 --- /dev/null +++ b/spec/ruby/library/matrix/trace_spec.rb @@ -0,0 +1,12 @@ +require_relative '../../spec_helper' +require 'matrix' + +describe "Matrix#trace" do + 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 |
