]> git.saurik.com Git - redis.git/blobdiff - tests/support/test.tcl
more pub/sub tests
[redis.git] / tests / support / test.tcl
index 988189bfa10887fbce8cbfe3fedf5290f1a75325..2c1fc164f270e7be976eb0fbd22e5da21fe6672e 100644 (file)
@@ -2,6 +2,13 @@ set ::passed 0
 set ::failed 0
 set ::testnum 0
 
+proc assert {condition} {
+    if {![uplevel 1 expr $condition]} {
+        puts "!! ERROR\nExpected '$value' to evaluate to true"
+        error "assertion"
+    }
+}
+
 proc assert_match {pattern value} {
     if {![string match $pattern $value]} {
         puts "!! ERROR\nExpected '$value' to match '$pattern'"
@@ -17,7 +24,7 @@ proc assert_equal {expected value} {
 }
 
 proc assert_error {pattern code} {
-    if {[catch $code error]} {
+    if {[catch {uplevel 1 $code} error]} {
         assert_match $pattern $error
     } else {
         puts "!! ERROR\nExpected an error but nothing was catched"