summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-02-18 21:22:09 -0800
committerOri Bernstein <ori@eigenstate.org>2018-02-18 22:47:24 -0800
commit745fee5b237ca93ba7c7d87030829edf177dc56d (patch)
tree6331055d5539f14b32b859b72e6b1c7936767227
parent9cb3a0f22ac95f75e87e944b95b6c5a13a4eb729 (diff)
downloadmc-745fee5b237ca93ba7c7d87030829edf177dc56d.tar.gz
Add utility functions for testing.
-rw-r--r--lib/testr/testr.myr14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/testr/testr.myr b/lib/testr/testr.myr
index d9443c7..bbb99fe 100644
--- a/lib/testr/testr.myr
+++ b/lib/testr/testr.myr
@@ -17,6 +17,8 @@ pkg testr =
const ok : (ctx : ctx# -> void)
const fail : (ctx : ctx#, msg : byte[:], args : ... -> void)
const check : (ctx : ctx#, cond : bool, msg : byte[:], args : ... -> void)
+ generic eq : (ctx : ctx#, a : @t, b : @t -> void) :: std.equatable @t
+ generic neq : (ctx : ctx#, a : @t, b : @t -> void) :: std.equatable @t
const softfail : (ctx : ctx#, msg : byte[:], args : ... -> void)
;;
@@ -56,6 +58,18 @@ const check = {ctx, cond, msg, args
;;
}
+generic eq = {ctx, a, b
+ if !std.eq(a, b)
+ fail(ctx, "{} != {}\n", a, b)
+ ;;
+}
+
+generic neq = {ctx, a, b
+ if std.eq(a, b)
+ fail(ctx, "{} != {}\n", a, b)
+ ;;
+}
+
const fail = {ctx, msg, args
var ap