Skip to content

Commit

Permalink
0.1.1: use cpp for exceptional reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Aug 5, 2020
1 parent 47b75ad commit e2158af
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 43 deletions.
98 changes: 71 additions & 27 deletions docs/demo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/testes.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h1 class="title">testes</h1>
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<a id="skip,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#skip%2Cstring"><span class="Identifier">skip</span></a><span class="Other">(</span><span class="Identifier">msg</span> <span class="Other">=</span> <span class="StringLit">&quot;skipped&quot;</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dt><pre><span class="Keyword">proc</span> <a href="#skip%2Cstring"><span class="Identifier">skip</span></a><span class="Other">(</span><span class="Identifier">msg</span> <span class="Other">=</span> <span class="StringLit">&quot;skipped&quot;</span><span class="Other">)</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">SkipError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>


Expand Down Expand Up @@ -176,7 +176,7 @@ <h1><a class="toc-backref" href="#18">Templates</a></h1>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2020-08-04 20:07:48 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2020-08-05 02:25:15 UTC</small>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/theindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h1 class="title">Index</h1>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2020-08-04 20:07:48 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2020-08-05 02:25:15 UTC</small>
</div>
</div>
</div>
Expand Down
16 changes: 6 additions & 10 deletions testes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,18 @@ proc compilerr(t: Test): NimNode =
result.add t.setExitCode

proc skip*(msg = "skipped") =
#raise newException(SkipError, msg)
report "💣 skipping is broken due to a bug"
report "💣 skipping is broken on C (not C++) backend due to a bug"
raise newException(SkipError, msg)

proc wrapExcept(t: Test): NimNode =
var skipping = bindSym"SkipError"
var assertion = bindSym"AssertionDefect"
var catchall = bindSym"Exception"
var e = genSym(nskLet, "e")
result = nnkTryStmt.newTree(t.n,
nnkExceptBranch.newTree(infix(skipping, "as", e),
t.skipped(e)),
nnkExceptBranch.newTree(infix(assertion, "as", e),
t.failure(e)),
nnkExceptBranch.newTree(infix(ident"Exception", "as", e),
t.exception(e)))
nnkExceptBranch.newTree(infix(skipping, "as", e), t.skipped(e)),
nnkExceptBranch.newTree(infix(assertion, "as", e), t.failure(e)),
nnkExceptBranch.newTree(infix(catchall, "as", e), t.exception(e)))

proc makeTest(n: NimNode; name: string): Test =
assert not n.isNil
Expand Down Expand Up @@ -198,8 +196,6 @@ when false:
else:
result = n

#template test*(x, y: untyped) = test x: y

proc rewriteTestBlock(n: NimNode): NimNode =
## rewrite test "something": ... as block: ## something ...
assert not n.isNil
Expand Down
6 changes: 3 additions & 3 deletions testes.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.1.0"
version = "0.1.1"
author = "disruptek"
description = "a cure for salty testes"
license = "MIT"
Expand All @@ -8,7 +8,7 @@ requires "bump >= 1.8.18 & < 2.0.0"
#requires "https://github.com/disruptek/badresults < 2.0.0"
requires "https://github.com/disruptek/cutelog >= 1.1.0 & < 2.0.0"

backend = "c"
backend = "cpp"

proc execCmd(cmd: string) =
echo "execCmd:" & cmd
Expand All @@ -23,4 +23,4 @@ task test, "run tests for travis":

task docs, "generate some docs":
exec "nim doc --project --outdir=docs testes.nim"
exec "termtosvg docs/demo.svg --loop-delay=10000 --screen-geometry=80x60 --template=solarized_light --command=\"nim cpp -r tests/testicles.nim\""
exec "termtosvg docs/demo.svg --loop-delay=10000 --screen-geometry=80x60 --template=window_frame_powershell --command=\"nim cpp -r tests/testicles.nim\""

0 comments on commit e2158af

Please sign in to comment.