Sha256: 35d53893251941982fdb7fc794a1449eee112a7c38eba1414d4ad607f078864f

Contents?: true

Size: 573 Bytes

Versions: 15

Compression:

Stored size: 573 Bytes

Contents

require 'RubyExt/require'
require 'spec'

module RubyExt
	describe 'Array' do
		class Respond
			def test; 2 end
		end

		it "sort_by_weight" do
			a = [:a, :b, :c]
			w = [3, 2, 1]
			a.sort_by_weight(w).should == [:c, :b, :a]
			a.should == [:a, :b, :c]
			a.sort_by_weight! w
			a.should == [:c, :b, :a]
		end		
		
		it "sort_by_weight (from error)" do
			a = ["Attributes", "Micelaneous", "Containers", "Tools"]
			w = [0, 0, -1, -2]
			a.sort_by_weight! w
			a.should == ["Tools", "Containers", "Attributes", "Micelaneous"]
			w.should == [-2, -1, 0, 0]
		end
	end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
ruby-ext-0.2.16 old/spec/array_spec.rb
ruby-ext-0.2.15 old/spec/array_spec.rb
ruby-ext-0.2.13 old/spec/array_spec.rb
ruby-ext-0.2.12 old/spec/array_spec.rb
ruby-ext-0.2.11 old/spec/array_spec.rb
ruby-ext-0.2.10 old/spec/array_spec.rb
ruby-ext-0.2.9 old/spec/array_spec.rb
ruby-ext-0.2.8 old/spec/array_spec.rb
ruby-ext-0.2.7 old/spec/array_spec.rb
ruby-ext-0.2.6 old/spec/array_spec.rb
ruby-ext-0.2.5 old/spec/array_spec.rb
ruby-ext-0.2.4 old/spec/array_spec.rb
ruby-ext-0.2.3 old/spec/array_spec.rb
RubyExt-0.1.1 spec/array_spec.rb
RubyExt-0.1.2 spec/array_spec.rb