]> git.saurik.com Git - redis.git/blobdiff - tests/support/test.tcl
Fix ZUNIONSTORE/ZINTERSTORE to never store a NaN score.
[redis.git] / tests / support / test.tcl
index 4caa6ca79731ef97d626d4cde8025b757b37c0f6..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"
@@ -26,6 +33,8 @@ proc assert_error {pattern code} {
 }
 
 proc assert_encoding {enc key} {
+    # swapped out value doesn't have encoding, so swap in first
+    r debug swapin $key
     assert_match "* encoding:$enc *" [r debug object $key]
 }