diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/base64.nom | 2 | ||||
| -rw-r--r-- | lib/consolecolor.nom | 2 | ||||
| -rw-r--r-- | lib/file_hash.nom | 17 | ||||
| -rw-r--r-- | lib/object.nom | 14 | ||||
| -rw-r--r-- | lib/os.nom | 13 | ||||
| -rw-r--r-- | lib/things.nom | 23 |
6 files changed, 42 insertions, 29 deletions
diff --git a/lib/base64.nom b/lib/base64.nom index f0c40b2..54f785f 100644 --- a/lib/base64.nom +++ b/lib/base64.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.13.12.8 +#!/usr/bin/env nomsu -V6.14 # This file defines actions for encoding/decoding base 64, as specified in: https://tools.ietf.org/html/rfc4648 diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom index 6c5e176..db29b9f 100644 --- a/lib/consolecolor.nom +++ b/lib/consolecolor.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.13.12.8 +#!/usr/bin/env nomsu -V6.14 # This file defines actions for ANSI console color escape codes. diff --git a/lib/file_hash.nom b/lib/file_hash.nom index a708249..ec39e29 100644 --- a/lib/file_hash.nom +++ b/lib/file_hash.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.13.12.8 +#!/usr/bin/env nomsu -V6.14 # This file defines some actions for hashing files and looking up files by hash. @@ -10,11 +10,12 @@ use "lib/base64.nom" lua> "local \$use_sha1, \$hashlib = pcall(require, 'openssl.digest')" test: assume (hash "hello world") == (hash "hello world") - assume ((hash "hello world") != (hash "goodbye")) or barf (" - Hash collision: - (hash "hello world") = \(hash "hello world") - (hash "goodbye") = \(hash "goodbye") - ") + if ((hash "hello world") == (hash "goodbye")): + fail (" + Hash collision: + (hash "hello world") = \(hash "hello world") + (hash "goodbye") = \(hash "goodbye") + ") assume ( @@ -24,8 +25,8 @@ test: ") ) != "inf" - assume ((hash "\000") != (hash "\000\000\000\000\000")) or barf - "Incorrect hashing of null strings" + if ((hash "\000") == (hash "\000\000\000\000\000")): + fail "Incorrect hashing of null strings" if $use_sha1: assume ((hash "hello world") == "Kq5sNclPz7QV2+lfQIuc6R7oRu0=") diff --git a/lib/object.nom b/lib/object.nom index fa746b6..13a9ec5 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.13.12.8 +#!/usr/bin/env nomsu -V6.14 # This file contains the implementation of an Object-Oriented programming system. @@ -37,7 +37,9 @@ test: assume ($d.genus == "Canus") assume ($d.barks == 3) $d2 = (Dog {}) - assume ($d2.barks == 0) or barf "Default initializer failed" + unless ($d2.barks == 0): + fail "Default initializer failed" + with [$d = (Dog {.barks = 1})]: assume (($d, bark) == "Bark!") @@ -50,8 +52,12 @@ test: $corg = (Corgi {}) assume ($corg.barks == 0) with [$d = (Corgi {.barks = 1})]: - assume (($d, sploot) == "splooted") or barf "subclass method failed" - assume (($d, bark) == "Yip!") or barf "inheritance failed" + unless (($d, sploot) == "splooted"): + fail "subclass method failed" + + unless (($d, bark) == "Yip!"): + fail "inheritance failed" + assume (($d, woof) == "Yip!") with [$d = (Dog {.barks = 2})]: @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.13.12.8 +#!/usr/bin/env nomsu -V6.14 # This file defines some actions that interact with the operating system and filesystem. @@ -33,7 +33,9 @@ externally [ write to file $filename $text, to file $filename write $text write $text to file $filename ] all mean: - assume ($filename != "stdin") or barf "Cannot write to stdin" + unless ($filename != "stdin"): + fail "Cannot write to stdin" + lua> (" local file = io.open(\$filename, 'w') file:write(\$text) @@ -45,10 +47,9 @@ externally (source lines of $tree) means: $file = (read file $source.filename) return [ - : - for $ in ($file, line number at $source.start) to - $file, line number at $source.stop - ..: add ($file, line $) + : for $ in ($file, line number at $source.start) to + $file, line number at $source.stop + ..: add ($file, line $) ], joined with "\n" externally (spoof file $text) means ($Files.spoof $text) diff --git a/lib/things.nom b/lib/things.nom index 2820328..32942d9 100644 --- a/lib/things.nom +++ b/lib/things.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.13.12.8 +#!/usr/bin/env nomsu -V6.14 # A library for simple object oriented programming. @@ -30,7 +30,9 @@ test: assume ($d.genus == "Canus") assume ($d.barks == 3) $d2 = (a Dog) - assume ($d2.barks == 0) or barf "Default initializer failed" + unless ($d2.barks == 0): + fail "Default initializer failed" + with [$d = (a Dog with {.barks = 1})]: assume (($d, bark) == "Bark!") @@ -47,8 +49,12 @@ test: assume ($corg.barks == 0) assume "\$corg" == "Dogloaf {barks: 0}" with [$d = (a Corgi with {.barks = 1})]: - assume (($d, sploot) == "sploooot") or barf "subclass method failed" - assume (($d, bark) == "Yip!") or barf "inheritance failed" + unless (($d, sploot) == "sploooot"): + fail "subclass method failed" + + unless (($d, bark) == "Yip!"): + fail "inheritance failed" + assume (($d, woof) == "Yip!") with [$d = (a Dog with {.barks = 2})]: @@ -87,9 +93,8 @@ $METAMETHOD_MAP = { .size = "__len", .iterate = "__ipairs", ."iterate all" = "__pairs" } -(($ as text like a dict)'s meaning) = ({}'s metatable).__tostring -externally (a class named $classname with $members ((initialize $it)'s meaning)) -..means: +$($ as text like a dict) = ({}'s metatable).__tostring +externally (a class named $classname with $members $(initialize $)) means: $class = {.__type = $classname} $class.__index = $class $class.class = $class @@ -103,7 +108,7 @@ externally (a class named $classname with $members ((initialize $it)'s meaning)) if $members.$key: rawset $its $key $value ..else: - barf "Cannot set \$key, it's not one of the allowed member fields." + fail "Cannot set \$key, it's not one of the allowed member fields." set $class's metatable to { .__tostring = ($class -> $class.__type) @@ -116,7 +121,7 @@ externally (a class named $classname with $members ((initialize $it)'s meaning)) return $initial_values } - if ((initialize)'s meaning): + if $(initialize $): initialize $class for $stub = $metamethod in $METAMETHOD_MAP: if $class.($stub, as lua id): |
