~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to test/ruby/test_alias.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'test/unit'
 
2
 
 
3
class TestAlias < Test::Unit::TestCase
 
4
  class Alias0
 
5
    def foo; "foo" end
 
6
  end
 
7
  class Alias1<Alias0
 
8
    alias bar foo
 
9
    def foo; "foo+" + super end
 
10
  end
 
11
  class Alias2<Alias1
 
12
    alias baz foo
 
13
    undef foo
 
14
  end
 
15
  class Alias3<Alias2
 
16
    def foo
 
17
      defined? super
 
18
    end
 
19
    def bar
 
20
      defined? super
 
21
    end
 
22
    def quux
 
23
      defined? super
 
24
    end
 
25
  end
 
26
 
 
27
  def test_alias
 
28
    x = Alias2.new
 
29
    assert_equal("foo", x.bar)
 
30
    assert_equal("foo+foo", x.baz)
 
31
 
 
32
    # test_check for cache
 
33
    assert_equal("foo+foo", x.baz)
 
34
 
 
35
    x = Alias3.new
 
36
    assert(!x.foo)
 
37
    assert(x.bar)
 
38
    assert(!x.quux)
 
39
  end
 
40
end