Browse Source

Add test for error(…)

David Peter 2 years ago
parent
commit
1fd298a61b
1 changed files with 6 additions and 0 deletions
  1. 6 0
      examples/runtime_error/user_error.nbt

+ 6 - 0
examples/runtime_error/user_error.nbt

@@ -0,0 +1,6 @@
+fn foo(n: Scalar) -> Scalar =
+  if n > 0
+    then sqrt(n) + 1
+    else error("Argument of foo(n) can not be negative")
+
+foo(-3)