summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCeleo <mattboulanger@fastmail.com>2020-10-15 14:54:13 -0700
committerDavid Peter <sharkdp@users.noreply.github.com>2020-10-16 08:56:36 +0200
commitb83716f0ebc211924dbb11bcabcbba88373c9085 (patch)
treee8f382138e410cb38a1018988690724c8eb0ae86
parent6872a4dd7f972721fe9b9698ca9fc5612b197890 (diff)
feat: add Nim syntax test file
-rw-r--r--tests/syntax-tests/highlighted/nim/main.nim41
-rw-r--r--tests/syntax-tests/source/nim/main.nim41
2 files changed, 82 insertions, 0 deletions
diff --git a/tests/syntax-tests/highlighted/nim/main.nim b/tests/syntax-tests/highlighted/nim/main.nim
new file mode 100644
index 00000000..044c2590
--- /dev/null
+++ b/tests/syntax-tests/highlighted/nim/main.nim
@@ -0,0 +1,41 @@
+import json
+
+const
+ message = "hello world"
+ multiLine = """
+ foo
+ bar
+ """
+ numbers = @[1, 2, 3]
+
+type Options = enum
+ A,
+ B,
+ C
+
+## Top-level comment
+type
+ SomeStruct* = ref object
+ value*: string
+
+proc someFunc*(): string =
+ ## Function docs
+ ##
+ ## More docs
+ result = message
+
+proc someOtherFunc(startingValue: int): (string, int) =
+ var num = startingValue
+ num += 1
+ if num > 10 * 10 * 10:
+ echo "Encountered an error"
+ raise newException(ValueError, "Value was over 1000")
+ ("Fizz", num)
+
+proc `+=`(a: var SomeStruct, b: SomeStruct): string =
+ a.value.add(b.value)
+ return a.value
+
+echo someFunc()
+echo(someOtherFunc(123))
+discard someFunc()
diff --git a/tests/syntax-tests/source/nim/main.nim b/tests/syntax-tests/source/nim/main.nim
new file mode 100644
index 00000000..5fa7a598
--- /dev/null
+++ b/tests/syntax-tests/source/nim/main.nim
@@ -0,0 +1,41 @@
+import json
+
+const
+ message = "hello world"
+ multiLine = """
+ foo
+ bar
+ """
+ numbers = @[1, 2, 3]
+
+type Options = enum
+ A,
+ B,
+ C
+
+## Top-level comment
+type
+ SomeStruct* = ref object
+ value*: string
+
+proc someFunc*(): string =
+ ## Function docs
+ ##
+ ## More docs
+ result = message
+
+proc someOtherFunc(startingValue: int): (string, int) =
+ var num = startingValue
+ num += 1
+ if num > 10 * 10 * 10:
+ echo "Encountered an error"
+ raise newException(ValueError, "Value was over 1000")
+ ("Fizz", num)
+
+proc `+=`(a: var SomeStruct, b: SomeStruct): string =
+ a.value.add(b.value)
+ return a.value
+
+echo someFunc()
+echo(someOtherFunc(123))
+discard someFunc()