summary refs log tree commit diff stats
path: root/tests/lexer
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lexer')
-rw-r--r--tests/lexer/nim.cfg1
-rw-r--r--tests/lexer/tcustom_numeric_literals.nim38
-rw-r--r--tests/lexer/tlexerspaces.nim2
-rw-r--r--tests/lexer/trawstr.nim10
-rw-r--r--tests/lexer/tunary_minus.nim4
5 files changed, 30 insertions, 25 deletions
diff --git a/tests/lexer/nim.cfg b/tests/lexer/nim.cfg
deleted file mode 100644
index f7a301a10..000000000
--- a/tests/lexer/nim.cfg
+++ /dev/null
@@ -1 +0,0 @@
---experimental:unicodeOperators
diff --git a/tests/lexer/tcustom_numeric_literals.nim b/tests/lexer/tcustom_numeric_literals.nim
index 9c49d0c08..35b4803d3 100644
--- a/tests/lexer/tcustom_numeric_literals.nim
+++ b/tests/lexer/tcustom_numeric_literals.nim
@@ -134,17 +134,14 @@ template main =
 
   block: # bug 1 from https://github.com/nim-lang/Nim/pull/17020#issuecomment-803193947
     macro deb1(a): untyped = newLit a.repr
-    macro deb2(a): untyped = newLit a.lispRepr
+    macro deb2(a): untyped =
+      a[1] = ident($a[1])
+      newLit a.lispRepr
     doAssert deb1(-12'wrap) == "-12'wrap"
     doAssert deb1(-12'nonexistent) == "-12'nonexistent"
     doAssert deb2(-12'nonexistent) == """(DotExpr (RStrLit "-12") (Ident "\'nonexistent"))"""
-    when false: # xxx bug:
-      # this holds:
-      doAssert deb2(-12.wrap2) == """(DotExpr (IntLit -12) (Sym "wrap2"))"""
-      doAssert deb2(-12'wrap) == """(DotExpr (RStrLit "-12") (Sym "\'wrap"))"""
-      # but instead this should hold:
-      doAssert deb2(-12.wrap2) == """(DotExpr (IntLit -12) (Ident "wrap2"))"""
-      doAssert deb2(-12'wrap) == """(DotExpr (RStrLit "-12") (Ident "\'wrap"))"""
+    doAssert deb2(-12.wrap2) == """(DotExpr (IntLit -12) (Ident "wrap2"))"""
+    doAssert deb2(-12'wrap) == """(DotExpr (RStrLit "-12") (Ident "\'wrap"))"""
 
   block: # bug 2 from https://github.com/nim-lang/Nim/pull/17020#issuecomment-803193947
     template toSuf(`'suf`): untyped =
@@ -165,21 +162,16 @@ template main =
     doAssert fn2() == "[[-12]]"
     doAssert fn3() == "[[-12]]"
 
-    when false: # xxx this fails; bug 9 from https://github.com/nim-lang/Nim/pull/17020#issuecomment-803193947
-      #[
-      possible workaround: use `genAst` (https://github.com/nim-lang/Nim/pull/17426) and this:
-      let a3 = `'wrap3`("-128")
-      ]#
-      block:
-        macro metawrap(): untyped =
-          func wrap1(a: string): string = "{" & a & "}"
-          func `'wrap3`(a: string): string = "{" & a & "}"
-          result = quote do:
-            let a1 = wrap1"-128"
-            let a2 = -128'wrap3
-        metawrap()
-        doAssert a1 == "{-128}"
-        doAssert a2 == "{-128}"
+    block: # bug 9 from https://github.com/nim-lang/Nim/pull/17020#issuecomment-803193947
+      macro metawrap(): untyped =
+        func wrap1(a: string): string = "{" & a & "}"
+        func `'wrap3`(a: string): string = "{" & a & "}"
+        result = quote do:
+          let a1 {.inject.} = wrap1"-128"
+          let a2 {.inject.} = -128'wrap3
+      metawrap()
+      doAssert a1 == "{-128}"
+      doAssert a2 == "{-128}"
 
 static: main()
 main()
diff --git a/tests/lexer/tlexerspaces.nim b/tests/lexer/tlexerspaces.nim
new file mode 100644
index 000000000..14b16111d
--- /dev/null
+++ b/tests/lexer/tlexerspaces.nim
@@ -0,0 +1,2 @@
+discard 12 +                                                                                                                                                                                                                                                                           5
+discard 12 + 5                                                                                                                        
diff --git a/tests/lexer/trawstr.nim b/tests/lexer/trawstr.nim
new file mode 100644
index 000000000..aa41071d5
--- /dev/null
+++ b/tests/lexer/trawstr.nim
@@ -0,0 +1,10 @@
+discard """
+  errormsg: "closing \" expected"
+  file: "trawstr.nim"
+  line: 10
+"""
+# Test the new raw strings:
+
+const
+  xxx = r"This is a raw string!"
+  yyy = "This not\" #ERROR
diff --git a/tests/lexer/tunary_minus.nim b/tests/lexer/tunary_minus.nim
index 1641e918c..5ec2b5c70 100644
--- a/tests/lexer/tunary_minus.nim
+++ b/tests/lexer/tunary_minus.nim
@@ -5,6 +5,7 @@ discard """
 # Test numeric literals and handling of minus symbol
 
 import std/[macros, strutils]
+import std/private/jsutils
 
 import mlexerutils
 
@@ -60,7 +61,8 @@ template main =
     doAssert -2147483648'i32 == int32.low
     when int.sizeof > 4:
       doAssert -9223372036854775808 == int.low
-    when not defined(js):
+    whenJsNoBigInt64: discard
+    do:
       doAssert -9223372036854775808 == int64.low
 
   block: # check when a minus (-) is an unary op