fedora-migrator /vendor/gems/facets-2.4.5/test/core/kernel/test_as.rb

Language Ruby Lines 51
MD5 Hash 1779b1246df2027b0b35309207c68a93 Estimated Cost $944 (why?)
Repository https://bitbucket.org/mediashelf/fedora-migrator View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'facets/kernel/as.rb'
require 'test/unit'

class TestKernelSuper < Test::Unit::TestCase

  class X ; def x ; 1 ; end ; end
  class Y < X ; def x ; 2 ; end ; end
  class Z < Y ; def x ; super_as(X) ; end ; end

  def test_super_as
    z = Z.new
    assert_equal( 1, z.x )
  end

  class X2 ; def x ; 1 ; end ; end
  class Y2 < X2 ; def x ; 2 ; end ; end
  class Z2 < Y2 ; def x ; 3 ; end ; end

  def test_super_method
    x = X2.new
    z = Z2.new
    s0 = x.method( :x )
    s1 = z.super_method( X2, :x )
    assert_equal( s0.call, s1.call )
  end

  class A
    def x; "A.x"; end
    def y; "A.y"; end
  end
  class B < A
    def x; "B.x" end
    def y; "B.y" end
  end
  class C < B
    def x; "C.x"; end
    def y; as(B).x ; end
  end

  def test_as
    c = C.new
    assert_equal("B.x", c.y)
    assert_equal("C.x", c.x)
  end

  def test_send_as
    assert_equal( String, "A".send_as(Object, :class) )
  end

end
Back to Top