testproject

This is the top level module.

Example:

import testproject
import subdir / subdir_b / utils
doAssert bar(3, 4) == 7
foo(enumValueA, enumValueB)
# bug #11078
for x in "xx": discard
top2

Example:

import testproject
discard "in top2"
top2 after

Example:

import testproject
discard "in top3"
top3 after

Types

FooBuzz {....deprecated: "FooBuzz msg".} = int
Deprecated: FooBuzz msg
A {.inject.} = enum
  aA
The enum A.
B {.inject.} = enum
  bB
The enum B.
Foo = enum
  enumValueA2
Shapes = enum
  Circle,                   ## A circle
  Triangle,                 ## A three-sided shape
  Rectangle                  ## A four-sided shape
Some shapes.

Vars

someVariable: bool
This should be visible.
aVariable: array[1, int]

Consts

C_A = 0x7FF0000000000000'f64
C_B = 0o377'i8
C_C = 0o277'i8
C_D = 0o177777'i16

Procs

proc bar[T](a, b: T): T
proc baz[T](a, b: T): T {....deprecated.}
Deprecated
This is deprecated without message.
proc buzz[T](a, b: T): T {....deprecated: "since v0.20".}
Deprecated: since v0.20
This is deprecated with a message.
func someFunc() {....raises: [], tags: [].}
My someFunc. Stuff in quotes here. Some link
proc fromUtils3() {....raises: [], tags: [].}
came form utils but should be shown where fromUtilsGen is called

Example:

discard """should be shown as examples for fromUtils3
       in module calling fromUtilsGen"""
proc isValid[T](x: T): bool
proc z1(): Foo {....raises: [], tags: [].}
cz1
proc z2() {....raises: [], tags: [].}
cz2

Example:

discard "in cz2"
proc z3() {....raises: [], tags: [].}
cz3
proc z4() {....raises: [], tags: [].}
cz4
proc z5(): int {....raises: [], tags: [].}
cz5
proc z6(): int {....raises: [], tags: [].}
cz6
proc z7(): int {....raises: [], tags: [].}
cz7
proc z8(): int {....raises: [], tags: [].}
cz8
proc z9() {....raises: [], tags: [].}

Example:

doAssert 1 + 1 == 2
proc z10() {....raises: [], tags: [].}

Example: cmd: -d:foobar

discard 1
cz10
proc z11() {....raises: [], tags: [].}

Example:

discard 1
proc z12(): int {....raises: [], tags: [].}

Example:

discard 1
proc z13() {....raises: [], tags: [].}
cz13

Example:

discard
proc baz() {....raises: [], tags: [].}
proc z17() {....raises: [], tags: [].}
cz17 rest

Example:

discard 1
rest
proc p1() {....raises: [], tags: [].}
cp1

Example:

doAssert 1 == 1 # regular comments work here
c4

Example:

# c5 regular comments before 1st token work
# regular comment
#[
nested regular comment
]#
doAssert 2 == 2 # c8
## this is a non-nested doc comment

##[
this is a nested doc comment
]##
discard "c9"
# also work after
proc addfBug14485() {....raises: [], tags: [].}
Some proc

Example:

discard "foo() = " & $[1]
#[
0: let's also add some broken html to make sure this won't break in future
1: </span>
2: </span>
3: </span
4: </script>
5: </script
6: </script
7: end of broken html
]#
proc c_printf(frmt: cstring): cint {.importc: "printf", header: "<stdio.h>",
                                     varargs, discardable.}
the c printf. etc.
proc c_nonexistent(frmt: cstring): cint {.importc: "nonexistent",
    header: "<stdio.h>", varargs, discardable.}
proc low[T: Ordinal | enum | range](x: T): T {.magic: "Low", noSideEffect.}

Returns the lowest possible value of an ordinal value x. As a special semantic rule, x may also be a type identifier.

See also:

low(2) # => -9223372036854775808
proc low2[T: Ordinal | enum | range](x: T): T {.magic: "Low", noSideEffect.}

Returns the lowest possible value of an ordinal value x. As a special semantic rule, x may also be a type identifier.

See also:

low2(2) # => -9223372036854775808

Example:

discard "in low2"
proc tripleStrLitTest() {....raises: [], tags: [].}

Example: cmd: --hint:XDeclaredButNotUsed:off

## mullitline string litterals are tricky as their indentation can span
## below that of the runnableExamples
let s1a = """
should appear at indent 0
  at indent 2
at indent 0
"""
# make sure this works too
let s1b = """start at same line
  at indent 2
at indent 0
""" # comment after
let s2 = """sandwich """
let s3 = """"""
when false:
  let s5 = """
        in s5 """

let s3b = ["""
%!? #[...] # inside a multiline ...
""", "foo"]

## make sure handles trailing spaces
let s4 = """ 
"""

let s5 = """ x
"""
let s6 = """ ""
"""
let s7 = """"""""""
let s8 = ["""""""""", """
  """ ]
discard
# should be in
proc asyncFun1(): Future[int] {....raises: [Exception, ValueError],
                                tags: [RootEffect].}
ok1
proc asyncFun2(): owned(Future[void]) {....raises: [Exception], tags: [RootEffect].}
proc asyncFun3(): owned(Future[void]) {....raises: [Exception], tags: [RootEffect].}

Example:

discard
ok1
proc anything() {....raises: [], tags: [].}
There is no block quote after blank lines at the beginning.

Methods

method method1(self: Moo) {.base, ...raises: [], tags: [].}
foo1
method method2(self: Moo): int {.base, ...raises: [], tags: [].}
foo2
method method3(self: Moo): int {.base, ...raises: [], tags: [].}
foo3

Iterators

iterator fromUtils1(): int {....raises: [], tags: [].}

Example:

# ok1
assert 1 == 1
# ok2
iterator iter1(n: int): int {....raises: [], tags: [].}
foo1
iterator iter2(n: int): int {....raises: [], tags: [].}
foo2

Example:

discard # bar

Macros

macro bar(): untyped
macro z16()

Example:

discard 1
cz16 after

Example:

doAssert 2 == 1 + 1
macro z18(): int
cz18

Templates

template fromUtils2()
ok3

Example:

discard """should be shown as examples for fromUtils2
       in module calling fromUtilsGen"""
template z6t(): int
cz6t
template foo(a, b: SomeType)
This does nothing
template myfn()

Example:

import std/strutils
## issue #8871 preserve formatting
## line doc comment
# bar
doAssert "'foo" == "'foo"
##[
foo
bar
]##

doAssert: not "foo".startsWith "ba"
block:
  discard 0xff # elu par cette crapule
# should be in
should be still in
template z14()
cz14

Example:

discard
template z15()
cz15

Example:

discard

Example:

discard 3

Example:

discard 4
ok5 ok5b

Example:

assert true

Example:

discard 1
in or out?
template testNimDocTrailingExample()

Example:

discard 2