<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,22 +3,35 @@ require 'matrix'
 
 describe &quot;Matrix#column&quot; do
   before :all do
-    @m =  Matrix[[1,2],[1,2]]
+    @m =  Matrix[[1,2,3], [2,3,4]]
   end
 
   it &quot;returns a Vector when called without a block&quot; do
-    @m.column(1).should == Vector[2,2]
+    @m.column(1).should == Vector[2,3]
   end
 
   it &quot;yields each element in the column to the block&quot; do
-    @m.column(1) do |n|
-      n.should == 2
-    end
+    a = []
+    @m.column(1) {|n| a &lt;&lt; n }
+    a.should == [2,3]
   end
   
+  it &quot;counts backwards for negative argument&quot; do
+    @m.column(-1).should == Vector[3, 4]
+  end
+
   ruby_bug &quot;redmine:1532&quot;, &quot;1.8.7&quot; do
+    it &quot;returns self when called with a block&quot; do
+      @m.column(0) { |x| x }.should equal(@m)
+    end
+
     it &quot;returns nil when out of bounds&quot; do
-      @m.column(2).should == nil
+      @m.column(3).should == nil
+    end
+
+    it &quot;never yields when out of bounds&quot; do
+      lambda { @m.column(3){ raise } }.should_not raise_error
+      lambda { @m.column(-4){ raise } }.should_not raise_error
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>library/matrix/column_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,8 +19,6 @@ describe &quot;Matrix#column_vectors&quot; do
     @vectors.should == [Vector[1,3], Vector[2,4]]
   end
 
-  # See Ruby bug #1526 for discussion of inconsistency between
-  # #column_vectors and #row_vectors
   it &quot;returns an empty Array for empty matrices&quot; do
     Matrix[ [] ].column_vectors.should == []
   end</diff>
      <filename>library/matrix/column_vectors_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,6 +9,11 @@ describe &quot;Matrix.diagonal&quot; do
   it &quot;returns an object of type Matrix&quot; do
     @m.class.should == Matrix
   end
+
+  it &quot;returns a square Matrix of the right size&quot; do
+    @m.column_size.should == 5
+    @m.row_size.should == 5
+  end
   
   it &quot;sets the diagonal to the arguments&quot; do
     (0..4).each do |i|</diff>
      <filename>library/matrix/diagonal_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,11 +15,7 @@ describe &quot;Matrix#[]&quot; do
     end
   end
 
-  # FIXME: Update this guard when the bug is fixed.
-  ruby_bug &quot;#1518&quot;, &quot;1.9.1.129&quot; do
-    # A NoMethodError is raised when the _first_ index is out of bounds,
-    # (http://redmine.ruby-lang.org/issues/show/1518); otherwise nil is
-    # returned.
+  ruby_bug &quot;#1518&quot;, &quot;1.8.7&quot; do
     it &quot;returns nil for an invalid index pair&quot; do
       @m[8,1].should be_nil
       @m[1,8].should be_nil</diff>
      <filename>library/matrix/element_reference_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,5 +3,11 @@ require File.dirname(__FILE__) + '/shared/equal_value'
 require 'matrix'
 
 describe &quot;Matrix#eql?&quot; do
-  it_behaves_like(:equal, :eql)
-end
+  it_behaves_like(:equal, :eql?)
+
+  ruby_bug(&quot;[ruby-dev:36298]&quot;, &quot;1.8.7&quot;) do
+    it &quot;returns false if some elements are == but not eql?&quot; do
+      Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should be_false
+    end
+  end
+end
\ No newline at end of file</diff>
      <filename>library/matrix/eql_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,5 +3,9 @@ require File.dirname(__FILE__) + '/shared/equal_value'
 require 'matrix'
 
 describe &quot;Matrix#==&quot; do
-  it_behaves_like(:equal, :equal_value)
+  it_behaves_like(:equal, :==)
+
+  it &quot;returns true if some elements are == but not eql?&quot; do
+    Matrix[[1, 2],[3, 4]].should == Matrix[[1, 2],[3, 4.0]]
+  end
 end</diff>
      <filename>library/matrix/equal_value_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require 'matrix'
 
-# Note: Matrix just computes a bitwise OR of the element's .hash values, so
-# their position in the matrix isn't taken into account. This means that
-# matrices with the same elements in different positions will generate the
-# same .hash code...
 describe &quot;Matrix#hash&quot; do
   
   it &quot;returns a Fixnum&quot; do</diff>
      <filename>library/matrix/hash_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,4 +7,16 @@ describe &quot;Matrix#inspect&quot; do
     Matrix[ [1,2], [2,1] ].inspect.should == &quot;Matrix[[1, 2], [2, 1]]&quot;
   end
 
+  ruby_bug &quot;redmine:1532&quot;, &quot;1.8.7&quot; do
+    it &quot;returns 'Matrix.empty(...)' for empty matrices&quot; do
+      Matrix[ [], [], [] ].inspect.should == &quot;Matrix.empty(3, 0)&quot;
+      Matrix.columns([ [], [], [] ]).inspect.should == &quot;Matrix.empty(0, 3)&quot;
+    end
+  end
+
+  it &quot;calls inspect on its contents&quot; do
+    obj = mock(&quot;some_value&quot;)
+    obj.should_receive(:inspect).and_return(&quot;some_value&quot;)
+    Matrix[ [1, 2], [3, obj] ].inspect.should == &quot;Matrix[[1, 2], [3, some_value]]&quot;
+  end
 end</diff>
      <filename>library/matrix/inspect_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,8 +21,22 @@ describe &quot;Matrix#minor&quot; do
       end
 
       it &quot;returns nil for out-of-bounds start_row/col&quot; do
-        @matrix.minor(4,0,0,10).should == nil
-        @matrix.minor(0,10,3,9).should == nil
+        r = @matrix.row_size + 1
+        c = @matrix.column_size + 1
+        @matrix.minor(r,0,0,10).should == nil
+        @matrix.minor(0,10,c,9).should == nil
+        @matrix.minor(-r,0,0,10).should == nil
+        @matrix.minor(0,10,-c,9).should == nil
+      end
+
+      it &quot;returns nil for negative nrows or ncols&quot; do
+        @matrix.minor(0,1,0,-1).should == nil
+        @matrix.minor(0,-1,0,1).should == nil
+      end
+
+      it &quot;start counting backwards for start_row or start_col below zero&quot; do
+        @matrix.minor(0, 1, -1, 1).should == @matrix.minor(0, 1, 1, 1)
+        @matrix.minor(-1, 1, 0, 1).should == @matrix.minor(2, 1, 0, 1)
       end
     end
 
@@ -46,8 +60,22 @@ describe &quot;Matrix#minor&quot; do
     end
 
     ruby_bug &quot;redmine:1532&quot;, &quot;1.8.7&quot; do
-      it &quot;returns an empty Matrix if col_range or row_range don't select any elements&quot; do
-        @matrix.minor(3..6, 3..6).should == nil
+      it &quot;returns nil if col_range or row_range is out of range&quot; do
+        r = @matrix.row_size + 1
+        c = @matrix.column_size + 1
+        @matrix.minor(r..6, c..6).should == nil
+        @matrix.minor(0..1, c..6).should == nil
+        @matrix.minor(r..6, 0..1).should == nil
+        @matrix.minor(-r..6, -c..6).should == nil
+        @matrix.minor(0..1, -c..6).should == nil
+        @matrix.minor(-r..6, 0..1).should == nil
+      end
+
+      it &quot;start counting backwards for col_range or row_range below zero&quot; do
+        @matrix.minor(0..1, -2..-1).should == @matrix.minor(0..1, 0..1)
+        @matrix.minor(0..1, -2..1).should == @matrix.minor(0..1, 0..1)
+        @matrix.minor(-2..-1, 0..1).should == @matrix.minor(1..2, 0..1)
+        @matrix.minor(-2..2, 0..1).should == @matrix.minor(1..2, 0..1)
       end
     end
   end</diff>
      <filename>library/matrix/minor_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,9 +20,9 @@ describe &quot;Matrix#-&quot; do
   end
 
   it &quot;raises a ExceptionForMatrix::ErrOperationNotDefined if other is a Numeric Type&quot; 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)
+    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)
   end
 
   it &quot;raises an exception if other is not a Matrix&quot; do</diff>
      <filename>library/matrix/minus_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,9 +7,6 @@ describe &quot;Matrix#regular?&quot; do
   # from writing a complete specification here. 
   it &quot;needs to be reviewed for spec completeness&quot;
 
-  # On Ruby 1.9.1 the below tests cause hangs, presumably due to bug #1020.
-  # They pass in 1.8.7. When #1020 is fixed, we can determine whether it was
-  # the cause of this failure...
   ruby_bug &quot;#1020&quot;, &quot;1.9.1.129&quot; do
     it &quot;returns false unless rank(A) != n&quot; do
       m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]</diff>
      <filename>library/matrix/regular_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,8 +2,12 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 require 'matrix'
 
 describe &quot;Matrix#row_size&quot; do
-  it &quot;returns the number of elements in a row&quot; do
-    data =  [[1,2], [3, 4]]
-    Matrix[ *data ].row_size.should == 2
+  it &quot;returns the number rows&quot; do
+    Matrix[ [1,2], [3, 4], [5, 6] ].row_size.should == 3
   end
+
+  it &quot;returns the number rows even for some empty matrices&quot; do
+    Matrix[ [], [], [] ].row_size.should == 3
+  end
+
 end</diff>
      <filename>library/matrix/row_size_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,20 +3,36 @@ require 'matrix'
 
 describe &quot;Matrix#row&quot; do
   before :all do
-    @m = Matrix[ [1, 2], [1, 2] ]
+    @m = Matrix[ [1, 2], [2, 3], [3, 4] ]
   end
 
   it &quot;returns a Vector when called without a block&quot; do
     @m.row(0).should == Vector[1,2]
   end
 
+  it &quot;yields the elements of the row when called with a block&quot; do
+    a = []
+    @m.row(0) {|x| a &lt;&lt; x}
+    a.should == [1,2]
+  end
+
+  it &quot;counts backwards for negative argument&quot; do
+    @m.row(-1).should == Vector[3, 4]
+  end
+
   ruby_bug &quot;redmine:1532&quot;, &quot;1.8.7&quot; do
     it &quot;returns self when called with a block&quot; do
       @m.row(0) { |x| x }.should equal(@m)
     end
 
     it &quot;returns nil when out of bounds&quot; do
-      @m.row(2).should == nil
+      @m.row(3).should == nil
+      @m.row(-4).should == nil
+    end
+
+    it &quot;never yields when out of bounds&quot; do
+      lambda { @m.row(3){ raise } }.should_not raise_error
+      lambda { @m.row(-4){ raise } }.should_not raise_error
     end
   end
 end
\ No newline at end of file</diff>
      <filename>library/matrix/row_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 require 'matrix'
-require File.dirname(__FILE__) + '/../../../fixtures/matrix'
 
 describe :equal, :shared =&gt; true do
   before do
@@ -7,19 +6,16 @@ describe :equal, :shared =&gt; true do
   end
 
   it &quot;returns true for self&quot; do
-    @matrix.eql?(@matrix).should be_true
+    @matrix.send(@method, @matrix).should be_true
   end
 
-  ruby_bug(&quot;[ruby-dev:36298]&quot;, &quot;1.8.7&quot;) do
-    it &quot;returns true when the each corresponding elements are equal in the sense of Object#eql?&quot; do
-      @matrix.eql?(Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_true
-
-      num1, num2 = TrivialField.new, TrivialField.new
-      Matrix[[num1]].eql?(Matrix[[num2]]).should be_true
-    end
+  it &quot;returns true for equal matrices&quot; do
+    @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_true
+  end
 
-    it &quot;returns false when there are a pair corresponding elements which are not equal in the sense of Object#eql?&quot; do
-      @matrix.eql?(Matrix[ [1, 2, 3, 4, 5.0], [2, 3, 4, 5, 6] ]).should be_false
-    end
+  it &quot;returns false for different matrices&quot; do
+    @matrix.send(@method, Matrix[ [42, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_false
+    @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7] ]).should be_false
+    @matrix.send(@method, Matrix[ [1, 2, 3], [2, 3, 4] ]).should be_false
   end
 end</diff>
      <filename>library/matrix/shared/equal_value.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,6 @@ describe :trace, :shared =&gt; true do
     Matrix[[7,6], [3,9]].trace.should == 16
   end
 
-  # Crashes with NoMethodError: undefined method `[]' for nil:NilClass
   ruby_bug &quot;redmine:1532&quot;, &quot;1.8.7&quot; do
     it &quot;returns the sum of diagonal elements in a rectangular Matrix&quot; do
       lambda{ Matrix[[1,2,3], [4,5,6]].trace}.should raise_error(Matrix::ErrDimensionMismatch)</diff>
      <filename>library/matrix/shared/trace.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,4 +4,11 @@ describe :matrix_transpose, :shared =&gt; true do
   it &quot;returns a transposed matrix&quot; do
     Matrix[[1, 2], [3, 4], [5, 6]].send(@method).should == Matrix[[1, 3, 5], [2, 4, 6]]
   end
+
+  ruby_bug &quot;redmine:1532&quot;, &quot;1.8.7&quot; do
+    it &quot;can transpose empty matrices&quot; do
+      m = Matrix[[], [], []]
+      m.send(@method).send(@method).should == m
+    end
+  end
 end</diff>
      <filename>library/matrix/shared/transpose.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,12 +12,19 @@ describe &quot;Matrix#square?&quot; do
     Matrix[ [9] ].square?.should be_true
   end
 
-  it &quot;returns false when the Matrix is 0xn&quot; do
+  it &quot;returns false when the Matrix is rectangular&quot; do
     Matrix[ [1, 2] ].square?.should be_false
   end
 
-  it &quot;returns false when the Matrix is nx0&quot; do
+  it &quot;returns false when the Matrix is rectangular&quot; do
     Matrix[ [1], [2] ].square?.should be_false
   end
-  
+
+  ruby_bug &quot;redmine:1532&quot;, &quot;1.8.7&quot; do
+    it &quot;returns handles empty matrices&quot; do
+      Matrix[].square?.should be_true
+      Matrix[[]].square?.should be_false
+      Matrix.columns([[]]).square?.should be_false
+    end
+  end
 end  </diff>
      <filename>library/matrix/square_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,5 @@
 require File.dirname(__FILE__) + '/../../../spec_helper'
 require 'matrix'
-require File.dirname(__FILE__) + '/../../../fixtures/matrix'
 
 describe &quot;Vector#eql?&quot; do
   before do
@@ -12,13 +11,6 @@ describe &quot;Vector#eql?&quot; do
   end
 
   ruby_bug(&quot;[ruby-dev:36298]&quot;, &quot;1.8.7&quot;) do
-    it &quot;returns true when the each corresponding elements are equal in the sense of Object#eql?&quot; do
-      @vector.eql?(Vector[1, 2, 3, 4, 5]).should be_true
-
-      num1, num2 = TrivialField.new, TrivialField.new
-      Vector[num1].eql?(Vector[num2]).should be_true
-    end
-
     it &quot;returns false when there are a pair corresponding elements which are not equal in the sense of Object#eql?&quot; do
       @vector.eql?(Vector[1, 2, 3, 4, 5.0]).should be_false
     end</diff>
      <filename>library/matrix/vector/eql_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,29 +26,4 @@ describe &quot;Matrix.zero&quot; do
       end
     end
   end
-  
-  it &quot;returns an object of type Matrix&quot; do
-    Matrix.zero(3).class.should == Matrix
-  end
-  
-  it &quot;creates a square matrix with size given by the argument&quot; do
-    m3 = Matrix.zero(3)
-    m3.row_size.should == 3
-    m3.column_size.should == 3
-    
-    m8 = Matrix.zero(8)
-    m8.row_size.should == 8
-    m8.column_size.should == 8
-  end
-  
-  it &quot;initializes all cells to 0&quot; do
-    size = 10 # arbitrary value
-    m = Matrix.zero(size)
-    
-    (0...size).each do |i|
-      (0...size).each do |j|
-        m[i, j].should == 0
-      end
-    end
-  end
 end</diff>
      <filename>library/matrix/zero_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>fixtures/matrix.rb</filename>
    </removed>
    <removed>
      <filename>library/matrix/init_rows_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>e61f29ed945f181383efcf1b5b622918dad659b1</id>
    </parent>
  </parents>
  <author>
    <name>Marc-Andre Lafortune</name>
    <email>github@marc-andre.ca</email>
  </author>
  <url>http://github.com/rubyspec/rubyspec/commit/7b5aeca89b6eee6d2ad2b133171440c9b09ed719</url>
  <id>7b5aeca89b6eee6d2ad2b133171440c9b09ed719</id>
  <committed-date>2009-10-23T22:58:53-07:00</committed-date>
  <authored-date>2009-10-23T22:58:53-07:00</authored-date>
  <message>lib/matrix: additional specs for empty matrices, negative and out of bound indices
  fix of == and eql? specs
  other clean up</message>
  <tree>b25b4f50a5077fc51138993a4ab615b9e6f21667</tree>
  <committer>
    <name>Marc-Andre Lafortune</name>
    <email>github@marc-andre.ca</email>
  </committer>
</commit>
