import subdir / subdir_b / utils ## This is the top level module. runnableExamples: import subdir / subdir_b / utils doAssert bar(3, 4) == 7 foo(enumValueA, enumValueB) # bug #11078 for x in "xx": discard var someVariable*: bool ## This should be visible. when true: ## top2 runnableExamples: discard "in top2" ## top2 after runnableExamples: discard "in top3" ## top3 after const C_A* = 0x7FF0000000000000'f64 C_B* = 0o377'i8 C_C* = 0o277'i8 C_D* = 0o177777'i16 proc bar*[T](a, b: T): T = result = a + b proc baz*[T](a, b: T): T {.deprecated.} = ## This is deprecated without message. result = a + b proc buzz*[T](a, b: T): T {.deprecated: "since v0.20".} = ## This is deprecated with a message. result = a + b type FooBuzz* {.deprecated: "FooBuzz msg".} = int import std/macros var aVariable*: array[1, int] # bug #9432 aEnum() bEnum() fromUtilsGen() proc isValid*[T](x: T): bool = x.len > 0 when true: # these cases appear redundant but they're actually (almost) all different at # AST level and needed to ensure docgen keeps working, e.g. because of issues # like D20200526T163511 type Foo* = enum enumValueA2 proc z1*(): Foo = ## cz1 Foo.default proc z2*() = ## cz2 runnableExamples: discard "in cz2" proc z3*() = ## cz3 proc z4*() = ## cz4 discard when true: # tests for D20200526T163511 proc z5*(): int = ## cz5 return 1 proc z6*(): int = ## cz6 1 template z6t*(): int = ## cz6t 1 proc z7*(): int = ## cz7 result = 1 proc z8*(): int = ## cz8 block: discard 1+1 when true: # interleaving 0 or more runnableExamples and doc comments, issue #9227 proc z9*() = runnableExamples: doAssert 1 + 1 == 2 proc z10*() = runnableExamples "-d:foobar": discard 1 ## cz10 proc z11*() = runnableExamples: discard 1 discard proc z12*(): int = runnableExamples: discard 1 12 proc z13*() = ## cz13 runnableExamples: discard proc baz*() = discard proc bazNonExported() = ## out (not exported) runnableExamples: # BUG: this currently this won't be run since not exported # but probably should doAssert false if false: bazNonExported() # silence XDeclaredButNotUsed proc z17*() = # BUG: a comment before 1st doc comment currently doesn't prevent # doc comment from being docgen'd; probably should be fixed ## cz17 ## rest runnableExamples: discard 1 ## rest # this comment separates docgen'd doc comments ## out when true: # capture non-doc comments correctly even before 1st token proc p1*() = ## cp1 runnableExamples: doAssert 1 == 1 # regular comments work here ## c4 runnableExamples: # 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 # this should be out when true: # issue #14485 proc addfBug14485*() = ## Some proc runnableExamples: discard "foo() = " & $[1] #[ 0: let's also add some broken html to make sure this won't break in future 1: 2: 3: 5: ", varargs, discardable.} ## the c printf. ## etc. proc c_nonexistent*(frmt: cstring): cint {.importc: "nonexistent", header: "", varargs, discardable.} when true: # tests RST inside comments 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: ## * `low2(T) <#low2,T>`_ ## ## .. code-block:: Nim ## 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: ## * `low(T) <#low,T>`_ ## ## .. code-block:: Nim ## low2(2) # => -9223372036854775808 runnableExamples: discard "in low2" when true: # multiline string litterals proc tripleStrLitTest*() = runnableExamples("--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 # should be out when true: # methods; issue #14691 type Moo = object method method1*(self: Moo) {.base.} = ## foo1 method method2*(self: Moo): int {.base.} = ## foo2 result = 1 method method3*(self: Moo): int {.base.} = ## foo3 1 when true: # iterators iterator iter1*(n: int): int = ## foo1 for i in 0..