aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/indent/common.lua32
-rw-r--r--tests/indent/typst/call.typ14
-rw-r--r--tests/indent/typst/for.typ8
-rw-r--r--tests/indent/typst/if.typ15
-rw-r--r--tests/indent/typst/let.typ13
-rw-r--r--tests/indent/typst/set.typ9
-rw-r--r--tests/indent/typst/show.typ7
-rw-r--r--tests/indent/typst_spec.lua12
-rw-r--r--tests/query/highlights/kos/test.kos40
-rw-r--r--tests/query/highlights/usd/prims.usda2
-rw-r--r--tests/query/injections/nix/test-nix-injections.nix3
11 files changed, 136 insertions, 19 deletions
diff --git a/tests/indent/common.lua b/tests/indent/common.lua
index 6add58c7f..ccc126870 100644
--- a/tests/indent/common.lua
+++ b/tests/indent/common.lua
@@ -2,12 +2,10 @@ local M = {}
local assert = require('luassert')
local say = require('say')
-local scan_dir = require('plenary.scandir').scan_dir
-local Path = require('plenary.path')
M.XFAIL = 'xfail'
-local function same_indent(state, arguments)
+local function same_indent(_, arguments)
local before = arguments[1]
local after = arguments[2]
@@ -166,7 +164,7 @@ Runner.__index = Runner
function Runner:new(it, base_dir, buf_opts)
local runner = {}
runner.it = it
- runner.base_dir = Path:new(base_dir)
+ runner.base_dir = base_dir
runner.buf_opts = buf_opts
return setmetatable(runner, self)
end
@@ -175,19 +173,23 @@ function Runner:whole_file(dirs, opts)
opts = opts or {}
local expected_failures = opts.expected_failures or {}
expected_failures = vim.tbl_map(function(f)
- return Path:new(f):make_relative(self.base_dir.filename)
+ return vim.fs.normalize(vim.fs.joinpath(self.base_dir, f))
end, expected_failures)
dirs = type(dirs) == 'table' and dirs or { dirs }
dirs = vim.tbl_map(function(dir)
- dir = self.base_dir / Path:new(dir)
- assert.is.same(1, vim.fn.isdirectory(dir.filename))
- return dir.filename
+ dir = vim.fs.normalize(vim.fs.joinpath(self.base_dir, dir))
+ assert.is.same(1, vim.fn.isdirectory(dir))
+ return dir
end, dirs)
- local files = vim.iter(vim.tbl_map(scan_dir, dirs)):flatten():totable()
- for _, file in ipairs(files) do
- local relpath = Path:new(file):make_relative(self.base_dir.filename)
- self.it(relpath, function()
- M.indent_whole_file(file, self.buf_opts, vim.tbl_contains(expected_failures, relpath))
+ local scandir = function(dir)
+ return vim.fs.find(function()
+ return true
+ end, { path = dir, limit = math.huge })
+ end
+ local files = vim.iter(dirs):map(scandir):flatten()
+ for _, file in files:enumerate() do
+ self.it(file, function()
+ M.indent_whole_file(file, self.buf_opts, vim.tbl_contains(expected_failures, file))
end)
end
end
@@ -195,8 +197,8 @@ end
function Runner:new_line(file, spec, title, xfail)
title = title and title or tostring(spec.on_line)
self.it(string.format('%s[%s]', file, title), function()
- local path = self.base_dir / file
- M.indent_new_line(path.filename, spec, self.buf_opts, xfail)
+ local path = vim.fs.joinpath(self.base_dir, file)
+ M.indent_new_line(path, spec, self.buf_opts, xfail)
end)
end
diff --git a/tests/indent/typst/call.typ b/tests/indent/typst/call.typ
new file mode 100644
index 000000000..f0a64c97a
--- /dev/null
+++ b/tests/indent/typst/call.typ
@@ -0,0 +1,14 @@
+#foo(
+ arg1,
+ arg2,
+)
+
+#bar[
+ content here
+]
+
+#baz(
+ inner(
+ nested,
+ ),
+)
diff --git a/tests/indent/typst/for.typ b/tests/indent/typst/for.typ
new file mode 100644
index 000000000..95fe60e9a
--- /dev/null
+++ b/tests/indent/typst/for.typ
@@ -0,0 +1,8 @@
+#for x in (1, 2, 3) {
+ x
+}
+
+#for x in (1, 2, 3) {
+ let y = x + 1
+ y
+}
diff --git a/tests/indent/typst/if.typ b/tests/indent/typst/if.typ
new file mode 100644
index 000000000..41bbaa4c1
--- /dev/null
+++ b/tests/indent/typst/if.typ
@@ -0,0 +1,15 @@
+#if true {
+ "this is one leve"
+}
+
+#set page(header: {
+ if true {
+ "this is internal on level"
+ }
+})
+
+#if true {
+ if false {
+ "this is it"
+ }
+}
diff --git a/tests/indent/typst/let.typ b/tests/indent/typst/let.typ
new file mode 100644
index 000000000..fa0c374c6
--- /dev/null
+++ b/tests/indent/typst/let.typ
@@ -0,0 +1,13 @@
+#let foo(
+ x,
+ y,
+) = x + y
+
+#let bar = {
+ let x = 1
+ x
+}
+
+#let baz(x) = {
+ x + 1
+}
diff --git a/tests/indent/typst/set.typ b/tests/indent/typst/set.typ
new file mode 100644
index 000000000..861b2f95e
--- /dev/null
+++ b/tests/indent/typst/set.typ
@@ -0,0 +1,9 @@
+#set text(
+ size: 12pt,
+ font: "Arial",
+)
+
+#set page(
+ width: 210mm,
+ height: 297mm,
+)
diff --git a/tests/indent/typst/show.typ b/tests/indent/typst/show.typ
new file mode 100644
index 000000000..3947b66c6
--- /dev/null
+++ b/tests/indent/typst/show.typ
@@ -0,0 +1,7 @@
+#show heading: it => {
+ it
+}
+
+#show link: it => {
+ underline(it)
+}
diff --git a/tests/indent/typst_spec.lua b/tests/indent/typst_spec.lua
new file mode 100644
index 000000000..81540405f
--- /dev/null
+++ b/tests/indent/typst_spec.lua
@@ -0,0 +1,12 @@
+local Runner = require('tests.indent.common').Runner
+
+local run = Runner:new(it, 'tests/indent/typst', {
+ tabstop = 4,
+ shiftwidth = 4,
+ softtabstop = 4,
+ expandtab = false,
+})
+
+describe('indent typst:', function()
+ run:whole_file('.')
+end)
diff --git a/tests/query/highlights/kos/test.kos b/tests/query/highlights/kos/test.kos
index 981fdb313..4e1b0ec6d 100644
--- a/tests/query/highlights/kos/test.kos
+++ b/tests/query/highlights/kos/test.kos
@@ -21,15 +21,15 @@ fun name(arg1,
# ^ keyword.function
# ^ function
# ^ punctuation.bracket
-# ^ variable
+# ^ variable.parameter
# ^ punctuation.delimiter
arg2 = "default",
-# ^ variable
+# ^ variable.parameter
# ^ operator
# ^ string
# ^ punctuation.delimiter
arg3...)
-# ^ variable
+# ^ variable.parameter
# ^ operator
# ^ punctuation.bracket
{
@@ -147,3 +147,37 @@ name.name()
# ^ function.method.call
# ^ punctuation.bracket
# ^ punctuation.bracket
+
+print("hello \(123 + var) world \(true)")
+# <- function.call
+# ^ punctuation.bracket
+# ^ string
+# ^ punctuation.special
+# ^ number
+# ^ operator
+# ^ variable
+# ^ punctuation.special
+# ^ string
+# ^ punctuation.special
+# ^ boolean
+# ^ punctuation.special
+# ^ punctuation.bracket
+
+[] -> each((x,_,y) => x + y)
+# <- punctuation.bracket
+#^ punctuation.bracket
+# ^ operator
+# ^ function.call
+# ^ punctuation.bracket
+# ^ punctuation.bracket
+# ^ variable.parameter
+# ^ punctuation.delimiter
+# ^ character.special
+# ^ punctuation.delimiter
+# ^ variable.parameter
+# ^ punctuation.bracket
+# ^ keyword.function
+# ^ variable
+# ^ operator
+# ^ variable
+# ^ punctuation.bracket
diff --git a/tests/query/highlights/usd/prims.usda b/tests/query/highlights/usd/prims.usda
index da9a5d6fe..dcb6c3b59 100644
--- a/tests/query/highlights/usd/prims.usda
+++ b/tests/query/highlights/usd/prims.usda
@@ -3,8 +3,10 @@ def Xform "cube" (
# <- @keyword
asset[] payloadAssetDependencies = [@fizz.usd@, @buzz.usd@]
# <- @type
+ # ^ @punctuation.bracket
# ^ @keyword
# ^ @string.special.url
+ # ^ @punctuation.delimiter
# ^ @string.special.url
}
)
diff --git a/tests/query/injections/nix/test-nix-injections.nix b/tests/query/injections/nix/test-nix-injections.nix
index 7505398e6..f0907a901 100644
--- a/tests/query/injections/nix/test-nix-injections.nix
+++ b/tests/query/injections/nix/test-nix-injections.nix
@@ -9,7 +9,8 @@ in {
drv1 = stdenv.mkDerivation {
buildPhase = "mkdir $out";
installPhase = ''
- echo "bar" > $out/foo.txt
+ echo "${bar}" > $out/foo.txt
+ echo "baz"" >> $out/foo.txt
'';
};