diff options
author | Simon Hafner <hafnersimon@gmail.com> | 2015-06-15 08:34:11 -0500 |
---|---|---|
committer | Simon Hafner <hafnersimon@gmail.com> | 2015-06-15 08:34:11 -0500 |
commit | 8618530413d68df7fbf8c16ab76d8ef63114f3e2 (patch) | |
tree | d2c7b3d7653997aa307b9897c27da27bb0c5f250 | |
parent | d4dd332c8d1767f411e2bed88b320aa698cbd396 (diff) | |
download | Nim-8618530413d68df7fbf8c16ab76d8ef63114f3e2.tar.gz |
switched over from assert to doAssert for guide
-rw-r--r-- | contributing.md | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/contributing.md b/contributing.md index 9c589ae49..123fd5668 100644 --- a/contributing.md +++ b/contributing.md @@ -33,28 +33,19 @@ If you change the stdlib (anything under `lib/`), put a test in the file you changed. Add the tests under an `when isMainModule:` condition so they only get executed when the tester is building the file. Each test should be in a separate `block:` statement, such that -each has its own scope. Use boolean conditions and `assert` for the +each has its own scope. Use boolean conditions and `doAssert` for the testing by itself, don't rely on echo statements or similar. Sample test: ```nim when isMainModule: - block lenTest: - var values: HashSet[int] - assert(not values.isValid) - assert values.len == 0 - assert values.card == 0 - block setIterator: - type pair = tuple[a, b: int] - var a, b = initSet[pair]() - a.incl((2, 3)) - a.incl((3, 2)) - a.incl((2, 3)) - for x, y in a.items: - b.incl((x - 2, y + 1)) - assert a.len == b.card - assert a.len == 2 + block: # newSeqWith tests + var seq2D = newSeqWith(4, newSeq[bool](2)) + seq2D[0][0] = true + seq2D[1][0] = true + seq2D[0][1] = true + doAssert seq2D == @[@[true, true], @[true, false], @[false, false], @[false, false]] ``` ## Compiler |