diff options
Diffstat (limited to 'tests/modules')
23 files changed, 133 insertions, 9 deletions
diff --git a/tests/modules/a/module_name_clashes.nim b/tests/modules/a/module_name_clashes.nim new file mode 100644 index 000000000..209526e22 --- /dev/null +++ b/tests/modules/a/module_name_clashes.nim @@ -0,0 +1,8 @@ +# See `tmodule_name_clashes` + +import ../b/module_name_clashes +type A* = object + b*: B + +proc print*(a: A) = + echo repr a diff --git a/tests/modules/a/utils.nim b/tests/modules/a/utils.nim new file mode 100644 index 000000000..f37abfb93 --- /dev/null +++ b/tests/modules/a/utils.nim @@ -0,0 +1,2 @@ +proc burnMem*(a: int) = + discard diff --git a/tests/modules/b/module_name_clashes.nim b/tests/modules/b/module_name_clashes.nim new file mode 100644 index 000000000..6a10cac33 --- /dev/null +++ b/tests/modules/b/module_name_clashes.nim @@ -0,0 +1,3 @@ +# See `tmodule_name_clashes` + +type B* = object diff --git a/tests/modules/b/utils.nim b/tests/modules/b/utils.nim new file mode 100644 index 000000000..e343385f5 --- /dev/null +++ b/tests/modules/b/utils.nim @@ -0,0 +1,2 @@ +# module b/utils.nim +let x* = 10 diff --git a/tests/modules/mforwarded_pure_enum.nim b/tests/modules/mforwarded_pure_enum.nim new file mode 100644 index 000000000..3f03390a5 --- /dev/null +++ b/tests/modules/mforwarded_pure_enum.nim @@ -0,0 +1,3 @@ + +import mforwarded_pure_enum2 +export mforwarded_pure_enum2.PureEnum diff --git a/tests/modules/mforwarded_pure_enum2.nim b/tests/modules/mforwarded_pure_enum2.nim new file mode 100644 index 000000000..e5d5d2a71 --- /dev/null +++ b/tests/modules/mforwarded_pure_enum2.nim @@ -0,0 +1,4 @@ + +type + PureEnum* {.pure.} = enum + x, y, z diff --git a/tests/modules/mincludeprefix.nim b/tests/modules/mincludeprefix.nim new file mode 100644 index 000000000..6d557a430 --- /dev/null +++ b/tests/modules/mincludeprefix.nim @@ -0,0 +1 @@ +const bar = 456 diff --git a/tests/modules/mincludetemplate.nim b/tests/modules/mincludetemplate.nim new file mode 100644 index 000000000..febe9bfcf --- /dev/null +++ b/tests/modules/mincludetemplate.nim @@ -0,0 +1 @@ +const foo = 123 diff --git a/tests/modules/seq.nim b/tests/modules/seq.nim new file mode 100644 index 000000000..176e44025 --- /dev/null +++ b/tests/modules/seq.nim @@ -0,0 +1,5 @@ +var seq: seq[int] +var b: seq[float] + +echo seq +echo b diff --git a/tests/modules/texplicit_system_import.nim b/tests/modules/texplicit_system_import.nim index bc4d018bf..0a4cedc71 100644 --- a/tests/modules/texplicit_system_import.nim +++ b/tests/modules/texplicit_system_import.nim @@ -1,9 +1,9 @@ -##. import system except `+` + discard """ errormsg: "undeclared identifier: '+'" line: 9 """ -# Testament requires that the initial """ occurs before the 40th byte -# in the file. No kidding... + + echo 4+5 diff --git a/tests/modules/tfowarded_pure_enum.nim b/tests/modules/tfowarded_pure_enum.nim new file mode 100644 index 000000000..1d2c4f342 --- /dev/null +++ b/tests/modules/tfowarded_pure_enum.nim @@ -0,0 +1,7 @@ +discard """ + output: '''z''' +""" + +import mforwarded_pure_enum as t2 + +echo z diff --git a/tests/modules/timportas.nim b/tests/modules/timportas.nim index 2f7bf7f6a..179613c6b 100644 --- a/tests/modules/timportas.nim +++ b/tests/modules/timportas.nim @@ -2,15 +2,20 @@ discard """ action: run """ -import .. / modules / [definitions as foo] -import .. / modules / definitions as foo +import .. / modules / [mexporta as a1, definitions as foo1] +import .. / modules / definitions as foo2 +import ./[mexporta as a2, definitions as foo3] import std / times as bar from times as bar2 import nil import times as bar3 except convert import definitions as baz -discard foo.v +discard foo1.v +discard foo2.v +discard foo3.v discard bar.now() discard bar2.now() discard bar3.now() discard baz.v +discard a1.xyz +discard a2.xyz diff --git a/tests/modules/tincludeas.nim b/tests/modules/tincludeas.nim new file mode 100644 index 000000000..b82e38b14 --- /dev/null +++ b/tests/modules/tincludeas.nim @@ -0,0 +1,6 @@ +discard """ + errormsg: "Cannot use 'as' in 'include'." + line: 6 +""" + +include foobar as foo diff --git a/tests/modules/tincludeprefix.nim b/tests/modules/tincludeprefix.nim new file mode 100644 index 000000000..d45a6eff3 --- /dev/null +++ b/tests/modules/tincludeprefix.nim @@ -0,0 +1,3 @@ +include ./[mincludeprefix, mincludetemplate] +doAssert foo == 123 +doAssert bar == 456 diff --git a/tests/modules/tincludetemplate.nim b/tests/modules/tincludetemplate.nim new file mode 100644 index 000000000..77e409ee5 --- /dev/null +++ b/tests/modules/tincludetemplate.nim @@ -0,0 +1,5 @@ +# issue #12539 + +template includePath(n: untyped) = include ../modules/n # But `include n` works +includePath(mincludetemplate) +doAssert foo == 123 diff --git a/tests/modules/tmismatchedvisibility.nim b/tests/modules/tmismatchedvisibility.nim index a61b28071..b649a5a3e 100644 --- a/tests/modules/tmismatchedvisibility.nim +++ b/tests/modules/tmismatchedvisibility.nim @@ -1,5 +1,5 @@ discard """ - errormsg: "public implementation 'tmismatchedvisibility.foo(a: int) [declared in tmismatchedvisibility.nim(6, 6)]' has non-public forward declaration in " + errormsg: "public implementation 'tmismatchedvisibility.foo(a: int)' has non-public forward declaration at " line: 8 """ diff --git a/tests/modules/tmodule_name_clashes.nim b/tests/modules/tmodule_name_clashes.nim new file mode 100644 index 000000000..814d5d152 --- /dev/null +++ b/tests/modules/tmodule_name_clashes.nim @@ -0,0 +1,17 @@ +discard """ +matrix: "--mm:refc" +targets: "c" +ccodecheck: "\\i @('atmaatsmodule_name_clashesdotnim_DatInit000')" +ccodecheck: "\\i @('atmbatsmodule_name_clashesdotnim_DatInit000')" +joinable: false +""" + +# Test module name clashes within same package. +# This was created to test that module symbol mangling functioned correctly +# for the C backend when there are one or more modules with the same name in +# a package, and more than one of them require module initialization procs. +# I'm not sure of the simplest method to cause the init procs to be generated. + +import a/module_name_clashes + +print A() diff --git a/tests/modules/tmodulesymtype.nim b/tests/modules/tmodulesymtype.nim new file mode 100644 index 000000000..d17c4cca4 --- /dev/null +++ b/tests/modules/tmodulesymtype.nim @@ -0,0 +1,22 @@ +discard """ +cmd: "nim check $file" +""" + +# bug #19225 +import std/sequtils +sequtils #[tt.Error +^ expression has no type: sequtils]# +proc foo() = + block: #[tt.Error + ^ expression has no type: block: + sequtils]# + sequtils + +foo() + +# issue #23399 +when isMainModule: + sequtils #[tt.Error + ^ expression has no type: sequtils]# + +discard diff --git a/tests/modules/treorder.nim b/tests/modules/treorder.nim index c81715cd8..ff0b2e071 100644 --- a/tests/modules/treorder.nim +++ b/tests/modules/treorder.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nim -d:testdef $target $file" + matrix: "-d:testdef" output: '''works 34 34 defined @@ -8,6 +8,8 @@ defined {.experimental: "codeReordering".} +{.push callconv: stdcall.} + proc bar(x: T) proc foo() = @@ -41,3 +43,5 @@ using my, omy: int goo(3, 4) + +{.pop.} diff --git a/tests/modules/tselfimport.nim b/tests/modules/tselfimport.nim index 7e50bef7c..ba5d9b4cf 100644 --- a/tests/modules/tselfimport.nim +++ b/tests/modules/tselfimport.nim @@ -1,5 +1,5 @@ discard """ - errormsg: "A module cannot import itself" + errormsg: "module 'tselfimport' cannot import itself" file: "tselfimport.nim" line: 7 """ diff --git a/tests/modules/tseq.nim b/tests/modules/tseq.nim new file mode 100644 index 000000000..22ee48f42 --- /dev/null +++ b/tests/modules/tseq.nim @@ -0,0 +1,8 @@ +discard """ + joinable: false + output: '''@[] +@[] +''' +""" + +import seq diff --git a/tests/modules/tstrutils_insert_sep.nim b/tests/modules/tstrutils_insert_sep.nim new file mode 100644 index 000000000..775fe7da1 --- /dev/null +++ b/tests/modules/tstrutils_insert_sep.nim @@ -0,0 +1,13 @@ +discard """ + output: ''' +-100 +-100,000 +100,000 +''' +""" +# test https://github.com/nim-lang/Nim/issues/11352 + +import strutils +echo insertSep($(-100), ',') +echo insertSep($(-100_000), ',') +echo insertSep($(100_000), ',') \ No newline at end of file diff --git a/tests/modules/tutils_ab.nim b/tests/modules/tutils_ab.nim new file mode 100644 index 000000000..25bd08f3c --- /dev/null +++ b/tests/modules/tutils_ab.nim @@ -0,0 +1,5 @@ +import a/utils as autils, b/utils + +# bug #12420 + +burnMem(x) |