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.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/spec/ruby/library/matrix/trace_spec.rb b/spec/ruby/library/matrix/trace_spec.rb
index ac6ce7927d..831278c838 100644
--- a/spec/ruby/library/matrix/trace_spec.rb
+++ b/spec/ruby/library/matrix/trace_spec.rb
@@ -1,10 +1,12 @@
require_relative '../../spec_helper'
+require 'matrix'
-ruby_version_is ""..."3.1" do
- require_relative 'shared/trace'
- 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
- describe "Matrix#trace" do
- it_behaves_like :trace, :trace
+ 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