From e2158af9126354404957dac0d7477ad165eaeea5 Mon Sep 17 00:00:00 2001 From: Andy Davidoff Date: Tue, 4 Aug 2020 22:25:58 -0400 Subject: [PATCH] 0.1.1: use cpp for exceptional reasons --- docs/demo.svg | 98 +++++++++++++++++++++++++++++++++------------- docs/testes.html | 4 +- docs/theindex.html | 2 +- testes.nim | 16 +++----- testes.nimble | 6 +-- 5 files changed, 83 insertions(+), 43 deletions(-) diff --git a/docs/demo.svg b/docs/demo.svg index 1ed64b7..a3bcb1b 100644 --- a/docs/demo.svg +++ b/docs/demo.svg @@ -1,4 +1,4 @@ - + @@ -16,19 +16,59 @@ } :root { - --animation-duration: 10022ms; + --animation-duration: 10661ms; } @keyframes roll { 0.000%{transform:translateY(0px)} -0.150%{transform:translateY(-1054px)} -0.190%{transform:translateY(-2108px)} -0.220%{transform:translateY(-3162px)} -100.000%{transform:translateY(-3162px)} +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)} } #screen_view { - animation-duration: 10022ms; + animation-duration: 10661ms; animation-iteration-count:infinite; animation-name:roll; animation-timing-function: steps(1,end); @@ -38,26 +78,30 @@ - Hint: used config file '/home/adavidoff/nims/config/nim.cfg' [Conf]Hint: used config file '/home/adavidoff/nims/config/config.nims' [Conf]Hint: used config file '/home/adavidoff/git/testes/nim.cfg' [Conf] Hint: 7693 lines; 0.016s; 12.234MiB peakmem; Debug build; proj: /home/adavidoff/git/testes/tests/testicles.nim; out: /home/adavidoff/git/testes/tests/testicles [SuccessX]Hint: /home/adavidoff/git/testes/tests/testicles [Exec]🟢 this is a test of goats🟢 a test of pigs⚫ var r = 3🔴 sometimes the wolf is nice 🗏 1 break 🗏 2 inc r💥 sheepies: ValueError: you're terrible 🗏 1 raise newException(ValueError, "you\'re terrible") 🗇 tests/testicles.nim 🗇 19 raise newException(ValueError, "you're terrible") # in testicles()r = 3r == 2 = false🔴 checking some things 🗏 1 ## this block exists only to test inclusion of 🗏 2 ## comments in the test code display... 🗏 3 check r == 3 🗏 4 dump r 🗏 5 check r == 2🟢 unnamed block🟢 test #7🟢 a test: block💣 skipping is broken due to a bug🟢 omission⚫ when defined(release):⚫ testes:⚫ const⚫ compile = true⚫ proc doesnt(c: bool) =⚫ if not c:⚫ raise⚫ block:⚫ proc fixed() =⚫ doesnt(compile)⚫ else:⚫ proc broken() =⚫ doesnt(comp ⛔ broken: compile failed 🗏 1 proc broken() = 🗏 2 doesnt(compile) 🗏 3 🔴 assertions 🗏 1 assert 2 == 4 div 2 🗏 2 assert 2 != 4 div 2 🗇 58 assert 2 != 4 div 2 # in testicles() 🗇 ../../nims/lib/system/assertions.nim 🗇 30 cast[Hide](raiseAssert)(msg) # in failedAssertImpl() 🗇 23 sysFatal(AssertionDefect, msg) # in raiseAssert() 🗇 ../../nims/lib/system/fatal.nim 🗇 49 raise (ref exceptn)(msg: message) # in sysFatal() + + + + + Hint: used config file '/home/adavidoff/nims/config/nim.cfg' [Conf]Hint: used config file '/home/adavidoff/nims/config/config.nims' [Conf]Hint: used config file '/home/adavidoff/git/testes/nim.cfg' [Conf]. .. ... .... ........ ......... ........... ............ ............. .............. ............... ................ ................. ................... .................... ...................... ....................... ........................ ......................... .......................... ............................ .............................. ............................... ................................ ................................. .................................. ................................../home/adavidoff/git/testes/testes.nim(66, 6) Hint: 'findWhere' is declared but not used [XDeclaredButNotUsed]/home/adavidoff/git/testes/testes.nim(44, 6) Hint: 'countComments' is declared but not used [XDeclaredButNotUsed]/home/adavidoff/git/testes/testes.nim(5, 11) /home/adavidoff/git/testes/testes.nim(5, 11) Warning: imported and not used: 'unittest' [UnusedImport] /home/adavidoff/git/testes/tests/testicles.nim(4, 3) template/generic instantiation of `testes` from here/home/adavidoff/git/testes/tests/testicles.nim(16, 11) Warning: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]/home/adavidoff/git/testes/tests/testicles.nim(14, 11) Warning: unreachable code/home/adavidoff/git/testes/tests/testicles.nim(4, 3) /home/adavidoff/git/testes/tests/testicles.nim(18, 11) Warning: unreachable codetry: block arrrg_17106043: block beuno_17106042: ## this is a test of goats report(["🟢 this is a test of goats"]) break arrrg_17106043 report(["🔴 this is a test of goats"]) report([" 🗏 "]) if not isatty(stdin): setProgramResult(1)except SkipError as e_17106083: report(["⚪ this is a test of goats: " & (`$`(e_17106083.name) & ": " & e_17106083.msg)])except AssertionDefect as e_17106083: report(["🔴 this is a test of goats"]) report([" 🗏 "]) if stackTraceAvailable(): renderStack(getStackTraceEntries(e_17106083)) if not isatty(stdin): setProgramResult(1)except Exception as e_17106083: report(["💥 this is a test of goats: " & (`$`(e_17106083.name) & ": " & e_1710 block arrrg_17106090: block beuno_17106089: ## a test of pigs report(["🟢 a test of pigs"]) break arrrg_17106090 report(["🔴 a test of pigs"])except SkipError as e_17106091: report(["⚪ a test of pigs: " & (`$`(e_17106091.name) & ": " & e_17106091.msg)])except AssertionDefect as e_17106091: report(["🔴 a test of pigs"]) renderStack(getStackTraceEntries(e_17106091))except Exception as e_17106091: report(["💥 a test of pigs: " & (`$`(e_17106091.name) & ": " & e_17106091.msg)report(["⚫ var r = 3"])var r = 3 block arrrg_17106106: block beuno_17106105: break inc r, 1 report(["🟢 sometimes the wolf is nice"]) break arrrg_17106106 report(["🔴 sometimes report(["🔴 sometimes the wolf is nice"]) report([" 🗏 1 break\n 🗏 2 inc r"])except SkipError as e_17106125: report(["⚪ sometimes the wolf is nice: " & (`$`(e_17106125.name) & ": " & e_17106125.msg)])except AssertionDefect as e_17106125: report(["🔴 sometimes the wolf is nice"]) report([" 🗏 1 break\n 🗏 2 inc r"]) renderStack(getStackTraceEntries(e_17106125))except Exception as e_17106125: report(["💥 sometimes the wolf is nice: " & (`$`(e_17106125.name) & ": " & e_1 block arrrg_17106127: block beuno_17106126: raise (ref ValueError)(msg: "you\'re terrible", parent: nil) report(["🟢 sheepies"]) break arrrg_1710 break arrrg_17106127 report(["🔴 sheepies"]) report([" 🗏 1 raise newException(ValueError, \"you\\\'re terrible\")"])except SkipError as e_17106128: report(["⚪ sheepies: " & (`$`(e_17106128.name) & ": " & e_17106128.msg)])except AssertionDefect as e_17106128: report(["🔴 sheepies"]) report([" 🗏 1 raise newException(ValueError, \"you\\\'re terrible\")"]) renderStack(getStackTraceEntries(e_17106128))except Exception as e_17106128: report(["💥 sheepies: " & (`$`(e_17106128.name) & ": " & e_17106128.msg)]) block arrrg_17106130: block beuno_17106129: ## checking some things ## this block exists only to test inclus ## this block exists only to test inclusion of ## comments in the test code display... if not (r == 3): debugEcho ["r == 3", " = ", r == 3] break debugEcho ["r", " = ", r] if not (r == 2): debugEcho ["r == 2", " = ", r == 2] report(["🟢 checking some things"]) break arrrg_17106130 report(["🔴 checking some things"]) report([" 🗏 1 ## this block exists only to test inclusion of\n 🗏 2 ## comments in the test code display...\n 🗏 3 check r == 3\n 🗏 4 dump r\n 🗏 5 check r == 2"])except SkipError as e_17106131: report(["⚪ checking some things: " & (`$`(e_17106131.name) & ": " & e_17106131.msg)])except AssertionDefect as e_17106131: report(["🔴 checking some things"]) report([" 🗏 1 ## this block exists only to test inclusion of\n 🗏 2 ## comments in the test code display...\n 🗏 3 check r == 3\n 🗏 4 dump r\n 🗏 5 check r == 2"]) if renderStack(getStackTraceEntries(e_17106131))except Exception as e_17106131: report(["💥 checking some things: " & (`$`(e_17106131.name) & ": " & e_1710613 block arrrg_17106133: block beuno_17106132: ## unnamed block discard report(["🟢 unnamed block"]) break arrrg_17106133 report(["🔴 unnamed block"]) report([" 🗏 1 discard"])except SkipError as e_17106134: report(["⚪ unnamed block: " & (`$`(e_17106134.name) & ": " & e_17106134.msg)])except AssertionDefect as e_17106134: re report(["🔴 unnamed block"]) report([" 🗏 1 discard"]) renderStack(getStackTraceEntries(e_17106134))except Exception as e_17106134: report(["💥 unnamed block: " & (`$`(e_17106134.name) & ": " & e_17106134.msg)] block arrrg_17106136: block beuno_17106135: discard "unnamed test" report(["🟢 test #7"]) break arrrg_17106136 report(["🔴 test #7"]) report([" 🗏 1 discard \"unnamed test\""])except SkipError as e_17106137: report(["⚪ test #7: " & (`$`(e_17106137.name) & ": " & e_17106137.msg)])except AssertionDefect as e_17106137: report(["🔴 test #7"]) report([" 🗏 1 discard \"unnamed test\""]) r renderStack(getStackTraceEntries(e_17106137))except Exception as e_17106137: report(["💥 test #7: " & (`$`(e_17106137.name) & ": " & e_17106137.msg)]) block arrrg_17106139: block beuno_17106138: ## a test: block report(["🟢 a test: block"]) break arrrg_17106139 report(["🔴 a test: block"])except SkipError as e_17106140: report(["⚪ a test: block: " & (`$`(e_17106140.name) & ": " & e_17106140.msg)]except AssertionDefect as e_17106140: report(["🔴 a test: block"]) renderStack(getStackTraceEntries(e_17106140)) setProgramRes except Exception as e_17106140: report(["💥 a test: block: " & (`$`(e_17106140.name) & ": " & e_17106140.msg)] block arrrg_17106142: block beuno_17106141: skip("skipped") report(["🟢 omission"]) break arrrg_17106142 report(["🔴 omission"]) report([" 🗏 1 skip()"])except SkipError as e_17106143: report(["⚪ omission: " & (`$`(e_17106143.name) & ": " & e_17106143.msg)])except AssertionDefect as e_17106143: report(["🔴 omission"]) report([" 🗏 1 skip()"]) renderStack(getStackTraceEntries(e_17106143))except Exception as e_17106143: report(["💥 omission: " & (`$`(e_17106143.name) & ": " & e_17106143.msg)]) report([" 🗏 report(["⚫ when defined(release):\n⚫ testes:\n⚫ const\n⚫ compile = true\n⚫ proc doesnt(c: bool) =\n⚫ if not c:\n⚫ raise\n⚫ \n⚫ block:\n⚫ proc fixed() =\n⚫ doesnt(compile)\n⚫ \n⚫ else:\n⚫ testes:\n⚫ block:\n⚫ proc broken() =\n⚫ doesnt(compile)\n⚫ "])report(["⛔ broken: compile failed"])report([" 🗏 1 proc broken() =\n 🗏 2 doesnt(compile)\n 🗏 3 "])if not isatty(stdin): setProgramResult(1) block arrrg_17106145: block beuno_17106144: const expr`gensym17 = "2 == 4 div 2" loc`gensym18 = ( filename: "/home/adavidoff/git/testes/tests/testicles.nim", line: 57, column: 13) ploc`gensym18 = "/home/adavidoff/git/testes/tests/testicles.nim(57, 14)" {.line: (fi {.line: (filename: "/home/adavidoff/git/testes/tests/testicles.nim", line: 57, column: 13).}: if false: failedAssertImpl("/home/adavidoff/git/testes/tests/testicles.nim(57, 14) `2 == 4 div 2` ") expr`gensym19 = "2 != 4 div 2" loc`gensym21 = ( filename: "/home/adavidoff/git/testes/tests/testicles.nim", line: 58, ploc`gensym21 = "/home/adavidoff/git/testes/tests/testicles.nim(58, 14)" line: 58, column: 13).}: if true: failedAssertImpl("/home/adavidoff/git/testes/tests/testicles.nim(58, 14) `2 != 4 div 2` ") report(["🟢 assertions"]) break arrrg_17106145 report(["🔴 assertions"]) report([" 🗏 1 assert 2 == 4 div 2\n 🗏 2 assert 2 != 4 div 2"])except SkipError as e_17106146: report(["⚪ assertions: report(["⚪ assertions: " & (`$`(e_17106146.name) & ": " & e_17106146.msg)])except AssertionDefect as e_17106146: report(["🔴 assertions"]) report([" 🗏 1 assert 2 == 4 div 2\n 🗏 2 assert 2 != 4 div 2"]) renderStack(getStackTraceEntries(e_17106146))except Exception as e_17106146: report(["💥 assertions: " & (`$`(e_17106146.name) & ": " & e_17106146.msg)])CC: stdlib_assertions.nimCC: stdlib_dollars.nimCC: stdlib_io.nimCC: stdlib_system.nimCC: stdlib_parseutils.nimCC: stdlib_unicode.nimCC: stdlib_strutils.nimCC: stdlib_pathnorm.nimCC: stdlib_times.nimCC: stdlib_os.nimCC: stdlib_exitprocs.nimCC: stdlib_strformat.nimCC: stdlib_terminal.nimCC: stdlib_streams.nimCC: stdlib_unittest.nimCC: stdl CC: stdlib_logging.nimCC: ../deps/cutelog/cutelog.nimCC: ../testes.nimCC: testicles.nimHint: 65520 lines; 0.621s; 75.941MiB peakmem; Debug build; proj: /home/adavidoff/git/testes/tests/testicles.nim; out: /home/adavidoff/git/testes/tests/testicles [SuccessX]Hint: /home/adavidoff/git/testes/tests/testicles [Exec]🟢 this is a test of goats🟢 a test of pigs⚫ var r = 3🔴 sometimes the wolf is nice 🗏 1 break 🗏 2 inc r💥 sheepies: ValueError: you're terrible 🗏 1 raise newException(ValueError, "you\'re terrible") 🗇 tests/testicles.nim 🗇 19 raise newException(ValueError, "you're terrible") # in testicles()r = 3r == 2 = false🔴 checking some things 🗏 1 ## this block exists only to test inclusion of 🗏 2 ## comments in the test code display... 🗏 3 check r == 3 🗏 4 dump r 🗏 5 check r == 2🟢 unnamed block🟢 test #7🟢 a test: block💣 skipping 💣 skipping is broken on C (not C++) backend due to a bug⚪ omission: SkipError: skipped⚫ when defined(release):⚫ testes:⚫ const⚫ compile = true⚫ proc doesnt(c: bool) =⚫ if not c:⚫ raise⚫ block:⚫ proc fixed() =⚫ doesnt(compile)⚫ else:⚫ proc broken() =⛔ broken: compile failed 🗏 1 proc broken() = 🗏 2 doesnt(compile) 🗏 3 🔴 assertions 🗏 1 assert 2 == 4 div 2 🗏 2 assert 2 != 4 div 2 🗇 58 assert 2 != 4 div 2 # in testicles() 🗇 ../../nims/lib/system/assertions.nim 🗇 30 cast[Hide](raiseAssert)(msg) # in failedAssertImpl() 🗇 23 sysFatal(AssertionDefect, msg) # in raiseAssert() 🗇 ../../nims/lib/system/fatal.nim 🗇 49 raise (ref exceptn)(msg: message) # in sysFatal() \ No newline at end of file diff --git a/docs/testes.html b/docs/testes.html index 7de163d..fa68831 100644 --- a/docs/testes.html +++ b/docs/testes.html @@ -129,7 +129,7 @@

testes

Procs

-
proc skip(msg = "skipped") {...}{.raises: [IOError], tags: [WriteIOEffect].}
+
proc skip(msg = "skipped") {...}{.raises: [IOError, SkipError], tags: [WriteIOEffect].}
@@ -176,7 +176,7 @@

Templates

diff --git a/docs/theindex.html b/docs/theindex.html index 8ac370d..daf3858 100644 --- a/docs/theindex.html +++ b/docs/theindex.html @@ -85,7 +85,7 @@

Index

diff --git a/testes.nim b/testes.nim index d0a4666..0788d3c 100644 --- a/testes.nim +++ b/testes.nim @@ -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 @@ -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 diff --git a/testes.nimble b/testes.nimble index 06311b2..7c025f3 100644 --- a/testes.nimble +++ b/testes.nimble @@ -1,4 +1,4 @@ -version = "0.1.0" +version = "0.1.1" author = "disruptek" description = "a cure for salty testes" license = "MIT" @@ -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 @@ -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\""