Sha256: d9562b769e0788611685f3e519f4af4c8cbf37ab40fe4f3009276bf72369ff47

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |
#   |_|\___||___/\__|
#
# for facets/hash/op.rb

require 'facets/hash/op.rb'

require 'test/unit'

class TestHashOperate < Test::Unit::TestCase

  def test_op_and_hash
    a = { :a => 1, :b => 2 }
    b = { :a => 1 }
    r = { :a => 1 }
    assert_equal( r, a & b )
  end

  def test_op_and_hash_subarray
    a = { :a => [1], :b => [2] }
    b = { :a => [1] }
    r = { :a => [1] }
    assert_equal( r, a & b )
  end

  def test_op_and_array
    a = { :a => 1, :b => 2 }
    b = [ :a ]
    r = { :a => 1 }
    assert_equal( r, a & b )
  end

  def test_shift_update
    a = { :a => 1, :b => 2, :c => 3 }
    b = { :a => 0, :d => 4 }
    e = { :a => 0, :b => 2, :c => 3, :d => 4 }
    assert_equal( e, a << b )
  end

  def test_op_minus_array
    a = { :a => 1, :b => 2, :c => 3 }
    b = [ :a ]
    e = { :b => 2, :c => 3 }
    assert_equal( e, a - b )
  end

  def test_op_minus_hash
    a = { :a => 1, :b => 2, :c => 3 }
    b = { :a => 1, :d => 4 }
    e = { :b => 2, :c => 3 }
    assert_equal( e, a - b )
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
facets-2.0.4 test/unit/hash/test_op.rb
facets-2.0.5 test/unit/hash/test_op.rb
facets-2.1.0 test/unit/hash/test_op.rb
facets-2.1.1 test/unit/hash/test_op.rb
facets-2.1.2 test/unit/hash/test_op.rb
facets-2.1.3 test/unit/hash/test_op.rb