Sha256: 7cb1c2b42d779935f73cdb63b7a5474d62d0991a58021f806351de211a1adb14

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/mega/class_inherit.rb
#
# Extracted Fri Oct 28 14:20:18 EDT 2005
# Unit Tools Reap Test Extractor
#

require 'mega/class_inherit.rb'


  require 'test/unit'

  class TC01 < Test::Unit::TestCase
    module M
      class_inherit do
        def x ; 4 ; end
      end
    end
    module N ; include M ; end
    module O ; include N ; end
    module P
      include M
      include O
    end

    def test_01_001
      assert_equal( 4, M.x )
    end
    def test_01_002
      assert_equal( 4, N.x )
    end
    def test_01_003
      assert_equal( 4, O.x )
    end
    def test_01_003
      assert_equal( 4, P.x )
    end
  end

  class TC02 < Test::Unit::TestCase
    module M
      class_inherit do
        def x ; 4 ; end
      end
    end
    module N ; include M ; end
    module O ; include N ; end
    module P
      include O
      class_inherit do
        def x ; super + 6 ; end
      end
    end
    class C ; include M ; end
    class D < C ; end
    class F
      include M
      def self.x ; super + 4 ; end
    end
    class G
      include O
      def self.x ; super + 5 ; end
    end

    def test_01_001
      assert_equal( 10, P.x )
    end
    def test_01_002
      assert_equal( 4, C.x )
    end
    def test_01_003
      assert_equal( 4, D.x )
    end
    def test_01_004
      assert_equal( 8, F.x )
    end
    def test_01_005
      assert_equal( 9, G.x )
    end
  end

  class TC03 < Test::Unit::TestCase
    module Q
      class_inherit do
        def x
          @x ||= []
          if ancestors[1]
            ancestors[1].x + @x
          else
            @x
          end
        end
        def x! ; @x ||= [] ; end
      end
    end
    class R
      include Q
    end

    def test_03_001
      Q.x! << 1
      assert_equal( [1], Q.x )
    end
    def test_03_002
      R.x! << 2
      assert_equal( [1,2], R.x )
    end
    def test_03_003
      assert_equal( [1], Q.x )
    end
  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-0.9.0 test/lib/mega/test_class_inherit.rb