diff options
author | metagn <metagngn@gmail.com> | 2023-06-06 07:54:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-06 06:54:07 +0200 |
commit | b97d603cd00a210547bda1a2a1c3e09f97fcc49e (patch) | |
tree | 080b4ad7b5826b88a9483c6a0e4d697096f12cc1 /tests/init | |
parent | 2ab948ce53e3d9b80bf9b02644c8ec8991f34d0a (diff) | |
download | Nim-b97d603cd00a210547bda1a2a1c3e09f97fcc49e.tar.gz |
some test cleanups & category reorganization (#22010)
* clean up some test categories * mention exact slice issue * magics into system * move trangechecks into overflow * move tmemory to system * try fix CI * try fix CI * final CI fix
Diffstat (limited to 'tests/init')
-rw-r--r-- | tests/init/tinitchecks_v2.nim | 24 | ||||
-rw-r--r-- | tests/init/tproveinit.nim | 18 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/init/tinitchecks_v2.nim b/tests/init/tinitchecks_v2.nim index 4a8cda028..f7716bcca 100644 --- a/tests/init/tinitchecks_v2.nim +++ b/tests/init/tinitchecks_v2.nim @@ -57,3 +57,27 @@ proc currentlyValid(x: out int; y: out string; cond: bool) = y = "abc" # <-- error: not every path initializes 'y' currentlyValid gl, gs, false + +block: # previously effects/toutparam + proc gah[T](x: out T) = + x = 3 + + proc arr1 = + var a: array[2, int] + var x: int + gah(x) + a[0] = 3 + a[x] = 3 + echo x + + arr1() + + proc arr2 = + var a: array[2, int] + var x: int + a[0] = 3 + a[x] = 3 #[tt.Warning + ^ use explicit initialization of 'x' for clarity [Uninit] ]# + echo x + + arr2() diff --git a/tests/init/tproveinit.nim b/tests/init/tproveinit.nim new file mode 100644 index 000000000..c9f688309 --- /dev/null +++ b/tests/init/tproveinit.nim @@ -0,0 +1,18 @@ +discard """ + joinable: false +""" + +{.warningAsError[ProveInit]:on.} +template main() = + proc fn(): var int = + discard + discard fn() +doAssert not compiles(main()) + +# bug #9901 +import std/[sequtils, times] +proc parseMyDates(line: string): DateTime = + result = parse(line, "yyyy-MM-dd") +var dateStrings = @["2018-12-01", "2018-12-02", "2018-12-03"] +var parsed = dateStrings.map(parseMyDates) +discard parsed |