aboutsummaryrefslogtreecommitdiff
path: root/core/errors.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-22 13:59:08 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-22 13:59:08 -0700
commitdfd39f0b14794b360fd6c961c65ab45d229e00b1 (patch)
tree51f0c30ef3a32c969c63321da8164436a3ba8b31 /core/errors.nom
parent01d5f810ed7fd6e9b261b1fe793f8666970b2068 (diff)
Shifting further towards having inline tests. Also added a helper
function for directly extracting source lines from a Source or AST.
Diffstat (limited to 'core/errors.nom')
-rw-r--r--core/errors.nom14
1 files changed, 13 insertions, 1 deletions
diff --git a/core/errors.nom b/core/errors.nom
index 2744208..53b06a2 100644
--- a/core/errors.nom
+++ b/core/errors.nom
@@ -27,6 +27,18 @@ compile [assume %condition or barf %message] to (..)
error(\(%message as lua expr), 0)
end
+test:
+ try (barf) and if it succeeds: barf "try failed."
+ %worked = (no)
+ try (barf) and if it barfs: %worked = (yes)
+ assume %worked or barf "try/catch failed"
+ %x = 1
+ try:
+ %x = 2
+ do (barf) then always: %x = 3
+ ..and if it barfs: do nothing
+
+ assume (%x == 3) or barf "do/then always failed"
# Try/except
compile [..]
@@ -75,4 +87,4 @@ parse [try %action and if it barfs %msg %fallback] as (..)
try %action and if it succeeds (do nothing) or if it barfs %msg %fallback
parse [try %action and if it succeeds %success] as (..)
- try %action and if it succeeds %success or if it barfs (do nothing) \ No newline at end of file
+ try %action and if it succeeds %success or if it barfs (do nothing)