Sha256: f76c05820bf799e19377cff1f8a6c1c87a364c641868bd92411d260f3fc47d6a

Contents?: true

Size: 914 Bytes

Versions: 4

Compression:

Stored size: 914 Bytes

Contents

covers 'facets/hash/select'

testcase Hash do

  unit :select! => "empty hash" do
    a = {}
    a.select!{false}.assert == nil
    a.assert == {}

    a = {}
    a.select!{true}.assert == nil
    a.assert == {}
  end

  unit :select! => "select none" do
    a = {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
    a.select!{false}.assert == {}
    a.assert == {}
  end

  unit :select! => "select one" do
    a = {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
    a.select! {|x,y| y == 'b'}.assert == {1 => 'b'}
    a.assert == {1 => 'b'}
  end

  unit :select! => "select some" do
    a = {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
    a.select! {|x,y| x % 2 == 0}.assert == {0 => 'a', 2 => 'c'}
    a.assert == {0 => 'a', 2 => 'c'}
  end

  unit :select! => "select all" do
    a = {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
    a.select!{true}.assert == nil
    a.assert == {0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'}
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facets-2.9.1 test/core/hash/test_select.rb
facets-2.9.0 test/core/hash/test_select.rb
facets-2.9.0.pre.2 test/core/hash/test_select.rb
facets-2.9.0.pre.1 test/core/hash/test_select.rb