on master help sign in
feat: add Nim syntax test file
commitb83716f0ebc211924dbb11bcabcbba88373c9085 authorCeleo <mattboulanger@fastmail.com> dateThu 15 Oct 2020, 14:54 (6 years ago) parent6872a4d
2 files changed+82
tests/syntax-tests/highlighted/nim/main.nim+41 tests/syntax-tests/source/nim/main.nim+41
tests/syntax-tests/highlighted/nim/main.nimnew file+41
@@ -0,0 +1,41 @@
1+import json
2+
3+const
4+ message = "hello world"
5+ multiLine = """
6+ foo
7+ bar
8+ """
9+ numbers = @[1, 2, 3]
10+
11+type Options = enum
12+ A,
13+ B,
14+ C
15+
16+## Top-level comment
17+type
18+ SomeStruct* = ref object
19+ value*: string
20+
21+proc someFunc*(): string =
22+ ## Function docs
23+ ##
24+ ## More docs
25+ result = message
26+
27+proc someOtherFunc(startingValue: int): (string, int) =
28+ var num = startingValue
29+ num += 1
30+ if num > 10 * 10 * 10:
31+ echo "Encountered an error"
32+ raise newException(ValueError, "Value was over 1000")
33+ ("Fizz", num)
34+
35+proc `+=`(a: var SomeStruct, b: SomeStruct): string =
36+ a.value.add(b.value)
37+ return a.value
38+
39+echo someFunc()
40+echo(someOtherFunc(123))
41+discard someFunc()
tests/syntax-tests/source/nim/main.nimnew file+41
@@ -0,0 +1,41 @@
1+import json
2+
3+const
4+ message = "hello world"
5+ multiLine = """
6+ foo
7+ bar
8+ """
9+ numbers = @[1, 2, 3]
10+
11+type Options = enum
12+ A,
13+ B,
14+ C
15+
16+## Top-level comment
17+type
18+ SomeStruct* = ref object
19+ value*: string
20+
21+proc someFunc*(): string =
22+ ## Function docs
23+ ##
24+ ## More docs
25+ result = message
26+
27+proc someOtherFunc(startingValue: int): (string, int) =
28+ var num = startingValue
29+ num += 1
30+ if num > 10 * 10 * 10:
31+ echo "Encountered an error"
32+ raise newException(ValueError, "Value was over 1000")
33+ ("Fizz", num)
34+
35+proc `+=`(a: var SomeStruct, b: SomeStruct): string =
36+ a.value.add(b.value)
37+ return a.value
38+
39+echo someFunc()
40+echo(someOtherFunc(123))
41+discard someFunc()