PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/tcl/std_vector/runme.tcl

#
TCL | 40 lines | 26 code | 10 blank | 4 comment | 0 complexity | a5d000b07f404d198567e5795bd36006 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. # file: runme.tcl
  2. catch { load ./example[info sharedlibextension] example}
  3. # Exercise IntVector
  4. set iv [IntVector]
  5. $iv push 1
  6. $iv push 3
  7. $iv push 5
  8. puts "IntVector size: [$iv size] (should be 3)"
  9. puts "IntVector average: [average $iv] (should be 3.0)"
  10. puts "IntVector pop: [$iv pop] (should be 5)"
  11. puts "IntVector pop: [$iv pop] (should be 3)"
  12. puts "IntVector get 0: [$iv get 0] (should be 1)"
  13. puts ""
  14. # Exercise DoubleVector
  15. set dv [DoubleVector]
  16. $dv push 2
  17. $dv push 4
  18. $dv push 6
  19. puts "DoubleVector size: [$dv size] (should be 3)"
  20. puts "DoubleVector data: [$dv get 0] [$dv get 1] [$dv get 2] (should be 2.0 4.0 6.0)"
  21. halve_in_place $dv
  22. puts "DoubleVector halved: [$dv get 0] [$dv get 1] [$dv get 2] (should be 1.0 2.0 3.0)"
  23. puts ""
  24. # Complain if unknown is called
  25. rename unknown unknown_orig
  26. proc unknown {args} {
  27. puts "ERROR: unknown called with: $args"
  28. uplevel 1 unknown_orig $args
  29. }
  30. puts "average \"1 2 3\": [average [list 1 2 3]]"