diff --git a/README.md b/README.md
index cf85545..6b1f5f8 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@ Because `testament` and `testutils` are going nowhere fast.
## Goals
+- we expect everything to work; any statement is a test
- better stack traces and test source output
- less magical syntax and less output omission
- aim to run many cheap tests in fewer files
@@ -33,14 +34,16 @@ expandMacros:
block goats:
## this is a test of goats
+ discard
block pigs:
## a test of pigs
+ discard
var r = 3
block sometimes_the_wolf_is_nice:
- break
+ assert true
inc r
block sheepies:
@@ -61,7 +64,7 @@ expandMacros:
block:
discard "unnamed test"
- test "a test: block":
+ test "a test: block is fine":
discard
block omission:
@@ -84,6 +87,8 @@ expandMacros:
block assertions:
assert 2 == 4 div 2
assert 2 != 4 div 2
+
+ assert "any statement is a test" != ""
```
![demonstration](docs/demo.svg "demonstration")
diff --git a/docs/demo.svg b/docs/demo.svg
index a3bcb1b..568d08e 100644
--- a/docs/demo.svg
+++ b/docs/demo.svg
@@ -16,59 +16,62 @@
}
:root {
- --animation-duration: 10661ms;
+ --animation-duration: 10629ms;
}
@keyframes roll {
0.000%{transform:translateY(0px)}
-0.872%{transform:translateY(-1054px)}
-0.910%{transform:translateY(-2108px)}
-0.976%{transform:translateY(-3162px)}
-0.985%{transform:translateY(-4216px)}
-1.051%{transform:translateY(-5270px)}
-1.060%{transform:translateY(-6324px)}
-1.285%{transform:translateY(-7378px)}
-1.313%{transform:translateY(-8432px)}
-2.645%{transform:translateY(-9486px)}
-2.655%{transform:translateY(-10540px)}
-2.664%{transform:translateY(-11594px)}
-2.748%{transform:translateY(-12648px)}
-2.758%{transform:translateY(-13702px)}
-3.358%{transform:translateY(-14756px)}
-3.386%{transform:translateY(-15810px)}
-3.414%{transform:translateY(-16864px)}
-3.424%{transform:translateY(-17918px)}
-3.461%{transform:translateY(-18972px)}
-3.499%{transform:translateY(-20026px)}
-3.593%{transform:translateY(-21080px)}
-3.668%{transform:translateY(-22134px)}
-3.968%{transform:translateY(-23188px)}
-3.996%{transform:translateY(-24242px)}
-4.024%{transform:translateY(-25296px)}
-4.033%{transform:translateY(-26350px)}
-4.249%{transform:translateY(-27404px)}
-4.259%{transform:translateY(-28458px)}
-4.352%{transform:translateY(-29512px)}
-4.380%{transform:translateY(-30566px)}
-4.446%{transform:translateY(-31620px)}
-4.531%{transform:translateY(-32674px)}
-4.671%{transform:translateY(-33728px)}
-4.803%{transform:translateY(-34782px)}
-5.000%{transform:translateY(-35836px)}
-5.178%{transform:translateY(-36890px)}
-5.393%{transform:translateY(-37944px)}
-5.506%{transform:translateY(-38998px)}
-5.619%{transform:translateY(-40052px)}
-5.731%{transform:translateY(-41106px)}
-5.844%{transform:translateY(-42160px)}
-5.956%{transform:translateY(-43214px)}
-6.088%{transform:translateY(-44268px)}
-6.200%{transform:translateY(-45322px)}
-100.000%{transform:translateY(-45322px)}
+0.847%{transform:translateY(-1054px)}
+0.884%{transform:translateY(-2108px)}
+0.950%{transform:translateY(-3162px)}
+0.960%{transform:translateY(-4216px)}
+1.025%{transform:translateY(-5270px)}
+1.035%{transform:translateY(-6324px)}
+1.261%{transform:translateY(-7378px)}
+1.289%{transform:translateY(-8432px)}
+2.540%{transform:translateY(-9486px)}
+2.550%{transform:translateY(-10540px)}
+2.568%{transform:translateY(-11594px)}
+2.653%{transform:translateY(-12648px)}
+2.663%{transform:translateY(-13702px)}
+3.236%{transform:translateY(-14756px)}
+3.274%{transform:translateY(-15810px)}
+3.283%{transform:translateY(-16864px)}
+3.293%{transform:translateY(-17918px)}
+3.302%{transform:translateY(-18972px)}
+3.349%{transform:translateY(-20026px)}
+3.387%{transform:translateY(-21080px)}
+3.472%{transform:translateY(-22134px)}
+3.481%{transform:translateY(-23188px)}
+3.556%{transform:translateY(-24242px)}
+3.566%{transform:translateY(-25296px)}
+3.839%{transform:translateY(-26350px)}
+3.867%{transform:translateY(-27404px)}
+3.895%{transform:translateY(-28458px)}
+3.904%{transform:translateY(-29512px)}
+4.102%{transform:translateY(-30566px)}
+4.121%{transform:translateY(-31620px)}
+4.158%{transform:translateY(-32674px)}
+4.309%{transform:translateY(-33728px)}
+4.347%{transform:translateY(-34782px)}
+4.469%{transform:translateY(-35836px)}
+4.582%{transform:translateY(-36890px)}
+4.695%{transform:translateY(-37944px)}
+4.817%{transform:translateY(-38998px)}
+4.939%{transform:translateY(-40052px)}
+5.080%{transform:translateY(-41106px)}
+5.184%{transform:translateY(-42160px)}
+5.297%{transform:translateY(-43214px)}
+5.419%{transform:translateY(-44268px)}
+5.541%{transform:translateY(-45322px)}
+5.664%{transform:translateY(-46376px)}
+5.795%{transform:translateY(-47430px)}
+5.918%{transform:translateY(-48484px)}
+100.000%{transform:translateY(-48484px)}
}
#screen_view {
- animation-duration: 10661ms;
+ animation-duration: 10629ms;
animation-iteration-count:infinite;
animation-name:roll;
animation-timing-function: steps(1,end);
@@ -103,5 +106,5 @@
-
+
\ No newline at end of file
diff --git a/docs/testes.html b/docs/testes.html
index fa68831..af3ced4 100644
--- a/docs/testes.html
+++ b/docs/testes.html
@@ -176,7 +176,7 @@
- Made with Nim. Generated: 2020-08-05 02:25:15 UTC
+ Made with Nim. Generated: 2020-08-05 20:11:11 UTC
diff --git a/docs/theindex.html b/docs/theindex.html
index daf3858..d17db66 100644
--- a/docs/theindex.html
+++ b/docs/theindex.html
@@ -85,7 +85,7 @@ Index
- Made with Nim. Generated: 2020-08-05 02:25:15 UTC
+ Made with Nim. Generated: 2020-08-05 20:11:11 UTC
diff --git a/testes.nim b/testes.nim
index f09bc64..396795d 100644
--- a/testes.nim
+++ b/testes.nim
@@ -160,18 +160,22 @@ proc wrapExcept(t: Test): NimNode =
proc makeTest(n: NimNode; name: string): Test =
assert not n.isNil
- result = Test(name: name, orig: copyNimTree(n))
+ result = Test(name: name, orig: n)
let beuno = genSym(nskLabel, "beuno") # all good, bro
let arrrg = genSym(nskLabel, "arrrg") # bad news, pal
- # emit a success if we exited the block normally
- n.add result.success
- n.add nnkBreakStmt.newTree(arrrg)
- result.n = nnkBlockStmt.newTree(beuno, n)
+ result.n = copyNimTree(n).newStmtList
+ result.n.add result.success
- # emit a failure if we broke out of the success block
- result.n = nnkBlockStmt.newTree(arrrg,
- newStmtList(result.n, result.failure))
+ when false:
+ # emit a success if we exited the block normally
+ n.add result.success
+ n.add nnkBreakStmt.newTree(arrrg)
+ result.n = nnkBlockStmt.newTree(beuno, n)
+
+ # emit a failure if we broke out of the success block
+ result.n = nnkBlockStmt.newTree(arrrg,
+ newStmtList(result.n, result.failure))
# wrap it to catch any exceptions
result.n = result.wrapExcept
@@ -180,8 +184,9 @@ proc makeTest(n: NimNode; name: string): Test =
when not defined(release):
result.n = nnkWhenStmt.newTree(
nnkElifBranch.newTree(
- newCall(ident"compiles", nnkBlockStmt.newTree(newEmptyNode(),
- result.orig)),
+ newCall(ident"compiles",
+ nnkBlockStmt.newTree(genSym(nskLabel, "compiles"),
+ newStmtList(result.orig))),
result.n),
nnkElse.newTree(result.compilerr))
@@ -217,7 +222,7 @@ proc findName(n: NimNode; index: int): string =
## generate a name for a test block
assert not n.isNil
block:
- if len(n) == 2:
+ if len(n) == 2 and n.kind == nnkBlockStmt:
# grab the body of the block,
var body = n.last
# and the first node
@@ -235,6 +240,9 @@ proc findName(n: NimNode; index: int): string =
"test #" & $index & " " & shortenRepr(n)
# and we're done.
break
+ else:
+ result = shortenRepr(n)
+ break
# else we had some kind of parse error
echo treeRepr(n)
result = "test #" & $index & " (parse error)"
@@ -249,7 +257,8 @@ const
nnkBreakStmt, nnkAsmStmt, nnkImportStmt, nnkImportExceptStmt,
nnkExportStmt, nnkExportExceptStmt, nnkFromStmt, nnkIncludeStmt,
nnkTypeSection, nnkMixinStmt, nnkBindStmt, nnkProcDef, nnkIteratorDef,
- nnkConverterDef, nnkTemplateDef, nnkFuncDef, nnkMacroDef
+ nnkConverterDef, nnkTemplateDef, nnkFuncDef, nnkMacroDef, nnkCommand,
+ nnkCall
}
@@ -259,7 +268,8 @@ const
nnkBlockStmt, nnkIfStmt, nnkWhileStmt, nnkForStmt, nnkTryStmt,
nnkReturnStmt, nnkYieldStmt, nnkDiscardStmt, nnkContinueStmt,
nnkAsmStmt, nnkImportStmt, nnkImportExceptStmt, nnkExportStmt,
- nnkExportExceptStmt, nnkFromStmt, nnkIncludeStmt
+ nnkExportExceptStmt, nnkFromStmt, nnkIncludeStmt, nnkCommand,
+ nnkCall, nnkWhenStmt
}
@@ -268,18 +278,18 @@ macro testes*(tests: untyped) =
result = newStmtList()
for index, n in pairs(tests):
var n = n.rewriteTestBlock
- if n.kind notin testable:
- result.add output(repr(n).prefixLines("⚫ ").newLit)
- result.add n
- else:
+ if n.kind in testable:
var test: Test
- if len(n) < 2 or len(n.last) == 0:
+ if false and len(n) < 2 or len(n.last) == 0:
test.name = "test #$1 omitted" % [ $index ]
test.n = test.output("🔵 " & test.name)
else:
let name = findName(n, index)
test = makeTest(n, name)
result.add test.n
+ else:
+ result.add output(repr(n).prefixLines("⚫ ").newLit)
+ result.add n
template suite*(title, tests: untyped): untyped =
## suite, suite testes
diff --git a/testes.nimble b/testes.nimble
index 7c025f3..ed7fe41 100644
--- a/testes.nimble
+++ b/testes.nimble
@@ -1,4 +1,4 @@
-version = "0.1.1"
+version = "0.1.2"
author = "disruptek"
description = "a cure for salty testes"
license = "MIT"
diff --git a/tests/testicles.nim b/tests/testicles.nim
index 2ca3da2..93f8973 100644
--- a/tests/testicles.nim
+++ b/tests/testicles.nim
@@ -5,14 +5,16 @@ expandMacros:
block goats:
## this is a test of goats
+ discard
block pigs:
## a test of pigs
+ discard
var r = 3
block sometimes_the_wolf_is_nice:
- break
+ assert true
inc r
block sheepies:
@@ -33,7 +35,7 @@ expandMacros:
block:
discard "unnamed test"
- test "a test: block":
+ test "a test: block is fine":
discard
block omission:
@@ -56,3 +58,5 @@ expandMacros:
block assertions:
assert 2 == 4 div 2
assert 2 != 4 div 2
+
+ assert "any statement is a test" != ""