spec/01_enum_spec.rb in nmatrix-0.0.9 vs spec/01_enum_spec.rb in nmatrix-0.1.0.rc1

- old
+ new

@@ -6,12 +6,12 @@ # NMatrix was originally inspired by and derived from NArray, by # Masahiro Tanaka: http://narray.rubyforge.org # # == Copyright Information # -# SciRuby is Copyright (c) 2010 - 2012, Ruby Science Foundation -# NMatrix is Copyright (c) 2012, Ruby Science Foundation +# SciRuby is Copyright (c) 2010 - 2014, Ruby Science Foundation +# NMatrix is Copyright (c) 2012 - 2014, John Woods and the Ruby Science Foundation # # Please see LICENSE.txt for additional copyright notices. # # == Contributing # @@ -35,10 +35,14 @@ before :each do @n = create_rectangular_matrix(stype) @m = @n[1..4,1..3] end + #after :each do + # GC.start + #end + if stype == :yale it "should iterate properly along each row of a slice" do vv = [] ii = [] jj = [] @@ -176,9 +180,19 @@ ii.should == [[0]*3, [1]*3, [2]*3, [3]*3].flatten vv.should == [7,8,9,12,13,0,0,0,0,0,17,18] end + if stype == :list or stype == :dense then + it "should correctly map to a matrix with a single element" do + nm = N.new([1], [2.0], stype: stype) + nm.map { |e| e**2 }.should eq N.new([1], [4.0], stype: stype) + end + it "should correctly map to a matrix with multiple elements" do + nm = N.new([2], [2.0, 2.0], stype: stype) + nm.map { |e| e**2 }.should eq N.new([2], [4.0, 4.0], stype: stype) + end + end end end -end \ No newline at end of file +end