Sha256: fc551ad2b1d8a737e2e1a698e6e483c5582fc5b18c98f56de4bc1f256ddee622

Contents?: true

Size: 796 Bytes

Versions: 10

Compression:

Stored size: 796 Bytes

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |
#   |_|\___||___/\__|
#

require 'facets/module/traits.rb'

require 'test/unit'

class TestModuleTraits < Test::Unit::TestCase

  module A
    def x; "x"; end
    def z; "zA"; end
  end

  module B
    def y; "y"; end
    def z; "zB"; end
  end

  Q = A + B
  R = A - B
  Z = A * { :x => :y }

  def test_add
    assert(Q)
    Q.extend Q
    assert_equal(  "x", Q.x )
    assert_equal(  "y", Q.y )
    assert_equal( "zB", Q.z )
  end

  def test_minus
    assert(R)
    R.extend R
    assert_equal( "x", R.x )
    assert_raises(NoMethodError){ R.z }
  end

  def test_rename
    assert(Z)
    Z.extend Z
    assert_raise(NoMethodError){ Z.x }
    assert_equal(  "x", Z.y )
    assert_equal( "zA", Z.z )
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.0.3 test/unit/module/test_traits.rb
facets-2.0.5 test/unit/module/test_traits.rb
facets-2.1.0 test/unit/module/test_traits.rb
facets-2.0.4 test/unit/module/test_traits.rb
facets-2.1.1 test/unit/module/test_traits.rb
facets-2.1.2 test/unit/module/test_traits.rb
facets-2.1.3 test/unit/module/test_traits.rb
facets-2.2.0 test/unit/module/test_traits.rb
facets-2.2.1 test/unit/module/test_traits.rb
facets-2.3.0 test/core/module/test_traits.rb