Upstream version 1.3.40
[profile/ivi/swig.git] / Examples / tcl / std_vector / runme.tcl
1 # file: runme.tcl
2
3 catch { load ./example[info sharedlibextension] example}
4
5 # Exercise IntVector
6
7 set iv [IntVector]
8 $iv push 1
9 $iv push 3
10 $iv push 5
11
12 puts "IntVector size:      [$iv size]   (should be 3)"
13 puts "IntVector average:   [average $iv] (should be 3.0)"
14 puts "IntVector pop:       [$iv pop]   (should be 5)"
15 puts "IntVector pop:       [$iv pop]   (should be 3)"
16 puts "IntVector get 0:     [$iv get 0]   (should be 1)"
17 puts ""
18
19 # Exercise DoubleVector
20
21 set dv [DoubleVector]
22 $dv push 2 
23 $dv push 4
24 $dv push 6
25  
26 puts "DoubleVector size:   [$dv size]           (should be 3)"
27 puts "DoubleVector data:   [$dv get 0] [$dv get 1] [$dv get 2] (should be 2.0 4.0 6.0)"
28 halve_in_place $dv
29 puts "DoubleVector halved: [$dv get 0] [$dv get 1] [$dv get 2] (should be 1.0 2.0 3.0)"
30 puts ""
31
32 # Complain if unknown is called
33 rename unknown unknown_orig
34 proc unknown {args} {
35   puts "ERROR: unknown called with: $args"
36   uplevel 1 unknown_orig $args
37 }
38
39 puts "average \"1 2 3\": [average [list 1 2 3]]"
40