summary refs log tree commit diff stats
path: root/tests/modules
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/a/module_name_clashes.nim8
-rw-r--r--tests/modules/b/module_name_clashes.nim3
-rw-r--r--tests/modules/mforwarded_pure_enum.nim3
-rw-r--r--tests/modules/mforwarded_pure_enum2.nim4
-rw-r--r--tests/modules/mincludeprefix.nim1
-rw-r--r--tests/modules/mincludetemplate.nim1
-rw-r--r--tests/modules/texplicit_system_import.nim6
-rw-r--r--tests/modules/tfowarded_pure_enum.nim7
-rw-r--r--tests/modules/timportas.nim11
-rw-r--r--tests/modules/tincludeprefix.nim3
-rw-r--r--tests/modules/tincludetemplate.nim5
-rw-r--r--tests/modules/tmodule_name_clashes.nim17
-rw-r--r--tests/modules/tmodulesymtype.nim22
-rw-r--r--tests/modules/treorder.nim6
-rw-r--r--tests/modules/tselfimport.nim2
-rw-r--r--tests/modules/tstrutils_insert_sep.nim13
16 files changed, 104 insertions, 8 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/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/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/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/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/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/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