diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-08-30 14:16:09 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-08-30 14:16:18 -0700 |
| commit | 18126da9c538046a93715d829722c818773b9ac1 (patch) | |
| tree | 3a88e43636b85534ded21abd9f9f106b8ffbc037 /lib | |
| parent | ba00294badff9d5f5d55e1080a17b13fea961f55 (diff) | |
Auto-upgraded to 3.7
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/base64.nom | 11 | ||||
| -rw-r--r-- | lib/consolecolor.nom | 2 | ||||
| -rw-r--r-- | lib/file_hash.nom | 10 | ||||
| -rw-r--r-- | lib/object.nom | 2 | ||||
| -rw-r--r-- | lib/os.nom | 2 | ||||
| -rw-r--r-- | lib/training_wheels.nom | 2 | ||||
| -rw-r--r-- | lib/version.nom | 2 |
7 files changed, 17 insertions, 14 deletions
diff --git a/lib/base64.nom b/lib/base64.nom index fb12319..92ce7c4 100644 --- a/lib/base64.nom +++ b/lib/base64.nom @@ -1,10 +1,10 @@ -#!/usr/bin/env nomsu -V3.6.5.6 +#!/usr/bin/env nomsu -V3.7.5.6 # This file defines actions for encoding/decoding base 64, as specified in: https://tools.ietf.org/html/rfc4648 %b64_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" -%reverse_b64 = (%b64_str.%i = (%i - 1) for %i in 1 to (length of %b64_str)) +%reverse_b64 = (%b64_str.%i = (%i - 1) for %i in 1 to (size of %b64_str)) %reverse_b64."=" = 0 test: @@ -14,15 +14,16 @@ test: assume ((base64 %plain) == %encoded) or barf ".." \(quote %plain) base64 encoded to \(quote (base64 %plain)) \ ..instead of \(quote %encoded) + assume ((base64 decode %encoded) == %plain) or barf ".." \(quote %encoded) base64 decoded to \(quote (base64 decode %encoded)) \ ..instead of \(quote %plain) action [base64 %str, base64 encode %str, %str base64]: %chars = [] - for %i in 1 to (length of %str) via 3: + for %i in 1 to (size of %str) via 3: %bytes = [=lua "\%str:byte(\%i, \(%i + 2))"] %chars::add %b64_str.(((%bytes.1 & 252) >> 2) + 1) - if (length of %bytes) is: + if (size of %bytes) is: 3: %chars::add %b64_str.(((%bytes.1 & 3) << 4) + ((%bytes.2 & 240) >> 4) + 1) %chars::add %b64_str.(((%bytes.2 & 15) << 2) + ((%bytes.3 & 192) >> 6) + 1) @@ -43,7 +44,7 @@ action [base64 %str, base64 encode %str, %str base64]: action [chr %] (=lua "string.char(\%)") action [decode base64 %str, %str base64 decoded, base64 decode %str]: %chars = [] - for %i in 1 to (length of %str) via 4: + for %i in 1 to (size of %str) via 4: %indices = (%reverse_b64.(%str.%) for % in %i to (%i + 3)) %chars::add (chr ((%indices.1 << 2) + ((%indices.2 & 48) >> 4))) if (%str.(%i + 2) == "="): stop diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom index 881109d..7809f86 100644 --- a/lib/consolecolor.nom +++ b/lib/consolecolor.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.6.5.6 +#!/usr/bin/env nomsu -V3.7.5.6 # This file defines actions for ANSI console color escape codes. diff --git a/lib/file_hash.nom b/lib/file_hash.nom index bce8c08..35b8340 100644 --- a/lib/file_hash.nom +++ b/lib/file_hash.nom @@ -1,12 +1,11 @@ -#!/usr/bin/env nomsu -V3.6.5.6 +#!/usr/bin/env nomsu -V3.7.5.6 # This file defines some actions for hashing files and looking up files by hash. use "lib/os.nom" use "lib/base64.nom" -lua> ".." - local \%use_sha1, \%hashlib = pcall(require, 'openssl.digest') +lua> "local \%use_sha1, \%hashlib = pcall(require, 'openssl.digest')" test: assume ((hash "hello world") == (hash "hello world")) @@ -14,13 +13,16 @@ test: Hash collision: (hash "hello world") = \(hash "hello world") (hash "goodbye") = \(hash "goodbye") + assume (..) (..) hash ".." This is a really long string meant to stress test the hashing function and ensure that it's not overflowing with long inputs. ..!= "inf" - assume ((hash "\0") != (hash "\0\0\0\0\0")) or barf "Incorrect hashing of null strings" + + assume ((hash "\000") != (hash "\000\000\000\000\000")) or barf ".." + Incorrect hashing of null strings if %use_sha1: assume ((hash "hello world") == "Kq5sNclPz7QV2+lfQIuc6R7oRu0=") if %use_sha1: diff --git a/lib/object.nom b/lib/object.nom index 67c6b73..6aa0630 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.6.5.6 +#!/usr/bin/env nomsu -V3.7.5.6 # This file contains the implementation of an Object-Oriented programming system. @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.6.5.6 +#!/usr/bin/env nomsu -V3.7.5.6 # This file defines some actions that interact with the operating system and filesystem. diff --git a/lib/training_wheels.nom b/lib/training_wheels.nom index 6dcbb42..e98392a 100644 --- a/lib/training_wheels.nom +++ b/lib/training_wheels.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.6.5.6 +#!/usr/bin/env nomsu -V3.7.5.6 # This file contains a set of definitions that bring some familiar language features from other languages into nomsu (e.g. "||" and "continue") diff --git a/lib/version.nom b/lib/version.nom index 0b11245..12e691a 100644 --- a/lib/version.nom +++ b/lib/version.nom @@ -1,3 +1,3 @@ -#!/usr/bin/env nomsu -V3.6.5.6 +#!/usr/bin/env nomsu -V3.7.5.6 # This file sets the current library version. lua> "NOMSU_LIB_VERSION = 6" |
