PageRenderTime 49ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/tcl/import/runme.tcl

#
TCL | 114 lines | 86 code | 23 blank | 5 comment | 8 complexity | 0e2e235d1876c1570505883f27743b28 MD5 | raw file
  1# file: runme.tcl
  2# Test various properties of classes defined in separate modules
  3
  4puts "Testing the %import directive"
  5catch { load ./base[info sharedlibextension] base}
  6catch { load ./foo[info sharedlibextension] foo}
  7catch { load ./bar[info sharedlibextension] bar}
  8catch { load ./spam[info sharedlibextension] spam}
  9
 10# Create some objects
 11
 12puts "Creating some objects"
 13
 14set a [Base]
 15set b [Foo]
 16set c [Bar]
 17set d [Spam]
 18
 19# Try calling some methods
 20puts "Testing some methods"
 21puts "Should see 'Base::A' ---> "
 22$a A
 23puts "Should see 'Base::B' ---> "
 24$a B
 25
 26puts  "Should see 'Foo::A' ---> "
 27$b A
 28puts  "Should see 'Foo::B' ---> "
 29$b B
 30
 31puts  "Should see 'Bar::A' ---> "
 32$c A
 33puts  "Should see 'Bar::B' ---> "
 34$c B
 35
 36puts  "Should see 'Spam::A' ---> "
 37$d A
 38puts  "Should see 'Spam::B' ---> "
 39$d B
 40
 41# Try some casts
 42
 43puts "\nTesting some casts\n"
 44
 45Base x -this [$a toBase]
 46puts "Should see 'Base::A' ---> "
 47x A
 48puts "Should see 'Base::B' ---> "
 49x B
 50rename x ""
 51
 52Base x -this [$b toBase]
 53puts "Should see 'Foo::A' ---> "
 54x A
 55puts  "Should see 'Base::B' ---> "
 56x B
 57rename x ""
 58
 59Base x -this [$c toBase]
 60puts  "Should see 'Bar::A' ---> "
 61x A
 62puts  "Should see 'Base::B' ---> "
 63x B
 64rename x ""
 65
 66Base x -this [$d toBase]
 67puts  "Should see 'Spam::A' ---> "
 68x A
 69puts  "Should see 'Base::B' ---> "
 70x B
 71rename x ""
 72
 73Bar x -this [$d toBar]
 74puts  "Should see 'Bar::B' ---> "
 75x B
 76rename x ""
 77
 78puts "\nTesting some dynamic casts\n"
 79Base x -this [$d toBase]
 80
 81puts  "Spam -> Base -> Foo : "
 82set y [Foo_fromBase [x cget -this]]
 83if {$y != "NULL"} {
 84      puts "bad swig"
 85} {
 86      puts "good swig"
 87}
 88
 89puts  "Spam -> Base -> Bar : "
 90set y [Bar_fromBase [x cget -this]]
 91if {$y != "NULL"} {
 92      puts "good swig"
 93} {
 94      puts "bad swig"
 95}
 96      
 97puts  "Spam -> Base -> Spam : "
 98set y [Spam_fromBase [x cget -this]]
 99if {$y != "NULL"} {
100      puts "good swig"
101} {
102      puts "bad swig"
103}
104
105puts  "Foo -> Spam : "
106set y [Spam_fromBase $b]
107if {$y != "NULL"} {
108      puts "bad swig"
109} {
110      puts "good swig"
111}
112
113
114