Sha256: 633d11455840fadafea252b8a220b00f13e00b40ffe5f1b8720b49355c472ffe

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |
#   |_|\___||___/\__|
#
# for facets/module/include.rb

require 'facets/module/include.rb'
require 'test/unit'

class TestInclude < Test::Unit::TestCase

  def test_ancestor
    assert( self.class.ancestor?(::Test::Unit::TestCase) )
  end

end

class TestIncludeAs < Test::Unit::TestCase

  module MockModule
    def x; "X"; end
    def y; @y; end
  end

  class MockObject
    include_as :mod => MockModule

    def initialize
      @y = "Y"
    end
  end

  def test_01
    m = MockObject.new
    assert_equal( "X", m.mod.x )
  end

  def test_02
    m = MockObject.new
    assert_equal( "Y", m.mod.y )
  end

end

class TestOnInclude < Test::Unit::TestCase

  module M
    def self.check ; @@check ; end
    on_included %{
      @@check = 1
    }
  end

  module Q
    def self.check ; @@check ; end
    on_included %{
      @@check = 1
    }
    on_included %{
      @@check = 2
    }
  end

  class C
    include M
    include Q
  end

  def test_included
    assert_equal(1, M.check)
    assert_equal(2, Q.check)
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-2.0.5 test/unit/module/test_include.rb
facets-2.0.3 test/unit/module/test_include.rb
facets-2.0.4 test/unit/module/test_include.rb
facets-2.1.2 test/unit/module/test_include.rb
facets-2.1.0 test/unit/module/test_include.rb
facets-2.1.1 test/unit/module/test_include.rb
facets-2.1.3 test/unit/module/test_include.rb