diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-30 15:05:41 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-30 15:06:03 -0700 |
| commit | ab4ebdf1751158391100efb0002f40b1d7f6314c (patch) | |
| tree | be675ed7b35164a24bdae5e8f1d3dd73af98490f /lib | |
| parent | 7c488dd266466f80e55a3f02050f4e4a019d64b5 (diff) | |
Changed autoformatting rules to ensure tests get clumped together with
the thing below them.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/base64.nom | 6 | ||||
| -rw-r--r-- | lib/consolecolor.nom | 1 | ||||
| -rw-r--r-- | lib/file_hash.nom | 4 | ||||
| -rw-r--r-- | lib/object.nom | 1 | ||||
| -rw-r--r-- | lib/os.nom | 8 |
5 files changed, 6 insertions, 14 deletions
diff --git a/lib/base64.nom b/lib/base64.nom index a5bb9bb..a65a99d 100644 --- a/lib/base64.nom +++ b/lib/base64.nom @@ -6,6 +6,7 @@ %b64_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" %reverse_b64 = (%b64_str.%i = (%i - 1) for %i in 1 to (length of %b64_str)) %reverse_b64."=" = 0 + test: %cases = ["", "Zg==", "Zm8=", "Zm9v", "Zm9vYg==", "Zm9vYmE=", "Zm9vYmFy"] for %len = %encoded in %cases: @@ -16,7 +17,6 @@ test: 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: @@ -46,9 +46,9 @@ action [decode base64 %str, %str base64 decoded, base64 decode %str]: for %i in 1 to (length of %str) via 4: %indices = (%reverse_b64.(%str.%) for % in %i to (%i + 3)) add (chr ((%indices.1 << 2) + ((%indices.2 & 48) >> 4))) to %chars - if (%str.(%i+2) == "="): stop + if (%str.(%i + 2) == "="): stop add (chr (((%indices.2 & 15) << 4) + ((%indices.3 & 60) >> 2))) to %chars - if (%str.(%i+3) == "="): stop + if (%str.(%i + 3) == "="): stop add (chr (((%indices.3 & 3) << 6) + %indices.4)) to %chars return (%chars joined) diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom index 53ddecf..1fdf4b2 100644 --- a/lib/consolecolor.nom +++ b/lib/consolecolor.nom @@ -4,7 +4,6 @@ test: bright "\(green)Color test passed." - %colors = {..} normal:0, "reset color":0, bright:1, bold:1, dim:2, italic:3, underscore:4 "slow blink":5, "fast blink":6, reverse:7, inverse:7, inverted:7, hidden:8 diff --git a/lib/file_hash.nom b/lib/file_hash.nom index aef1c78..2f9076e 100644 --- a/lib/file_hash.nom +++ b/lib/file_hash.nom @@ -9,7 +9,6 @@ use "lib/base64.nom" test: assume ((hash "hello world") == "Kq5sNclPz7QV2+lfQIuc6R7oRu0=") - action [hash %, sha1 %]: %hash = (=lua "\%hashlib.new('sha1'):final(\%)") return (base64 %hash) @@ -18,7 +17,6 @@ action [file with hash %hash]: for file %filename in ".": %contents = (read file %filename) %file_hash = (hash %contents) - if (%file_hash == %hash): - return %filename + if (%file_hash == %hash): return %filename parse [hash of file %filename] as (sha1 (read file %filename)) diff --git a/lib/object.nom b/lib/object.nom index 5b842c4..8c33f36 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -42,7 +42,6 @@ test: assume ((sploot) == "splooted") or barf "subclass method failed" assume ((bark) == "Bark!") or barf "inheritance failed" assume ((woof) == "Bark!") - compile [@, me] to (Lua value "self") compile [method %actions %body] to: %lua = (compile as (local action %actions %body)) @@ -4,7 +4,6 @@ test: path of Nomsu file "lib/os.nom" - action [path of Nomsu file %filename]: lua> "for i,f in Files.walk(\%filename) do return f end" barf "Could not find file: \%filename" @@ -18,11 +17,10 @@ action [sh> %cmd]: test: read file "lib/os.nom" - action [read file %filename] (=lua "Files.read(\%filename)") + test: for file %f in "core": do nothing - compile [for file %f in %path %body] to (..) Lua ".." for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do @@ -52,16 +50,14 @@ action [..] test: assume ((line number of 3 in "x\ny") == 2) - action [line number of %pos in %str] (=lua "Files.get_line_number(\%str, \%pos)") + test: assume ((line 2 in "one\ntwo\nthree") == "two") - action [line %line_num in %str] (=lua "Files.get_line(\%str, \%line_num)") test: assume (source lines of \(this)) - action [source lines of %tree]: %source = (%tree.source if (%tree is syntax tree) else %tree) %file = (read file %source.filename) |
