diff options
author | Celeo <mattboulanger@fastmail.com> | 2020-10-15 14:54:13 -0700 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2020-10-16 08:56:36 +0200 |
commit | b83716f0ebc211924dbb11bcabcbba88373c9085 (patch) | |
tree | e8f382138e410cb38a1018988690724c8eb0ae86 | |
parent | 6872a4dd7f972721fe9b9698ca9fc5612b197890 (diff) |
feat: add Nim syntax test file
-rw-r--r-- | tests/syntax-tests/highlighted/nim/main.nim | 41 | ||||
-rw-r--r-- | tests/syntax-tests/source/nim/main.nim | 41 |
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 @@ +[38;2;249;38;114mimport[0m[38;2;248;248;242m json[0m + +[38;2;249;38;114mconst[0m +[38;2;248;248;242m message = [0m[38;2;230;219;116m"hello world"[0m +[38;2;248;248;242m multiLine = [0m[38;2;230;219;116m"""[0m +[38;2;230;219;116m foo[0m +[38;2;230;219;116m bar[0m +[38;2;230;219;116m """[0m +[38;2;248;248;242m numbers = @[[0m[38;2;190;132;255m1[0m[38;2;248;248;242m, [0m[38;2;190;132;255m2[0m[38;2;248;248;242m, [0m[38;2;190;132;255m3[0m[38;2;248;248;242m][0m + +[38;2;249;38;114mtype[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mOptions[0m[38;2;248;248;242m = [0m[38;2;249;38;114menum[0m +[38;2;248;248;242m A,[0m +[38;2;248;248;242m B,[0m +[38;2;248;248;242m C[0m + +[38;2;117;113;94m## [0m[38;2;117;113;94mTop-level comment[0m +[38;2;249;38;114mtype[0m +[38;2;248;248;242m [0m[3;38;2;166;226;46mSomeStruct[0m[38;2;248;248;242m* = [0m[38;2;249;38;114mref[0m[38;2;248;248;242m [0m[38;2;249;38;114mobject[0m +[38;2;248;248;242m value*: [0m[3;38;2;102;217;239mstring[0m + +[3;38;2;102;217;239mproc[0m[38;2;248;248;242m someFunc*(): [0m[3;38;2;102;217;239mstring[0m[38;2;248;248;242m =[0m +[38;2;248;248;242m [0m[38;2;117;113;94m## [0m[38;2;117;113;94mFunction docs[0m +[38;2;248;248;242m [0m[38;2;117;113;94m##[0m +[38;2;248;248;242m [0m[38;2;117;113;94m## [0m[38;2;117;113;94mMore docs[0m +[38;2;248;248;242m result = message[0m + +[3;38;2;102;217;239mproc[0m[38;2;248;248;242m [0m[38;2;102;217;239msomeOtherFunc[0m[38;2;248;248;242m(startingValue: [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m): ([0m[3;38;2;102;217;239mstring[0m[38;2;248;248;242m, [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m) =[0m +[38;2;248;248;242m [0m[38;2;249;38;114mvar[0m[38;2;248;248;242m num = startingValue[0m +[38;2;248;248;242m num += [0m[38;2;190;132;255m1[0m +[38;2;248;248;242m [0m[38;2;249;38;114mif[0m[38;2;248;248;242m num > [0m[38;2;190;132;255m10[0m[38;2;248;248;242m * [0m[38;2;190;132;255m10[0m[38;2;248;248;242m * [0m[38;2;190;132;255m10[0m[38;2;248;248;242m:[0m +[38;2;248;248;242m [0m[38;2;249;38;114mecho[0m[38;2;248;248;242m [0m[38;2;230;219;116m"Encountered an error"[0m +[38;2;248;248;242m [0m[38;2;249;38;114mraise[0m[38;2;248;248;242m [0m[38;2;249;38;114mnewException[0m[38;2;248;248;242m([0m[3;38;2;166;226;46mValueError[0m[38;2;248;248;242m, [0m[38;2;230;219;116m"Value was over 1000"[0m[38;2;248;248;242m)[0m +[38;2;248;248;242m ([0m[38;2;230;219;116m"Fizz"[0m[38;2;248;248;242m, num)[0m + +[3;38;2;102;217;239mproc[0m[38;2;248;248;242m `+=[0m[38;2;102;217;239m`[0m[38;2;248;248;242m(a: [0m[38;2;249;38;114mvar[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mSomeStruct[0m[38;2;248;248;242m, b: [0m[3;38;2;166;226;46mSomeStruct[0m[38;2;248;248;242m)[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mstring[0m[38;2;248;248;242m =[0m +[38;2;248;248;242m a.value.[0m[38;2;102;217;239madd[0m[38;2;248;248;242m(b.value)[0m +[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m a.value[0m + +[38;2;249;38;114mecho[0m[38;2;248;248;242m [0m[38;2;102;217;239msomeFunc[0m[38;2;248;248;242m()[0m +[38;2;249;38;114mecho[0m[38;2;248;248;242m([0m[38;2;102;217;239msomeOtherFunc[0m[38;2;248;248;242m([0m[38;2;190;132;255m123[0m[38;2;248;248;242m))[0m +[38;2;249;38;114mdiscard[0m[38;2;248;248;242m [0m[38;2;102;217;239msomeFunc[0m[38;2;248;248;242m()[0m 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() |