about summary refs log tree commit diff stats
path: root/028assert.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-13 14:15:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-13 14:15:09 -0700
commit469524d6defc0c94c11b7aec9f9a724f01e58407 (patch)
tree04a5668dea46a0ff03479835129f889394e305a7 /028assert.cc
parentd5d908dda655c791329563522faad42d7e4ee618 (diff)
downloadmu-469524d6defc0c94c11b7aec9f9a724f01e58407.tar.gz
1767
Diffstat (limited to '028assert.cc')
-rw-r--r--028assert.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/028assert.cc b/028assert.cc
new file mode 100644
index 00000000..f864d43e
--- /dev/null
+++ b/028assert.cc
@@ -0,0 +1,21 @@
+:(scenario assert)
+% Hide_warnings = true;  // '%' lines insert arbitrary C code into tests before calling 'run' with the lines below. Must be immediately after :(scenario) line.
+recipe main [
+  assert 0:literal, [this is an assert in mu]
+]
++warn: this is an assert in mu
+
+:(before "End Primitive Recipe Declarations")
+ASSERT,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["assert"] = ASSERT;
+:(before "End Primitive Recipe Implementations")
+case ASSERT: {
+  assert(SIZE(ingredients) == 2);
+  assert(scalar(ingredients.at(0)));
+  if (!ingredients.at(0).at(0)) {
+    assert(is_literal(current_instruction().ingredients.at(1)));
+    raise << current_instruction().ingredients.at(1).name << '\n' << die();
+  }
+  break;
+}