nim-unittest2/unittest2.html

1831 lines
92 KiB
HTML

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- CSS -->
<title>unittest2</title>
<style type="text/css" >
/*
Stylesheet for use with Docutils/rst2html.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Modified from Chad Skeeters' rst2html-style
https://bitbucket.org/cskeeters/rst2html-style/
Modified by Boyd Greenfield
*/
/* SCSS variables */
/* Text weights */
/* Body colors */
/* Text colors */
/* Link colors */
/* Syntax highlighting colors */
/* Pct changes */
/* Mixins */
/* Body/layout */
html {
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%; }
/* Where we want fancier font if available */
h1, h2, h3, h4, h5, h6, p.module-desc, table.docinfo + blockquote p, table.docinfo blockquote p, h1 + blockquote p {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif !important; }
h1.title {
font-weight: 900; }
body {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-weight: 400;
font-size: 16px;
line-height: 20px;
color: #444;
letter-spacing: 0.15px;
background-color: #FDFBFA; }
/* Skeleton grid */
.container {
position: relative;
width: 100%;
max-width: 960px;
margin: 0 auto;
padding: 0 20px;
box-sizing: border-box; }
.column,
.columns {
width: 100%;
float: left;
box-sizing: border-box; }
/* For devices larger than 400px */
@media (min-width: 400px) {
.container {
width: 100%;
padding: 0; } }
/* For devices larger than 650px */
@media (min-width: 650px) {
.container {
width: 100%; }
.column,
.columns {
margin-left: 4%; }
.column:first-child,
.columns:first-child {
margin-left: 0; }
.one.column,
.one.columns {
width: 4.66666666667%; }
.two.columns {
width: 13.3333333333%; }
.three.columns {
width: 22%; }
.four.columns {
width: 30.6666666667%; }
.five.columns {
width: 39.3333333333%; }
.six.columns {
width: 48%; }
.seven.columns {
width: 56.6666666667%; }
.eight.columns {
width: 65.3333333333%; }
.nine.columns {
width: 74.0%; }
.ten.columns {
width: 82.6666666667%; }
.eleven.columns {
width: 91.3333333333%; }
.twelve.columns {
width: 100%;
margin-left: 0; }
.one-third.column {
width: 30.6666666667%; }
.two-thirds.column {
width: 65.3333333333%; } }
/* Customer Overrides */
.footer {
text-align: center;
color: #969696;
padding-top: 10%; }
p.module-desc {
font-size: 1.1em;
color: #666666; }
a.link-seesrc {
color: #aec7d2;
font-style: italic; }
a.link-seesrc:hover {
color: #6c9aae; }
#toc-list {
word-wrap: break-word; }
ul.simple-toc {
list-style: none; }
ul.simple-toc a.reference-toplevel {
font-weight: bold;
color: #0077b3; }
ul.simple-toc-section {
list-style-type: circle;
color: #6c9aae; }
ul.simple-toc-section a.reference {
color: #0077b3; }
cite {
font-style: italic !important; }
dt > pre {
border-color: rgba(0, 0, 0, 0.1);
background-color: rgba(255, 255, 255, 0.3);
margin: 15px 0px 5px; }
dd > pre {
border-color: rgba(0, 0, 0, 0.1);
background-color: whitesmoke;
margin-top: 8px; }
.item > dd {
margin-left: 10px;
margin-bottom: 30px; }
/* Nim line-numbered tables */
.line-nums-table {
width: 100%;
table-layout: fixed; }
/* Nim search input */
div#searchInputDiv {
margin-bottom: 8px;
}
div#searchInputDiv input#searchInput {
width: 10em;
}
div.search-groupby {
margin-bottom: 8px;
}
table.line-nums-table {
border-radius: 4px;
border: 1px solid #cccccc;
background-color: whitesmoke;
border-collapse: separate;
margin-top: 15px;
margin-bottom: 25px; }
.line-nums-table tbody {
border: none; }
.line-nums-table td pre {
border: none;
background-color: transparent; }
.line-nums-table td.blob-line-nums {
width: 28px; }
.line-nums-table td.blob-line-nums pre {
color: #b0b0b0;
-webkit-filter: opacity(75%);
text-align: right;
border-color: transparent;
background-color: transparent;
padding-left: 0px;
margin-left: 0px;
padding-right: 0px;
margin-right: 0px; }
/* Docgen styles */
/* Links */
a {
color: #0077b3;
text-decoration: none; }
a:hover,
a:focus {
color: #00334d;
text-decoration: underline; }
a:visited {
color: #00334d; }
a:focus {
outline: thin dotted #2d2d2d;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px; }
a:hover,
a:active {
outline: 0; }
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline; }
sup {
top: -0.5em; }
sub {
bottom: -0.25em; }
img {
width: auto;
height: auto;
max-width: 100%;
vertical-align: middle;
border: 0;
-ms-interpolation-mode: bicubic; }
@media print {
* {
color: black !important;
text-shadow: none !important;
background: transparent !important;
box-shadow: none !important; }
a,
a:visited {
text-decoration: underline; }
a[href]:after {
content: " (" attr(href) ")"; }
abbr[title]:after {
content: " (" attr(title) ")"; }
.ir a:after,
a[href^="javascript:"]:after,
a[href^="#"]:after {
content: ""; }
pre,
blockquote {
border: 1px solid #999;
page-break-inside: avoid; }
thead {
display: table-header-group; }
tr,
img {
page-break-inside: avoid; }
img {
max-width: 100% !important; }
@page {
margin: 0.5cm; }
h1 {
page-break-before: always; }
h1.title {
page-break-before: avoid; }
p,
h2,
h3 {
orphans: 3;
widows: 3; }
h2,
h3 {
page-break-after: avoid; } }
.img-rounded {
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px; }
.img-polaroid {
padding: 4px;
background-color: rgba(252, 248, 244, 0.75);
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
p {
margin: 0 0 8px; }
small {
font-size: 85%; }
strong {
font-weight: 600; }
em {
font-style: italic; }
cite {
font-style: normal; }
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-weight: 600;
line-height: 20px;
color: inherit;
text-rendering: optimizelegibility; }
h1 {
font-size: 2em;
font-weight: 400;
padding-bottom: .15em;
border-bottom: 1px solid #aaaaaa;
margin-top: 1.0em;
line-height: 1.2em; }
h1.title {
padding-bottom: 1em;
border-bottom: 0px;
font-size: 2.75em; }
h2 {
font-size: 1.5em;
margin-top: 1.5em; }
h3 {
font-size: 1.3em;
font-style: italic;
margin-top: 0.75em; }
h4 {
font-size: 1.3em;
margin-top: 0.5em; }
h5 {
font-size: 1.2em;
margin-top: 0.25em; }
h6 {
font-size: 1.1em; }
ul,
ol {
padding: 0;
margin: 0 0 0px 15px; }
ul ul,
ul ol,
ol ol,
ol ul {
margin-bottom: 0; }
li {
line-height: 20px; }
dl {
margin-bottom: 20px; }
dt,
dd {
line-height: 20px; }
dt {
font-weight: bold; }
dd {
margin-left: 10px;
margin-bottom: 26px; }
hr {
margin: 20px 0;
border: 0;
border-top: 1px solid #eeeeee;
border-bottom: 1px solid #ffffff; }
abbr[title],
abbr[data-original-title] {
cursor: help;
border-bottom: 1px dotted #999999; }
abbr.initialism {
font-size: 90%;
text-transform: uppercase; }
blockquote {
padding: 0 0 0 15px;
margin: 0 0 20px;
border-left: 5px solid #EFEBE0; }
table.docinfo + blockquote, table.docinfo blockquote, h1 + blockquote {
border-left: 5px solid #c9c9c9;
}
table.docinfo + blockquote p, table.docinfo blockquote p, h1 + blockquote p {
margin-bottom: 0;
font-size: 15px;
font-weight: 200;
line-height: 1.5;
font-style: italic; }
q:before,
q:after,
blockquote:before,
blockquote:after {
content: ""; }
address {
display: block;
margin-bottom: 20px;
font-style: normal;
line-height: 20px; }
code,
pre {
font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
padding: 0 3px 2px;
font-weight: 500;
font-size: 12px;
color: #444444;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px; }
.pre {
font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace;
font-weight: 600;
/*color: #504da6;*/
}
code {
padding: 2px 4px;
color: #444444;
white-space: nowrap;
background-color: white;
border: 1px solid #777777; }
pre {
display: inline-block;
box-sizing: border-box;
min-width: calc(100% - 19.5px);
padding: 9.5px;
margin: 0.25em 10px 10px 10px;
font-size: 15px;
line-height: 20px;
white-space: pre !important;
overflow-y: hidden;
overflow-x: visible;
background-color: rgba(0, 0, 0, 0.01);
border: 1px solid #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px; }
pre.prettyprint {
margin-bottom: 20px; }
pre code {
padding: 0;
color: inherit;
white-space: pre;
overflow-x: visible;
background-color: transparent;
border: 0; }
.pre-scrollable {
max-height: 340px;
overflow-y: scroll; }
table {
max-width: 100%;
background-color: transparent;
border-collapse: collapse;
border-spacing: 0; }
table th, table td {
padding: 0px 8px 0px;
}
.table {
width: 100%;
margin-bottom: 20px; }
.table th,
.table td {
padding: 8px;
line-height: 20px;
text-align: left;
vertical-align: top;
border-top: 1px solid #444444; }
.table th {
font-weight: bold; }
.table thead th {
vertical-align: bottom; }
.table caption + thead tr:first-child th,
.table caption + thead tr:first-child td,
.table colgroup + thead tr:first-child th,
.table colgroup + thead tr:first-child td,
.table thead:first-child tr:first-child th,
.table thead:first-child tr:first-child td {
border-top: 0; }
.table tbody + tbody {
border-top: 2px solid #444444; }
.table .table {
background-color: rgba(252, 248, 244, 0.75); }
.table-condensed th,
.table-condensed td {
padding: 4px 5px; }
.table-bordered {
border: 1px solid #444444;
border-collapse: separate;
*border-collapse: collapse;
border-left: 0;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px; }
.table-bordered th,
.table-bordered td {
border-left: 1px solid #444444; }
.table-bordered caption + thead tr:first-child th,
.table-bordered caption + tbody tr:first-child th,
.table-bordered caption + tbody tr:first-child td,
.table-bordered colgroup + thead tr:first-child th,
.table-bordered colgroup + tbody tr:first-child th,
.table-bordered colgroup + tbody tr:first-child td,
.table-bordered thead:first-child tr:first-child th,
.table-bordered tbody:first-child tr:first-child th,
.table-bordered tbody:first-child tr:first-child td {
border-top: 0; }
.table-bordered thead:first-child tr:first-child > th:first-child,
.table-bordered tbody:first-child tr:first-child > td:first-child,
.table-bordered tbody:first-child tr:first-child > th:first-child {
-webkit-border-top-left-radius: 4px;
border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px; }
.table-bordered thead:first-child tr:first-child > th:last-child,
.table-bordered tbody:first-child tr:first-child > td:last-child,
.table-bordered tbody:first-child tr:first-child > th:last-child {
-webkit-border-top-right-radius: 4px;
border-top-right-radius: 4px;
-moz-border-radius-topright: 4px; }
.table-bordered thead:last-child tr:last-child > th:first-child,
.table-bordered tbody:last-child tr:last-child > td:first-child,
.table-bordered tbody:last-child tr:last-child > th:first-child,
.table-bordered tfoot:last-child tr:last-child > td:first-child,
.table-bordered tfoot:last-child tr:last-child > th:first-child {
-webkit-border-bottom-left-radius: 4px;
border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px; }
.table-bordered thead:last-child tr:last-child > th:last-child,
.table-bordered tbody:last-child tr:last-child > td:last-child,
.table-bordered tbody:last-child tr:last-child > th:last-child,
.table-bordered tfoot:last-child tr:last-child > td:last-child,
.table-bordered tfoot:last-child tr:last-child > th:last-child {
-webkit-border-bottom-right-radius: 4px;
border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px; }
.table-bordered tfoot + tbody:last-child tr:last-child td:first-child {
-webkit-border-bottom-left-radius: 0;
border-bottom-left-radius: 0;
-moz-border-radius-bottomleft: 0; }
.table-bordered tfoot + tbody:last-child tr:last-child td:last-child {
-webkit-border-bottom-right-radius: 0;
border-bottom-right-radius: 0;
-moz-border-radius-bottomright: 0; }
.table-bordered caption + thead tr:first-child th:first-child,
.table-bordered caption + tbody tr:first-child td:first-child,
.table-bordered colgroup + thead tr:first-child th:first-child,
.table-bordered colgroup + tbody tr:first-child td:first-child {
-webkit-border-top-left-radius: 4px;
border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px; }
.table-bordered caption + thead tr:first-child th:last-child,
.table-bordered caption + tbody tr:first-child td:last-child,
.table-bordered colgroup + thead tr:first-child th:last-child,
.table-bordered colgroup + tbody tr:first-child td:last-child {
-webkit-border-top-right-radius: 4px;
border-top-right-radius: 4px;
-moz-border-radius-topright: 4px; }
table.docutils th {
background-color: #e8e8e8; }
table.docutils tr:hover {
background-color: whitesmoke; }
.table-striped tbody > tr:nth-child(odd) > td,
.table-striped tbody > tr:nth-child(odd) > th {
background-color: rgba(252, 248, 244, 0.75); }
.table-hover tbody tr:hover > td,
.table-hover tbody tr:hover > th {
background-color: rgba(241, 222, 204, 0.75); }
table td[class*="span"],
table th[class*="span"],
.row-fluid table td[class*="span"],
.row-fluid table th[class*="span"] {
display: table-cell;
float: none;
margin-left: 0; }
.hero-unit {
padding: 60px;
margin-bottom: 30px;
font-size: 18px;
font-weight: 200;
line-height: 30px;
color: inherit;
background-color: rgba(230, 197, 164, 0.75);
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px; }
.hero-unit h1 {
margin-bottom: 0;
font-size: 60px;
line-height: 1;
letter-spacing: -1px;
color: inherit; }
.hero-unit li {
line-height: 30px; }
/* rst2html default used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0; }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 !important; }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 !important; }
.last, .with-subtitle {
margin-bottom: 0 !important; }
.hidden {
display: none; }
a.toc-backref {
text-decoration: none;
color: #444444; }
blockquote.epigraph {
margin: 2em 5em; }
dl.docutils dd {
margin-bottom: 0.5em; }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden; }
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em; }
div.abstract p.topic-title {
font-weight: bold;
text-align: center; }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em;
border: medium outset;
padding: 1em; }
div.note, div.warning {
margin: 1.5em 0px;
border: none; }
div.note p.admonition-title,
div.warning p.admonition-title {
display: none; }
/* Clearfix
* http://css-tricks.com/snippets/css/clear-fix/
*/
div.note:after,
div.warning:after {
content: "";
display: table;
clear: both; }
div.note p:before,
div.warning p:before {
display: block;
float: left;
font-size: 4em;
line-height: 1em;
margin-right: 20px;
margin-left: 0em;
margin-top: -10px;
content: '\0270D';
/*handwriting*/ }
div.warning p:before {
content: '\026A0';
/*warning*/ }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold;
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: #b30000;
font-weight: bold;
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em;
text-align: center;
font-style: italic; }
div.dedication p.topic-title {
font-weight: bold;
font-style: normal; }
div.figure {
margin-left: 2em;
margin-right: 2em; }
div.footer, div.header {
clear: both;
font-size: smaller; }
div.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em; }
div.line-block div.line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em; }
div.sidebar {
margin: 0 0 0.5em 1em;
border: medium outset;
padding: 1em;
background-color: rgba(252, 248, 244, 0.75);
width: 40%;
float: right;
clear: right; }
div.sidebar p.rubric {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-size: medium; }
div.system-messages {
margin: 5em; }
div.system-messages h1 {
color: #b30000; }
div.system-message {
border: medium outset;
padding: 1em; }
div.system-message p.system-message-title {
color: #b30000;
font-weight: bold; }
div.topic {
margin: 2em; }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em; }
h1.title {
text-align: center; }
h2.subtitle {
text-align: center; }
hr.docutils {
width: 75%; }
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em; }
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em; }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto; }
.align-left {
text-align: left; }
.align-center {
clear: both;
text-align: center; }
.align-right {
text-align: right; }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit; }
/* div.align-center * { */
/* text-align: left } */
ul.simple > li {
margin-bottom: 0.5em }
ol.simple, ul.simple {
margin-bottom: 1em; }
ol.arabic {
list-style: decimal; }
ol.loweralpha {
list-style: lower-alpha; }
ol.upperalpha {
list-style: upper-alpha; }
ol.lowerroman {
list-style: lower-roman; }
ol.upperroman {
list-style: upper-roman; }
p.attribution {
text-align: right;
margin-left: 50%; }
p.caption {
font-style: italic; }
p.credits {
font-style: italic;
font-size: smaller; }
p.label {
white-space: nowrap; }
p.rubric {
font-weight: bold;
font-size: larger;
color: maroon;
text-align: center; }
p.sidebar-title {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: larger; }
p.sidebar-subtitle {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-weight: bold; }
p.topic-title {
font-weight: bold; }
pre.address {
margin-bottom: 0;
margin-top: 0;
font: inherit; }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em;
margin-right: 2em; }
pre.code .ln {
color: grey; }
/* line numbers */
pre.code, code {
background-color: #eeeeee; }
pre.code .comment, code .comment {
color: #5c6576; }
pre.code .keyword, code .keyword {
color: #3B0D06;
font-weight: bold; }
pre.code .literal.string, code .literal.string {
color: #0c5404; }
pre.code .name.builtin, code .name.builtin {
color: #352b84; }
pre.code .deleted, code .deleted {
background-color: #DEB0A1; }
pre.code .inserted, code .inserted {
background-color: #A3D289; }
span.classifier {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-style: oblique; }
span.classifier-delimiter {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-weight: bold; }
span.interpreted {
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; }
span.option {
white-space: nowrap; }
span.pre {
white-space: pre; }
span.problematic {
color: #b30000; }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80%; }
table.citation {
border-left: solid 1px #666666;
margin-left: 1px; }
table.docinfo {
margin: 0em;
margin-top: 2em;
margin-bottom: 2em;
font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif !important;
color: #444444; }
table.docutils {
margin-top: 0.5em;
margin-bottom: 0.5em; }
table.footnote {
border-left: solid 1px #2d2d2d;
margin-left: 1px; }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em;
padding-right: 0.5em;
vertical-align: top; }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: 700;
text-align: left;
white-space: nowrap;
padding-left: 0; }
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100%; }
ul.auto-toc {
list-style-type: none; }
span.DecNumber {
color: #252dbe; }
span.BinNumber {
color: #252dbe; }
span.HexNumber {
color: #252dbe; }
span.OctNumber {
color: #252dbe; }
span.FloatNumber {
color: #252dbe; }
span.Identifier {
color: #3b3b3b; }
span.Keyword {
font-weight: 600;
color: #5e8f60; }
span.StringLit {
color: #a4255b; }
span.LongStringLit {
color: #a4255b; }
span.CharLit {
color: #a4255b; }
span.EscapeSequence {
color: black; }
span.Operator {
color: black; }
span.Punctuation {
color: black; }
span.Comment, span.LongComment {
font-style: italic;
font-weight: 400;
color: #484a86; }
span.RegularExpression {
color: darkviolet; }
span.TagStart {
color: darkviolet; }
span.TagEnd {
color: darkviolet; }
span.Key {
color: #252dbe; }
span.Value {
color: #252dbe; }
span.RawData {
color: #a4255b; }
span.Assembler {
color: #252dbe; }
span.Preprocessor {
color: #252dbe; }
span.Directive {
color: #252dbe; }
span.Command, span.Rule, span.Hyperlink, span.Label, span.Reference,
span.Other {
color: black; }
/* Pop type, const, proc, and iterator defs in nim def blocks */
dt pre > span.Identifier, dt pre > span.Operator {
color: #155da4;
font-weight: 700; }
dt pre > span.Identifier ~ span.Identifier, dt pre > span.Operator ~ span.Identifier {
color: inherit;
font-weight: inherit; }
dt pre > span.Operator ~ span.Identifier {
color: inherit;
font-weight: inherit; }
/* Nim sprite for the footer (taken from main page favicon) */
.nim-sprite {
display: inline-block;
height: 12px;
width: 12px;
background-position: 0 0;
background-size: 12px 12px;
-webkit-filter: opacity(50%);
background-repeat: no-repeat;
background-image: url("data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA==");
margin-bottom: -5px; }
div.search_results {
background-color: antiquewhite;
margin: 3em;
padding: 1em;
border: 1px solid #4d4d4d;
}
div#global-links ul {
margin-left: 0;
list-style-type: none;
}
span.pragmadots {
/* Position: relative frees us up to make the dots
look really nice without fucking up the layout and
causing bulging in the parent container */
position: relative;
/* 1px down looks slightly nicer */
top: 1px;
padding: 2px;
background-color: #D3D3D3;
border-radius: 4px;
margin: 0 2px;
cursor: pointer;
/* For some reason on Chrome, making the font size
smaller than 1em is causing the parent container to
bulge slightly. So, we're stuck with inheriting 1em,
which is sad, because 0.8em looks better... */
}
span.pragmadots:hover {
background-color: #DBDBDB;
}
span.pragmawrap {
display: none;
}
</style>
<script type="text/javascript" src="dochack.js"></script>
<script type="text/javascript">
function main() {
var pragmaDots = document.getElementsByClassName("pragmadots");
for (var i = 0; i < pragmaDots.length; i++) {
pragmaDots[i].onclick = function(event) {
// Hide tease
event.target.parentNode.style.display = "none";
// Show actual
event.target.parentNode.nextElementSibling.style.display = "inline";
}
}
}
</script>
</head>
<body onload="main()">
<div class="document" id="documentId">
<div class="container">
<h1 class="title">unittest2</h1>
<div class="row">
<div class="three columns">
<div id="global-links">
<ul class="simple">
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<ul class="simple simple-toc" id="toc-list">
<li><a class="reference" id="running-individual-tests_toc" href="#running-individual-tests">Running individual tests</a></li>
<li><a class="reference" id="running-a-single-test-suite_toc" href="#running-a-single-test-suite">Running a single test suite</a></li>
<li><a class="reference" id="selecting-tests-by-pattern_toc" href="#selecting-tests-by-pattern">Selecting tests by pattern</a></li>
<li><a class="reference" id="running-tests-in-parallel_toc" href="#running-tests-in-parallel">Running tests in parallel</a></li>
<ul class="simple"><li><a class="reference" id="running-tests-in-parallel-example_toc" href="#running-tests-in-parallel-example">Example</a></li>
</ul><li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#TestStatus"
title="TestStatus = enum
OK, FAILED, SKIPPED"><wbr />Test<wbr />Status<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#OutputLevel"
title="OutputLevel = enum
PRINT_ALL, ## Print as much as possible.
PRINT_FAILURES, ## Print only the failed tests.
PRINT_NONE ## Print nothing."><wbr />Output<wbr />Level<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#TestResult"
title="TestResult = object
suiteName*: string ## Name of the test suite that contains this test case.
## Can be ``nil`` if the test case is not in a suite.
testName*: string ## Name of the test case
status*: TestStatus"><wbr />Test<wbr />Result<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#OutputFormatter"
title="OutputFormatter = ref object of RootObj"><wbr />Output<wbr />Formatter<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#ConsoleOutputFormatter"
title="ConsoleOutputFormatter = ref object of OutputFormatter
colorOutput: bool ## Have test results printed in color.
## Default is true for the non-js target,
## for which ``stdout`` is a tty.
## Setting the environment variable
## ``NIMTEST_COLOR`` to ``always`` or
## ``never`` changes the default for the
## non-js target to true or false respectively.
## The deprecated environment variable
## ``NIMTEST_NO_COLOR``, when set,
## changes the defualt to true, if
## ``NIMTEST_COLOR`` is undefined.
outputLevel: OutputLevel ## Set the verbosity of test results.
## Default is ``PRINT_ALL``, unless
## the ``NIMTEST_OUTPUT_LVL`` environment
## variable is set for the non-js target.
isInSuite: bool
isInTest: bool"><wbr />Console<wbr />Output<wbr />Formatter<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#JUnitOutputFormatter"
title="JUnitOutputFormatter = ref object of OutputFormatter
stream: Stream
testErrors: seq[string]
testStartTime: float
testStackTrace: string"><wbr />JUnit<wbr />Output<wbr />Formatter<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#8" id="58">Vars</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#abortOnError"
title="abortOnError: bool"><wbr />abort<wbr />On<wbr />Error<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#10" id="60">Consts</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#paralleliseTests"
title="paralleliseTests = false"><wbr />parallelise<wbr />Tests<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#clearOutputFormatters%2C"
title="clearOutputFormatters()"><wbr />clear<wbr />Output<wbr />Formatters<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#addOutputFormatter%2COutputFormatter"
title="addOutputFormatter(formatter: OutputFormatter)"><wbr />add<wbr />Output<wbr />Formatter<span class="attachedType" style="visibility:hidden">OutputFormatter</span></a></li>
<li><a class="reference" href="#newConsoleOutputFormatter%2COutputLevel"
title="newConsoleOutputFormatter(outputLevel: OutputLevel = PRINT_ALL; colorOutput = true): ConsoleOutputFormatter"><wbr />new<wbr />Console<wbr />Output<wbr />Formatter<span class="attachedType" style="visibility:hidden">OutputLevel</span></a></li>
<li><a class="reference" href="#defaultConsoleFormatter%2C"
title="defaultConsoleFormatter(): ConsoleOutputFormatter"><wbr />default<wbr />Console<wbr />Formatter<span class="attachedType" style="visibility:hidden">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#newJUnitOutputFormatter%2CStream"
title="newJUnitOutputFormatter(stream: Stream): JUnitOutputFormatter"><wbr />new<wbr />JUnit<wbr />Output<wbr />Formatter<span class="attachedType" style="visibility:hidden">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#close%2CJUnitOutputFormatter"
title="close(formatter: JUnitOutputFormatter)"><wbr />close<span class="attachedType" style="visibility:hidden">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#checkpoint%2Cstring"
title="checkpoint(msg: string)"><wbr />checkpoint<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#disableParamFiltering%2C"
title="disableParamFiltering()"><wbr />disable<wbr />Param<wbr />Filtering<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#14" id="64">Methods</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#suiteStarted.e%2COutputFormatter%2Cstring"
title="suiteStarted(formatter: OutputFormatter; suiteName: string)"><wbr />suite<wbr />Started<span class="attachedType" style="visibility:hidden">OutputFormatter</span></a></li>
<li><a class="reference" href="#testStarted.e%2COutputFormatter%2Cstring"
title="testStarted(formatter: OutputFormatter; testName: string)"><wbr />test<wbr />Started<span class="attachedType" style="visibility:hidden">OutputFormatter</span></a></li>
<li><a class="reference" href="#failureOccurred.e%2COutputFormatter%2Cseq%5Bstring%5D%2Cstring"
title="failureOccurred(formatter: OutputFormatter; checkpoints: seq[string];
stackTrace: string)"><wbr />failure<wbr />Occurred<span class="attachedType" style="visibility:hidden">OutputFormatter</span></a></li>
<li><a class="reference" href="#testEnded.e%2COutputFormatter%2CTestResult"
title="testEnded(formatter: OutputFormatter; testResult: TestResult)"><wbr />test<wbr />Ended<span class="attachedType" style="visibility:hidden">OutputFormatter</span></a></li>
<li><a class="reference" href="#suiteEnded.e%2COutputFormatter"
title="suiteEnded(formatter: OutputFormatter)"><wbr />suite<wbr />Ended<span class="attachedType" style="visibility:hidden">OutputFormatter</span></a></li>
<li><a class="reference" href="#suiteStarted.e%2CConsoleOutputFormatter%2Cstring"
title="suiteStarted(formatter: ConsoleOutputFormatter; suiteName: string)"><wbr />suite<wbr />Started<span class="attachedType" style="visibility:hidden">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#testStarted.e%2CConsoleOutputFormatter%2Cstring"
title="testStarted(formatter: ConsoleOutputFormatter; testName: string)"><wbr />test<wbr />Started<span class="attachedType" style="visibility:hidden">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#failureOccurred.e%2CConsoleOutputFormatter%2Cseq%5Bstring%5D%2Cstring"
title="failureOccurred(formatter: ConsoleOutputFormatter; checkpoints: seq[string];
stackTrace: string)"><wbr />failure<wbr />Occurred<span class="attachedType" style="visibility:hidden">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#testEnded.e%2CConsoleOutputFormatter%2CTestResult"
title="testEnded(formatter: ConsoleOutputFormatter; testResult: TestResult)"><wbr />test<wbr />Ended<span class="attachedType" style="visibility:hidden">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#suiteEnded.e%2CConsoleOutputFormatter"
title="suiteEnded(formatter: ConsoleOutputFormatter)"><wbr />suite<wbr />Ended<span class="attachedType" style="visibility:hidden">ConsoleOutputFormatter</span></a></li>
<li><a class="reference" href="#suiteStarted.e%2CJUnitOutputFormatter%2Cstring"
title="suiteStarted(formatter: JUnitOutputFormatter; suiteName: string)"><wbr />suite<wbr />Started<span class="attachedType" style="visibility:hidden">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#testStarted.e%2CJUnitOutputFormatter%2Cstring"
title="testStarted(formatter: JUnitOutputFormatter; testName: string)"><wbr />test<wbr />Started<span class="attachedType" style="visibility:hidden">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#failureOccurred.e%2CJUnitOutputFormatter%2Cseq%5Bstring%5D%2Cstring"
title="failureOccurred(formatter: JUnitOutputFormatter; checkpoints: seq[string];
stackTrace: string)"><wbr />failure<wbr />Occurred<span class="attachedType" style="visibility:hidden">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#testEnded.e%2CJUnitOutputFormatter%2CTestResult"
title="testEnded(formatter: JUnitOutputFormatter; testResult: TestResult)"><wbr />test<wbr />Ended<span class="attachedType" style="visibility:hidden">JUnitOutputFormatter</span></a></li>
<li><a class="reference" href="#suiteEnded.e%2CJUnitOutputFormatter"
title="suiteEnded(formatter: JUnitOutputFormatter)"><wbr />suite<wbr />Ended<span class="attachedType" style="visibility:hidden">JUnitOutputFormatter</span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#17" id="67">Macros</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#check.m%2Cuntyped"
title="check(conditions: untyped): untyped"><wbr />check<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#expect.m%2Cvarargs%5Btyped%5D%2Cuntyped"
title="expect(exceptions: varargs[typed]; body: untyped): untyped"><wbr />expect<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#18" id="68">Templates</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#suite.t%2C%2C"
title="suite(name, body)"><wbr />suite<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#test.t%2C%2C"
title="test(name, body)"><wbr />test<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#fail.t%2C"
title="fail()"><wbr />fail<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#skip.t%2C"
title="skip()"><wbr />skip<span class="attachedType" style="visibility:hidden"></span></a></li>
<li><a class="reference" href="#require.t%2Cuntyped"
title="require(conditions: untyped)"><wbr />require<span class="attachedType" style="visibility:hidden"></span></a></li>
</ul>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc"><table class="docinfo" frame="void" rules="none"><col class="docinfo-name" /><col class="docinfo-content" /><tbody valign="top"><tr><th class="docinfo-name">Authors:</th><td> Zahary Karadjov, Ștefan Talpalaru</td></tr>
</tbody></table><p>This module implements boilerplate to make unit testing easy.</p>
<p>The test status and name is printed after any output or traceback.</p>
<p>Tests can be nested, however failure of a nested test will not mark the parent test as failed. Setup and teardown are inherited. Setup can be overridden locally.</p>
<p>Compiled test files return the number of failed test as exit code, while</p>
<pre class="listing">nim c -r testfile.nim</pre><p>exits with 0 or 1.</p>
<h1><a class="toc-backref" id="running-individual-tests" href="#running-individual-tests">Running individual tests</a></h1><p>Specify the test names as command line arguments.</p>
<pre class="listing">
nim c -r test &quot;my test name&quot; &quot;another test&quot;</pre><p>Multiple arguments can be used.</p>
<h1><a class="toc-backref" id="running-a-single-test-suite" href="#running-a-single-test-suite">Running a single test suite</a></h1><p>Specify the suite name delimited by <tt class="docutils literal"><span class="pre">&quot;::&quot;</span></tt>.</p>
<pre class="listing">
nim c -r test &quot;my suite name::&quot;</pre>
<h1><a class="toc-backref" id="selecting-tests-by-pattern" href="#selecting-tests-by-pattern">Selecting tests by pattern</a></h1><p>A single <tt class="docutils literal"><span class="pre">&quot;*&quot;</span></tt> can be used for globbing.</p>
<p>Delimit the end of a suite name with <tt class="docutils literal"><span class="pre">&quot;::&quot;</span></tt>.</p>
<p>Tests matching <strong>any</strong> of the arguments are executed.</p>
<pre class="listing">
nim c -r test fast_suite::mytest1 fast_suite::mytest2
nim c -r test &quot;fast_suite::mytest*&quot;
nim c -r test &quot;auth*::&quot; &quot;crypto::hashing*&quot;
# Run suites starting with 'bug #' and standalone tests starting with '#'
nim c -r test 'bug #*::' '::#*'</pre>
<h1><a class="toc-backref" id="running-tests-in-parallel" href="#running-tests-in-parallel">Running tests in parallel</a></h1><p>To enable the threadpool-based test parallelisation, &quot;--threads:on&quot; needs to be passed to the compiler, along with &quot;-d:nimtestParallel&quot; or the NIMTEST_PARALLEL environment variable:</p>
<pre class="listing">
nim c -r --threads:on -d:nimtestParallel testfile.nim
# or
NIMTEST_PARALLEL=1 nim c -r --threads:on testfile.nim</pre><p>There are some implicit barriers where we wait for all the spawned jobs to complete: before and after each test suite and at the main thread's exit.</p>
<p>The suite-related barriers are there to avoid mixing test output, but they also affect which groups of tests can be run in parallel, so keep them in mind when deciding how many tests to place in different suites (or between suites).</p>
<p>You may sometimes need to disable test parallelisation for a specific test, even though it was enabled in some configuration file in a parent dir. Do this with &quot;-d:nimtestParallelDisabled&quot; which overrides everything else.</p>
<h2><a class="toc-backref" id="running-tests-in-parallel-example" href="#running-tests-in-parallel-example">Example</a></h2><pre class="listing"><span class="Identifier">suite</span> <span class="StringLit">&quot;description for this stuff&quot;</span><span class="Punctuation">:</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;suite setup: run once before the tests&quot;</span>
<span class="Identifier">setup</span><span class="Punctuation">:</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;run before each test&quot;</span>
<span class="Identifier">teardown</span><span class="Punctuation">:</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;run after each test&quot;</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;essential truths&quot;</span><span class="Punctuation">:</span>
<span class="Comment"># give up and stop if this fails</span>
<span class="Identifier">require</span><span class="Punctuation">(</span><span class="Identifier">true</span><span class="Punctuation">)</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;slightly less obvious stuff&quot;</span><span class="Punctuation">:</span>
<span class="Comment"># print a nasty message and move on, skipping</span>
<span class="Comment"># the remainder of this block</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">!=</span> <span class="DecNumber">1</span><span class="Punctuation">)</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="StringLit">&quot;asd&quot;</span><span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="CharLit">'d'</span><span class="Punctuation">)</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;out of bounds error is thrown on bad access&quot;</span><span class="Punctuation">:</span>
<span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span> <span class="Comment"># you can do initialization here</span>
<span class="Identifier">expect</span><span class="Punctuation">(</span><span class="Identifier">IndexError</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
<span class="Keyword">discard</span> <span class="Identifier">v</span><span class="Punctuation">[</span><span class="DecNumber">4</span><span class="Punctuation">]</span>
<span class="Identifier">suiteTeardown</span><span class="Punctuation">:</span>
<span class="Identifier">echo</span> <span class="StringLit">&quot;suite teardown: run once after the tests&quot;</span></pre></p>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<a id="TestStatus"></a>
<dt><pre><a href="unittest2.html#TestStatus"><span class="Identifier">TestStatus</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">OK</span><span class="Other">,</span> <span class="Identifier">FAILED</span><span class="Other">,</span> <span class="Identifier">SKIPPED</span></pre></dt>
<dd>
The status of a test when it is done.
</dd>
<a id="OutputLevel"></a>
<dt><pre><a href="unittest2.html#OutputLevel"><span class="Identifier">OutputLevel</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">PRINT_ALL</span><span class="Other">,</span> <span class="Comment">## Print as much as possible.</span>
<span class="Identifier">PRINT_FAILURES</span><span class="Other">,</span> <span class="Comment">## Print only the failed tests.</span>
<span class="Identifier">PRINT_NONE</span> <span class="Comment">## Print nothing.</span></pre></dt>
<dd>
The output verbosity of the tests.
</dd>
<a id="TestResult"></a>
<dt><pre><a href="unittest2.html#TestResult"><span class="Identifier">TestResult</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">suiteName</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Comment">## Name of the test suite that contains this test case.</span>
<span class="Comment">## Can be ``nil`` if the test case is not in a suite.</span>
<span class="Identifier">testName</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Comment">## Name of the test case</span>
<span class="Identifier">status</span><span class="Operator">*</span><span class="Other">:</span> <a href="unittest2.html#TestStatus"><span class="Identifier">TestStatus</span></a>
</pre></dt>
<dd>
</dd>
<a id="OutputFormatter"></a>
<dt><pre><a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">RootObj</span></pre></dt>
<dd>
</dd>
<a id="ConsoleOutputFormatter"></a>
<dt><pre><a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a>
<span class="Identifier">colorOutput</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Comment">## Have test results printed in color.</span>
<span class="Comment">## Default is true for the non-js target,</span>
<span class="Comment">## for which ``stdout`` is a tty.</span>
<span class="Comment">## Setting the environment variable</span>
<span class="Comment">## ``NIMTEST_COLOR`` to ``always`` or</span>
<span class="Comment">## ``never`` changes the default for the</span>
<span class="Comment">## non-js target to true or false respectively.</span>
<span class="Comment">## The deprecated environment variable</span>
<span class="Comment">## ``NIMTEST_NO_COLOR``, when set,</span>
<span class="Comment">## changes the defualt to true, if</span>
<span class="Comment">## ``NIMTEST_COLOR`` is undefined.</span>
<span class="Identifier">outputLevel</span><span class="Other">:</span> <a href="unittest2.html#OutputLevel"><span class="Identifier">OutputLevel</span></a> <span class="Comment">## Set the verbosity of test results.</span>
<span class="Comment">## Default is ``PRINT_ALL``, unless</span>
<span class="Comment">## the ``NIMTEST_OUTPUT_LVL`` environment</span>
<span class="Comment">## variable is set for the non-js target.</span>
<span class="Identifier">isInSuite</span><span class="Other">:</span> <span class="Identifier">bool</span>
<span class="Identifier">isInTest</span><span class="Other">:</span> <span class="Identifier">bool</span>
</pre></dt>
<dd>
</dd>
<a id="JUnitOutputFormatter"></a>
<dt><pre><a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a>
<span class="Identifier">stream</span><span class="Other">:</span> <span class="Identifier">Stream</span>
<span class="Identifier">testErrors</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span>
<span class="Identifier">testStartTime</span><span class="Other">:</span> <span class="Identifier">float</span>
<span class="Identifier">testStackTrace</span><span class="Other">:</span> <span class="Identifier">string</span>
</pre></dt>
<dd>
</dd>
</dl></div>
<div class="section" id="8">
<h1><a class="toc-backref" href="#8">Vars</a></h1>
<dl class="item">
<a id="abortOnError"></a>
<dt><pre><span class="Identifier">abortOnError</span><span class="Other">:</span> <span class="Identifier">bool</span></pre></dt>
<dd>
Set to true in order to quit immediately on fail. Default is false, unless the <tt class="docutils literal"><span class="pre">NIMTEST_ABORT_ON_ERROR</span></tt> environment variable is set for the non-js target.
</dd>
</dl></div>
<div class="section" id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<a id="paralleliseTests"></a>
<dt><pre><span class="Identifier">paralleliseTests</span> <span class="Other">=</span> <span class="DecNumber">false</span></pre></dt>
<dd>
Whether parallel test running was enabled (set at compile time). This constant might be useful in custom output formatters.
</dd>
</dl></div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<a id="clearOutputFormatters,"></a>
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">clearOutputFormatters</span><span class="Other">(</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="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="addOutputFormatter,OutputFormatter"></a>
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">addOutputFormatter</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><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="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="newConsoleOutputFormatter,OutputLevel"></a>
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">newConsoleOutputFormatter</span><span class="Other">(</span><span class="Identifier">outputLevel</span><span class="Other">:</span> <a href="unittest2.html#OutputLevel"><span class="Identifier">OutputLevel</span></a> <span class="Other">=</span> <span class="Identifier">PRINT_ALL</span><span class="Other">;</span>
<span class="Identifier">colorOutput</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">)</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a> <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="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="defaultConsoleFormatter,"></a>
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">defaultConsoleFormatter</span><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a> <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="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="newJUnitOutputFormatter,Stream"></a>
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">newJUnitOutputFormatter</span><span class="Other">(</span><span class="Identifier">stream</span><span class="Other">:</span> <span class="Identifier">Stream</span><span class="Other">)</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a> <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">Exception</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>
Creates a formatter that writes report to the specified stream in JUnit format. The <tt class="docutils literal"><span class="pre">stream</span></tt> is NOT closed automatically when the test are finished, because the formatter has no way to know when all tests are finished. You should invoke formatter.close() to finalize the report.
</dd>
<a id="close,JUnitOutputFormatter"></a>
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">close</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><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">Exception</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>
Completes the report and closes the underlying stream.
</dd>
<a id="checkpoint,string"></a>
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">checkpoint</span><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <span class="Identifier">string</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="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Set a checkpoint identified by <cite>msg</cite>. Upon test failure all checkpoints encountered so far are printed out. Example:<pre class="listing"><span class="Identifier">checkpoint</span><span class="Punctuation">(</span><span class="StringLit">&quot;Checkpoint A&quot;</span><span class="Punctuation">)</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="StringLit">&quot;the Answer to life and everything&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">&quot;a&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
<span class="Identifier">checkpoint</span><span class="Punctuation">(</span><span class="StringLit">&quot;Checkpoint B&quot;</span><span class="Punctuation">)</span></pre><p>outputs &quot;Checkpoint A&quot; once it fails.</p>
</dd>
<a id="disableParamFiltering,"></a>
<dt><pre><span class="Keyword">proc</span> <span class="Identifier">disableParamFiltering</span><span class="Other">(</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="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
disables filtering tests with the command line params
</dd>
</dl></div>
<div class="section" id="14">
<h1><a class="toc-backref" href="#14">Methods</a></h1>
<dl class="item">
<a id="suiteStarted.e,OutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">suiteStarted</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">suiteName</span><span class="Other">:</span> <span class="Identifier">string</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">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span>
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="testStarted.e,OutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">testStarted</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testName</span><span class="Other">:</span> <span class="Identifier">string</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">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span>
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="failureOccurred.e,OutputFormatter,seq[string],string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">failureOccurred</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">checkpoints</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="Identifier">string</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">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<tt class="docutils literal"><span class="pre">stackTrace</span></tt> is provided only if the failure occurred due to an exception. <tt class="docutils literal"><span class="pre">checkpoints</span></tt> is never <tt class="docutils literal"><span class="pre">nil</span></tt>.
</dd>
<a id="testEnded.e,OutputFormatter,TestResult"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">testEnded</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testResult</span><span class="Other">:</span> <a href="unittest2.html#TestResult"><span class="Identifier">TestResult</span></a><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">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span>
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="suiteEnded.e,OutputFormatter"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">suiteEnded</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#OutputFormatter"><span class="Identifier">OutputFormatter</span></a><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">base</span><span class="Other">,</span> <span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="suiteStarted.e,ConsoleOutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">suiteStarted</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">suiteName</span><span class="Other">:</span> <span class="Identifier">string</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>
<dd>
</dd>
<a id="testStarted.e,ConsoleOutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">testStarted</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testName</span><span class="Other">:</span> <span class="Identifier">string</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="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="failureOccurred.e,ConsoleOutputFormatter,seq[string],string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">failureOccurred</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">checkpoints</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="Identifier">string</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="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="testEnded.e,ConsoleOutputFormatter,TestResult"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">testEnded</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testResult</span><span class="Other">:</span> <a href="unittest2.html#TestResult"><span class="Identifier">TestResult</span></a><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>
<dd>
</dd>
<a id="suiteEnded.e,ConsoleOutputFormatter"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">suiteEnded</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#ConsoleOutputFormatter"><span class="Identifier">ConsoleOutputFormatter</span></a><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="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="suiteStarted.e,JUnitOutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">suiteStarted</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">suiteName</span><span class="Other">:</span> <span class="Identifier">string</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">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</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>
</dd>
<a id="testStarted.e,JUnitOutputFormatter,string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">testStarted</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testName</span><span class="Other">:</span> <span class="Identifier">string</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="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">TimeEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="failureOccurred.e,JUnitOutputFormatter,seq[string],string"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">failureOccurred</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">checkpoints</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">;</span>
<span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="Identifier">string</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="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<tt class="docutils literal"><span class="pre">stackTrace</span></tt> is provided only if the failure occurred due to an exception. <tt class="docutils literal"><span class="pre">checkpoints</span></tt> is never <tt class="docutils literal"><span class="pre">nil</span></tt>.
</dd>
<a id="testEnded.e,JUnitOutputFormatter,TestResult"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">testEnded</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><span class="Other">;</span> <span class="Identifier">testResult</span><span class="Other">:</span> <a href="unittest2.html#TestResult"><span class="Identifier">TestResult</span></a><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">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</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">TimeEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="suiteEnded.e,JUnitOutputFormatter"></a>
<dt><pre><span class="Keyword">method</span> <span class="Identifier">suiteEnded</span><span class="Other">(</span><span class="Identifier">formatter</span><span class="Other">:</span> <a href="unittest2.html#JUnitOutputFormatter"><span class="Identifier">JUnitOutputFormatter</span></a><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">Exception</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>
</dd>
</dl></div>
<div class="section" id="17">
<h1><a class="toc-backref" href="#17">Macros</a></h1>
<dl class="item">
<a id="check.m,untyped"></a>
<dt><pre><span class="Keyword">macro</span> <span class="Identifier">check</span><span class="Other">(</span><span class="Identifier">conditions</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
Verify if a statement or a list of statements is true. A helpful error message and set checkpoints are printed out on failure (if <tt class="docutils literal"><span class="pre">outputLevel</span></tt> is not <tt class="docutils literal"><span class="pre">PRINT_NONE</span></tt>). Example:<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">strutils</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="StringLit">&quot;AKB48&quot;</span><span class="Operator">.</span><span class="Identifier">toLowerAscii</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;akb48&quot;</span><span class="Punctuation">)</span>
<span class="Keyword">let</span> <span class="Identifier">teams</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="CharLit">'A'</span><span class="Punctuation">,</span> <span class="CharLit">'K'</span><span class="Punctuation">,</span> <span class="CharLit">'B'</span><span class="Punctuation">,</span> <span class="CharLit">'4'</span><span class="Punctuation">,</span> <span class="CharLit">'8'</span><span class="Punctuation">}</span>
<span class="Identifier">check</span><span class="Punctuation">:</span>
<span class="StringLit">&quot;AKB48&quot;</span><span class="Operator">.</span><span class="Identifier">toLowerAscii</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;akb48&quot;</span>
<span class="CharLit">'C'</span> <span class="Keyword">in</span> <span class="Identifier">teams</span></pre>
</dd>
<a id="expect.m,varargs[typed],untyped"></a>
<dt><pre><span class="Keyword">macro</span> <span class="Identifier">expect</span><span class="Other">(</span><span class="Identifier">exceptions</span><span class="Other">:</span> <span class="Identifier">varargs</span><span class="Other">[</span><span class="Identifier">typed</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">body</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
<dd>
Test if <cite>body</cite> raises an exception found in the passed <cite>exceptions</cite>. The test passes if the raised exception is part of the acceptable exceptions. Otherwise, it fails. Example:<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">math</span><span class="Punctuation">,</span> <span class="Identifier">random</span>
<span class="Keyword">proc</span> <span class="Identifier">defectiveRobot</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">=</span>
<span class="Identifier">randomize</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
<span class="Keyword">case</span> <span class="Identifier">random</span><span class="Punctuation">(</span><span class="FloatNumber">1.</span><span class="Operator">.</span><span class="DecNumber">4</span><span class="Punctuation">)</span>
<span class="Keyword">of</span> <span class="DecNumber">1</span><span class="Punctuation">:</span> <span class="Keyword">raise</span> <span class="Identifier">newException</span><span class="Punctuation">(</span><span class="Identifier">OSError</span><span class="Punctuation">,</span> <span class="StringLit">&quot;CANNOT COMPUTE!&quot;</span><span class="Punctuation">)</span>
<span class="Keyword">of</span> <span class="DecNumber">2</span><span class="Punctuation">:</span> <span class="Keyword">discard</span> <span class="Identifier">parseInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World!&quot;</span><span class="Punctuation">)</span>
<span class="Keyword">of</span> <span class="DecNumber">3</span><span class="Punctuation">:</span> <span class="Keyword">raise</span> <span class="Identifier">newException</span><span class="Punctuation">(</span><span class="Identifier">IOError</span><span class="Punctuation">,</span> <span class="StringLit">&quot;I can't do that Dave.&quot;</span><span class="Punctuation">)</span>
<span class="Keyword">else</span><span class="Punctuation">:</span> <span class="Identifier">assert</span> <span class="DecNumber">2</span> <span class="Operator">+</span> <span class="DecNumber">2</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
<span class="Identifier">expect</span> <span class="Identifier">IOError</span><span class="Punctuation">,</span> <span class="Identifier">OSError</span><span class="Punctuation">,</span> <span class="Identifier">ValueError</span><span class="Punctuation">,</span> <span class="Identifier">AssertionError</span><span class="Punctuation">:</span>
<span class="Identifier">defectiveRobot</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre>
</dd>
</dl></div>
<div class="section" id="18">
<h1><a class="toc-backref" href="#18">Templates</a></h1>
<dl class="item">
<a id="suite.t,,"></a>
<dt><pre><span class="Keyword">template</span> <span class="Identifier">suite</span><span class="Other">(</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">body</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">dirty</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
<p>Declare a test suite identified by <cite>name</cite> with optional <tt class="docutils literal"><span class="pre">setup</span></tt> and/or <tt class="docutils literal"><span class="pre">teardown</span></tt> section.</p>
<p>A test suite is a series of one or more related tests sharing a common fixture (<tt class="docutils literal"><span class="pre">setup</span></tt>, <tt class="docutils literal"><span class="pre">teardown</span></tt>). The fixture is executed for EACH test.</p>
<pre class="listing"><span class="Identifier">suite</span> <span class="StringLit">&quot;test suite for addition&quot;</span><span class="Punctuation">:</span>
<span class="Identifier">setup</span><span class="Punctuation">:</span>
<span class="Keyword">let</span> <span class="Identifier">result</span> <span class="Operator">=</span> <span class="DecNumber">4</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;2 + 2 = 4&quot;</span><span class="Punctuation">:</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Operator">+</span><span class="DecNumber">2</span> <span class="Operator">==</span> <span class="Identifier">result</span><span class="Punctuation">)</span>
<span class="Identifier">test</span> <span class="StringLit">&quot;(2 + -2) != 4&quot;</span><span class="Punctuation">:</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="DecNumber">2</span> <span class="Operator">+</span> <span class="Operator">-</span><span class="DecNumber">2</span> <span class="Operator">!=</span> <span class="Identifier">result</span><span class="Punctuation">)</span>
<span class="Comment"># No teardown needed</span></pre><p>The suite will run the individual test cases in the order in which they were listed. With default global settings the above code prints:</p>
<pre class="listing"><span class="Punctuation">[</span><span class="Identifier">Suite</span><span class="Punctuation">]</span> <span class="Identifier">test</span> <span class="Identifier">suite</span> <span class="Keyword">for</span> <span class="Identifier">addition</span>
<span class="Punctuation">[</span><span class="Identifier">OK</span><span class="Punctuation">]</span> <span class="DecNumber">2</span> <span class="Operator">+</span> <span class="DecNumber">2</span> <span class="Operator">=</span> <span class="DecNumber">4</span>
<span class="Punctuation">[</span><span class="Identifier">OK</span><span class="Punctuation">]</span> <span class="Punctuation">(</span><span class="DecNumber">2</span> <span class="Operator">+</span> <span class="Operator">-</span><span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">!=</span> <span class="DecNumber">4</span></pre>
</dd>
<a id="test.t,,"></a>
<dt><pre><span class="Keyword">template</span> <span class="Identifier">test</span><span class="Other">(</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">body</span><span class="Other">)</span></pre></dt>
<dd>
Define a single test case identified by <cite>name</cite>.<pre class="listing"><span class="Identifier">test</span> <span class="StringLit">&quot;roses are red&quot;</span><span class="Punctuation">:</span>
<span class="Keyword">let</span> <span class="Identifier">roses</span> <span class="Operator">=</span> <span class="StringLit">&quot;red&quot;</span>
<span class="Identifier">check</span><span class="Punctuation">(</span><span class="Identifier">roses</span> <span class="Operator">==</span> <span class="StringLit">&quot;red&quot;</span><span class="Punctuation">)</span></pre><p>The above code outputs:</p>
<pre class="listing"><span class="Punctuation">[</span><span class="Identifier">OK</span><span class="Punctuation">]</span> <span class="Identifier">roses</span> <span class="Identifier">are</span> <span class="Identifier">red</span></pre>
</dd>
<a id="fail.t,"></a>
<dt><pre><span class="Keyword">template</span> <span class="Identifier">fail</span><span class="Other">(</span><span class="Other">)</span></pre></dt>
<dd>
Print out the checkpoints encountered so far and quit if <tt class="docutils literal"><span class="pre">abortOnError</span></tt> is true. Otherwise, erase the checkpoints and indicate the test has failed (change exit code and test status). This template is useful for debugging, but is otherwise mostly used internally. Example:<pre class="listing"><span class="Identifier">checkpoint</span><span class="Punctuation">(</span><span class="StringLit">&quot;Checkpoint A&quot;</span><span class="Punctuation">)</span>
<span class="Identifier">complicatedProcInThread</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
<span class="Identifier">fail</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre><p>outputs &quot;Checkpoint A&quot; before quitting.</p>
</dd>
<a id="skip.t,"></a>
<dt><pre><span class="Keyword">template</span> <span class="Identifier">skip</span><span class="Other">(</span><span class="Other">)</span></pre></dt>
<dd>
Mark the test as skipped. Should be used directly in case when it is not possible to perform test for reasons depending on outer environment, or certain application logic conditions or configurations. The test code is still executed.<pre class="listing"><span class="Keyword">if</span> <span class="Keyword">not</span> <span class="Identifier">isGLConextCreated</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
<span class="Identifier">skip</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre>
</dd>
<a id="require.t,untyped"></a>
<dt><pre><span class="Keyword">template</span> <span class="Identifier">require</span><span class="Other">(</span><span class="Identifier">conditions</span><span class="Other">:</span> <span class="Identifier">untyped</span><span class="Other">)</span></pre></dt>
<dd>
Same as <cite>check</cite> except any failed test causes the program to quit immediately. Any teardown statements are not executed and the failed test output is not generated.
</dd>
</dl></div>
</div>
</div>
<div class="row">
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small>Made with Nim. Generated: 2019-05-29 14:32:15 UTC</small>
</div>
</div>
</div>
</div>
</body>
</html>