aboutsummaryrefslogtreecommitdiff
path: root/tests/alias.test
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-04-13 10:37:31 +1000
committerSteve Bennett <steveb@workware.net.au>2011-06-01 12:05:19 +1000
commita2694699f8d3d14465cbd9310678ab723f4bc79f (patch)
treeca178158c7026183715cf6643c5d2de02ab73553 /tests/alias.test
parent229239b9443c366f90ca251ede04bfa04ae16cc2 (diff)
downloadjimtcl-a2694699f8d3d14465cbd9310678ab723f4bc79f.zip
jimtcl-a2694699f8d3d14465cbd9310678ab723f4bc79f.tar.gz
jimtcl-a2694699f8d3d14465cbd9310678ab723f4bc79f.tar.bz2
Add [upcall] command
Allows previous command definitions to be invoked when otherwise hidden via [local] Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/alias.test')
-rw-r--r--tests/alias.test43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/alias.test b/tests/alias.test
index bcafe04..abbc2a0 100644
--- a/tests/alias.test
+++ b/tests/alias.test
@@ -192,4 +192,47 @@ test local-2.3 "local proc over existing proc" {
lappend x [a 5]
} {6 4 6}
+test upcall-1.1 "upcall pushed proc" {
+ proc a {b} {incr b}
+ local proc a {b} {
+ incr b 10
+ # invoke the original defn via upcall
+ return [upcall a $b]
+ }
+ # Should call the new defn which will call the original defn
+ a 3
+} 14
+
+test upcall-1.2 "upcall in proc" {
+ proc a {b} {incr b}
+ proc t {c} {
+ local proc a {b} {
+ incr b 10
+ return [upcall a $b]
+ }
+ a $c
+ }
+ unset -nocomplain x
+ lappend x [t 5]
+ lappend x [a 5]
+ set x
+} {16 6}
+
+test upcall-1.3 "double upcall" {
+ proc a {} {return 1}
+ local proc a {} {list 2 {*}[upcall a]}
+ local proc a {} {list 3 {*}[upcall a]}
+ a
+} {3 2 1}
+
+test upcall-1.4 "upcall errors" {
+ proc a {} {return 1}
+ list [catch {upcall a} msg] $msg
+} {1 {no previous proc: "a"}}
+
+test upcall-1.4 "upcall errors" {
+ proc a {} {upcall a}
+ list [catch a msg] $msg
+} {1 {no previous proc: "a"}}
+
testreport