PageRenderTime 13ms CodeModel.GetById 4ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/ruby/director_protected_runme.rb

#
Ruby | 45 lines | 28 code | 9 blank | 8 comment | 8 complexity | 43e3ee8051b3571df0612bc5accf7166 MD5 | raw file
 1#!/usr/bin/env ruby
 2#
 3# Put description here
 4#
 5# 
 6# 
 7# 
 8#
 9
10require 'swig_assert'
11
12require 'director_protected'
13
14NoProtectedError = Kernel.const_defined?("NoMethodError") ? NoMethodError : NameError
15
16class FooBar < Director_protected::Bar
17  protected
18    def ping
19      "FooBar::ping();"
20    end
21end
22
23class Hello < FooBar
24  public
25    def pang
26      ping
27    end
28end
29
30b = Director_protected::Bar.new
31fb = FooBar.new
32
33p = 0
34begin 
35  b.ping
36  p = 1
37rescue NoProtectedError
38end
39
40h = Hello.new
41
42raise RuntimeError if p == 1
43raise RuntimeError if b.pong != "Bar::pong();Foo::pong();Bar::ping();"
44raise RuntimeError if fb.pong != "Bar::pong();Foo::pong();FooBar::ping();"
45raise RuntimeError if h.pang != "FooBar::ping();"