about summary refs log tree commit diff stats
path: root/cpp/026assert.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-28 14:25:07 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-28 14:25:07 -0700
commit5f6cf0629d36a15845b34cbb0fa45df931f92e0b (patch)
treefcce854babc0e3b374742877d58063c7c59fc574 /cpp/026assert.cc
parentc6bea7a010be89fbb464a513180d60200716053e (diff)
downloadmu-5f6cf0629d36a15845b34cbb0fa45df931f92e0b.tar.gz
1213
Diffstat (limited to 'cpp/026assert.cc')
-rw-r--r--cpp/026assert.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/cpp/026assert.cc b/cpp/026assert.cc
new file mode 100644
index 00000000..785db1f5
--- /dev/null
+++ b/cpp/026assert.cc
@@ -0,0 +1,20 @@
+:(scenario assert)
+% Hide_warnings = true;
+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_number["assert"] = ASSERT;
+:(before "End Primitive Recipe Implementations")
+case ASSERT: {
+  trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].name;
+  vector<int> arg0 = read_memory(current_instruction().ingredients[0]);
+  assert(arg0.size() == 1);
+  if (arg0[0] == 0)
+    raise << current_instruction().ingredients[1].name << '\n';
+  break;
+}