package: add package names as an alias for package list
[jimtcl.git] / tests / errors.tcl
blob0992c596e2e25bb4880e03f8fe70b05e3af5c7b9
1 # Package which can generate a variety of errors at known locations
3 proc error_generator {type} {
4 switch $type {
5 badcmd {
6 bogus command called
8 badvar {
9 set bogus
11 error {
12 error bogus
14 interpbadvar {
15 set x "some $bogus text"
17 interpbadcmd {
18 set x "some $bogus text"
20 package {
21 package require dummy
23 source {
24 source dummy.tcl
26 badpackage {
27 package require bogus
29 returncode {
30 return -code error failure
32 badproc {
33 error_badproc
35 default {
36 puts "Unknown type=$type"
40 # line 40: Some empty lines above so that line numbers don't change
41 proc error_caller {type {method call}} {
42 switch $method {
43 call {
44 error_generator $type
46 uplevel {
47 uplevel 1 [list error_generator $type]
49 eval {
50 eval [list error_generator $type]
52 evalstr {
53 eval error_generator $type
55 default {
56 puts "Unknown method=$method"
61 proc error_badproc {} {
62 return [list missing bracket here