mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
test(tiger): import upstream tests
This commit is contained in:
parent
ef385991b6
commit
6e3f888dc7
16 changed files with 454 additions and 0 deletions
14
tests/indent/tiger/classes.tig
Normal file
14
tests/indent/tiger/classes.tig
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class A {
|
||||
var a := 12
|
||||
|
||||
method method() : int = 1
|
||||
}
|
||||
|
||||
type B = class extends A {
|
||||
var b := 27
|
||||
|
||||
method another_method() = (
|
||||
print("called");
|
||||
self.b + self.method()
|
||||
)
|
||||
}
|
||||
22
tests/indent/tiger/control-flow.tig
Normal file
22
tests/indent/tiger/control-flow.tig
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(
|
||||
if
|
||||
12
|
||||
then
|
||||
27
|
||||
else
|
||||
42
|
||||
;
|
||||
|
||||
for
|
||||
i := 12
|
||||
to
|
||||
27
|
||||
do
|
||||
42
|
||||
;
|
||||
|
||||
while
|
||||
0
|
||||
do
|
||||
break
|
||||
)
|
||||
14
tests/indent/tiger/functions.tig
Normal file
14
tests/indent/tiger/functions.tig
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
primitive long_parameter_list(
|
||||
a: int,
|
||||
b: string,
|
||||
c: type
|
||||
)
|
||||
|
||||
function f() =
|
||||
(
|
||||
long_parameter_list(
|
||||
1,
|
||||
"2",
|
||||
nil
|
||||
)
|
||||
)
|
||||
10
tests/indent/tiger/groupings.tig
Normal file
10
tests/indent/tiger/groupings.tig
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
let
|
||||
var a := 42
|
||||
in
|
||||
(
|
||||
12;
|
||||
27;
|
||||
42
|
||||
);
|
||||
a
|
||||
end
|
||||
30
tests/indent/tiger/values-and-expressions.tig
Normal file
30
tests/indent/tiger/values-and-expressions.tig
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
let
|
||||
type array_of_int = array of int
|
||||
|
||||
type record = {
|
||||
a: int,
|
||||
b: string,
|
||||
c: type
|
||||
}
|
||||
|
||||
var a :=
|
||||
"a string"
|
||||
in
|
||||
array[
|
||||
12
|
||||
]
|
||||
;
|
||||
|
||||
array_of_int[
|
||||
27
|
||||
]
|
||||
of
|
||||
42
|
||||
;
|
||||
|
||||
record {
|
||||
a = 1,
|
||||
b = "2",
|
||||
c = nil
|
||||
}
|
||||
end
|
||||
138
tests/indent/tiger_spec.lua
Normal file
138
tests/indent/tiger_spec.lua
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
local Runner = require("tests.indent.common").Runner
|
||||
local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
local runner = Runner:new(it, "tests/indent/tiger", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent Tiger:", function()
|
||||
describe("whole file:", function()
|
||||
runner:whole_file "."
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
runner:new_line(
|
||||
"classes.tig",
|
||||
{ on_line = 1, text = "var a := 0", indent = 2 },
|
||||
"class declaration beginning",
|
||||
XFAIL
|
||||
)
|
||||
runner:new_line("classes.tig", { on_line = 2, text = "var a := 0", indent = 2 }, "class declaration after field")
|
||||
runner:new_line("classes.tig", { on_line = 4, text = "var a := 0", indent = 2 }, "class declaration after method")
|
||||
runner:new_line("classes.tig", { on_line = 5, text = "var a := 0", indent = 0 }, "after class declaration")
|
||||
runner:new_line("classes.tig", { on_line = 7, text = "var a := 0", indent = 2 }, "class type beginning", XFAIL)
|
||||
runner:new_line("classes.tig", { on_line = 8, text = "var a := 0", indent = 2 }, "class type after field")
|
||||
runner:new_line("classes.tig", { on_line = 10, text = "self.a := 0", indent = 4 }, "inside method", XFAIL)
|
||||
runner:new_line("classes.tig", { on_line = 13, text = "var a := 0", indent = 2 }, "class type after method")
|
||||
runner:new_line("classes.tig", { on_line = 14, text = "var a := 0", indent = 0 }, "after class type")
|
||||
|
||||
runner:new_line("control-flow.tig", { on_line = 2, text = "true", indent = 4 }, "if condition", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 4, text = "true", indent = 4 }, "if consequence", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 4, text = "true", indent = 4 }, "if alternative", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 10, text = "start := 0", indent = 4 }, "for index start", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 12, text = "the_end", indent = 4 }, "for index end", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 14, text = "break", indent = 4 }, "for body", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 18, text = "true", indent = 4 }, "while condition", XFAIL)
|
||||
runner:new_line("control-flow.tig", { on_line = 20, text = "break", indent = 4 }, "while body", XFAIL)
|
||||
|
||||
runner:new_line(
|
||||
"functions.tig",
|
||||
{ on_line = 1, text = "parameter: int,", indent = 2 },
|
||||
"parameter list beginning",
|
||||
XFAIL
|
||||
)
|
||||
runner:new_line("functions.tig", { on_line = 2, text = "parameter: int,", indent = 2 }, "parameter list middle")
|
||||
runner:new_line("functions.tig", { on_line = 4, text = ",parameter: int", indent = 2 }, "parameter list end")
|
||||
runner:new_line("functions.tig", { on_line = 5, text = "var a := 0", indent = 0 }, "after parameter list")
|
||||
runner:new_line("functions.tig", { on_line = 7, text = "print(a)", indent = 2 }, "function body", XFAIL)
|
||||
runner:new_line("functions.tig", { on_line = 9, text = "a,", indent = 6 }, "function call beginning", XFAIL)
|
||||
runner:new_line("functions.tig", { on_line = 10, text = "a,", indent = 6 }, "function call middle")
|
||||
runner:new_line("functions.tig", { on_line = 12, text = ",a", indent = 6 }, "function call end")
|
||||
runner:new_line("functions.tig", { on_line = 13, text = "; print(a)", indent = 4 }, "after function call")
|
||||
runner:new_line(
|
||||
"functions.tig",
|
||||
{ on_line = 14, text = "var a := 12", indent = 0 },
|
||||
"after function declaration",
|
||||
XFAIL
|
||||
)
|
||||
|
||||
runner:new_line("groupings.tig", { on_line = 2, text = "var b := 0", indent = 2 }, "let declarations")
|
||||
runner:new_line("groupings.tig", { on_line = 3, text = "a := a + 1", indent = 2 }, "after 'in'", XFAIL)
|
||||
runner:new_line("groupings.tig", { on_line = 4, text = "a := a + 1;", indent = 4 }, "sequence", XFAIL)
|
||||
runner:new_line("groupings.tig", { on_line = 8, text = "a := a + 1;", indent = 2 }, "after sequence")
|
||||
runner:new_line("groupings.tig", { on_line = 10, text = "+ 1", indent = 0 }, "after 'end'")
|
||||
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 4, text = "field: record,", indent = 4 },
|
||||
"record type beginning",
|
||||
XFAIL
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 5, text = "field: record,", indent = 4 },
|
||||
"record type middle"
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 7, text = ",field: record", indent = 4 },
|
||||
"record type end"
|
||||
)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 8, text = "var a := 0", indent = 2 }, "after record type")
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 10, text = "0", indent = 4 },
|
||||
"variable declaration init value",
|
||||
XFAIL
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 11, text = "+ a", indent = 4 },
|
||||
"variable declaration init follow-up"
|
||||
)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 13, text = "a", indent = 4 }, "array index", XFAIL)
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 14, text = "+ a", indent = 4 }, "array index follow-up")
|
||||
runner:new_line("values-and-expressions.tig", { on_line = 15, text = "+ a", indent = 2 }, "after array value")
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 18, text = "a", indent = 4 },
|
||||
"array expression size",
|
||||
XFAIL
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 20, text = "of", indent = 2 },
|
||||
"array expression after size"
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 21, text = "a", indent = 4 },
|
||||
"array expression init value",
|
||||
XFAIL
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 25, text = "field = 0,", indent = 4 },
|
||||
"record expression beginning",
|
||||
XFAIL
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 26, text = "field = 0,", indent = 4 },
|
||||
"record expression middle"
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 28, text = ",field = 0", indent = 4 },
|
||||
"record expression end"
|
||||
)
|
||||
runner:new_line(
|
||||
"values-and-expressions.tig",
|
||||
{ on_line = 29, text = "a := 0", indent = 2 },
|
||||
"after record expression"
|
||||
)
|
||||
end)
|
||||
end)
|
||||
43
tests/query/highlights/tiger/built-ins.tig
Normal file
43
tests/query/highlights/tiger/built-ins.tig
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
let
|
||||
var a := exit(0)
|
||||
/* ^ function.builtin */
|
||||
|
||||
primitive exit(ret: int) /* Shadowing the prelude-included built-in */
|
||||
/* ^ type.builtin */
|
||||
|
||||
var b := exit(0)
|
||||
/* ^ function */
|
||||
|
||||
type int = string /* Shadowing the built-in type */
|
||||
/* ^ type.builtin */
|
||||
|
||||
var c : int := "This is an \"int\""
|
||||
/* ^ type.builtin (not sure why it isn't 'type')*/
|
||||
|
||||
var d : Object := nil
|
||||
/* ^ type.builtin */
|
||||
|
||||
type Object = int
|
||||
|
||||
var self := "self"
|
||||
in
|
||||
let
|
||||
var c : int := "This is an int"
|
||||
/* ^ type.builtin (not sure why it isn't 'type')*/
|
||||
var d : Object := "This is an object"
|
||||
/* ^ type.builtin (not sure why it isn't 'type')*/
|
||||
in
|
||||
end;
|
||||
|
||||
exit(1);
|
||||
/* <- function */
|
||||
|
||||
print("shadowing is fun");
|
||||
/* <- function.builtin */
|
||||
|
||||
self;
|
||||
/* <- variable */
|
||||
|
||||
b := print
|
||||
/* ^ variable */
|
||||
end
|
||||
5
tests/query/highlights/tiger/comment.tig
Normal file
5
tests/query/highlights/tiger/comment.tig
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/* This is /* a nested */ comment */
|
||||
/* <- comment
|
||||
^ comment
|
||||
^ comment
|
||||
*/
|
||||
8
tests/query/highlights/tiger/functions.tig
Normal file
8
tests/query/highlights/tiger/functions.tig
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
primitive print(s: string)
|
||||
/* ^ function */
|
||||
/* ^ variable.parameter */
|
||||
|
||||
function func(a: int) : int = (print("Hello World!"); a)
|
||||
/* ^ function */
|
||||
/* ^ variable.parameter */
|
||||
/* ^ function */
|
||||
29
tests/query/highlights/tiger/identifiers.tig
Normal file
29
tests/query/highlights/tiger/identifiers.tig
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
type int = int
|
||||
/* ^ variable */
|
||||
/* ^ type.builtin */
|
||||
|
||||
type int_array = array of int
|
||||
/* ^ type.builtin */
|
||||
|
||||
type record = {a: int, b: string}
|
||||
/* ^ property */
|
||||
/* ^ type.builtin */
|
||||
/* ^ property */
|
||||
/* ^ type.builtin */
|
||||
|
||||
var record := record {a = 12, b = "27"}
|
||||
/* ^ variable */
|
||||
/* ^ type */
|
||||
/* ^ property */
|
||||
/* ^ property */
|
||||
|
||||
var array := int_array[12] of 27;
|
||||
/* ^ variable */
|
||||
/* ^ type */
|
||||
|
||||
primitive func(a: int, b: string) : array
|
||||
/* ^ variable.parameter */
|
||||
/* ^ type.builtin */
|
||||
/* ^ variable.parameter */
|
||||
/* ^ type.builtin */
|
||||
/* ^ type */
|
||||
3
tests/query/highlights/tiger/imports.tig
Normal file
3
tests/query/highlights/tiger/imports.tig
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import "lib.tih"
|
||||
/* <- keyword */
|
||||
/* ^ string.special.path */
|
||||
41
tests/query/highlights/tiger/keywords.tig
Normal file
41
tests/query/highlights/tiger/keywords.tig
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
let
|
||||
/* <- keyword */
|
||||
|
||||
var a := 12
|
||||
/* <- keyword */
|
||||
|
||||
function f() : int = a
|
||||
/* <- keyword.function */
|
||||
primitive g()
|
||||
/* <- keyword.function */
|
||||
|
||||
import "lib.tih"
|
||||
/* <- keyword */
|
||||
|
||||
type array_of_int = array of int
|
||||
/* <- keyword */
|
||||
/* ^ keyword */
|
||||
/* ^ keyword */
|
||||
|
||||
in
|
||||
/* <- keyword */
|
||||
|
||||
12;
|
||||
|
||||
if 12 then 27 else 42;
|
||||
/* <- keyword */
|
||||
/* ^ keyword */
|
||||
/* ^ keyword */
|
||||
|
||||
for i := 12 to 27 do 42;
|
||||
/* <- keyword.repeat */
|
||||
/* ^ keyword.repeat */
|
||||
/* ^ keyword.repeat */
|
||||
|
||||
while 12 do break
|
||||
/* <- keyword.repeat */
|
||||
/* ^ keyword.repeat */
|
||||
/* ^ keyword */
|
||||
|
||||
end
|
||||
/* <- keyword */
|
||||
8
tests/query/highlights/tiger/literals.tig
Normal file
8
tests/query/highlights/tiger/literals.tig
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
nil
|
||||
/* <- constant.builtin */
|
||||
42
|
||||
/* <- number */
|
||||
"Hello World!\n"
|
||||
/* <- string
|
||||
^ string.escape
|
||||
*/
|
||||
13
tests/query/highlights/tiger/meta-variables.tig
Normal file
13
tests/query/highlights/tiger/meta-variables.tig
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
let
|
||||
_chunks(42)
|
||||
/* <- keyword */
|
||||
|
||||
in
|
||||
_lvalue(12) : _namety(42) := _cast("I'm So Meta Even This Acronym", string);
|
||||
/* <- keyword */
|
||||
/* ^ keyword */
|
||||
/* ^ keyword */
|
||||
|
||||
_exp(42)
|
||||
/* <- keyword */
|
||||
end
|
||||
28
tests/query/highlights/tiger/object-oriented.tig
Normal file
28
tests/query/highlights/tiger/object-oriented.tig
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
let
|
||||
class A extends Object {}
|
||||
/* <- keyword */
|
||||
/* ^ keyword */
|
||||
/* ^ type.builtin */
|
||||
|
||||
type B = class extends A {
|
||||
/* ^ keyword */
|
||||
/* ^ keyword */
|
||||
/* ^ type */
|
||||
|
||||
var a := 12
|
||||
|
||||
method meth() : int = self.a
|
||||
/* <- keyword.method */
|
||||
/* ^ method */
|
||||
/* ^ variable.builtin */
|
||||
}
|
||||
|
||||
var object := new B
|
||||
/* ^ keyword.constructor */
|
||||
in
|
||||
object.a := 27;
|
||||
/* ^ property */
|
||||
|
||||
object.meth()
|
||||
/* ^ method */
|
||||
end
|
||||
48
tests/query/highlights/tiger/operators.tig
Normal file
48
tests/query/highlights/tiger/operators.tig
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
let
|
||||
var a : int := 42
|
||||
/* ^ punctuation.delimiter */
|
||||
/* ^ operator */
|
||||
in
|
||||
(
|
||||
/* <- punctuation.bracket */
|
||||
|
||||
-1 | 2 & 3 + 4 * 5;
|
||||
/* <- operator */
|
||||
/* ^ operator */
|
||||
/* ^ operator */
|
||||
/* ^ operator */
|
||||
/* ^ operator */
|
||||
/* ^ punctuation.delimiter */
|
||||
|
||||
12 >= 27;
|
||||
/* ^ operator */
|
||||
12 <= 27;
|
||||
/* ^ operator */
|
||||
12 = 27;
|
||||
/* ^ operator */
|
||||
12 <> 27;
|
||||
/* ^ operator */
|
||||
12 < 27;
|
||||
/* ^ operator */
|
||||
12 > 27;
|
||||
/* ^ operator */
|
||||
|
||||
record.field;
|
||||
/* ^ punctuation.delimiter */
|
||||
|
||||
func(a, b);
|
||||
/* ^ punctuation.bracket */
|
||||
/* ^ punctuation.bracket */
|
||||
/* ^ punctuation.delimiter */
|
||||
|
||||
record_type { };
|
||||
/* ^ punctuation.bracket */
|
||||
/* ^ punctuation.bracket */
|
||||
|
||||
array[42]
|
||||
/* ^ punctuation.bracket */
|
||||
/* ^ punctuation.bracket */
|
||||
|
||||
)
|
||||
/* <- punctuation.bracket */
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue