Skip to content

Commit d0c242b

Browse files
committed
add unit tests for arrays
1 parent bd517b9 commit d0c242b

File tree

1 file changed

+258
-0
lines changed

1 file changed

+258
-0
lines changed

test/completion/common.lua

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,264 @@ f('<??>')
16391639
}
16401640
}
16411641

1642+
TEST [[
1643+
---@alias Option string | "AAA" | "BBB" | "CCC"
1644+
---@param x Option[]
1645+
function f(x)
1646+
end
1647+
1648+
f({<??>})
1649+
]]
1650+
{
1651+
{
1652+
label = '"AAA"',
1653+
kind = define.CompletionItemKind.EnumMember,
1654+
textEdit = EXISTS
1655+
},
1656+
{
1657+
label = '"BBB"',
1658+
kind = define.CompletionItemKind.EnumMember,
1659+
textEdit = EXISTS
1660+
},
1661+
{
1662+
label = '"CCC"',
1663+
kind = define.CompletionItemKind.EnumMember,
1664+
textEdit = EXISTS
1665+
}
1666+
}
1667+
1668+
TEST [[
1669+
---@alias Option string | "AAA" | "BBB" | "CCC"
1670+
---@param x Option[]
1671+
function f(x)
1672+
end
1673+
1674+
f({"<??>"})
1675+
]]
1676+
{
1677+
{
1678+
label = '"AAA"',
1679+
kind = define.CompletionItemKind.EnumMember,
1680+
textEdit = EXISTS
1681+
},
1682+
{
1683+
label = '"BBB"',
1684+
kind = define.CompletionItemKind.EnumMember,
1685+
textEdit = EXISTS
1686+
},
1687+
{
1688+
label = '"CCC"',
1689+
kind = define.CompletionItemKind.EnumMember,
1690+
textEdit = EXISTS
1691+
}
1692+
}
1693+
1694+
TEST [[
1695+
---@alias Option string | "AAA" | "BBB" | "CCC"
1696+
---@param x Option[]
1697+
function f(x)
1698+
end
1699+
1700+
f(<??>)
1701+
]]
1702+
(nil)
1703+
1704+
TEST [[
1705+
---@alias Option "AAA" | "BBB" | "CCC"
1706+
1707+
---@type Option[]
1708+
local l = {<??>}
1709+
]]
1710+
{
1711+
{
1712+
label = '"AAA"',
1713+
kind = define.CompletionItemKind.EnumMember,
1714+
},
1715+
{
1716+
label = '"BBB"',
1717+
kind = define.CompletionItemKind.EnumMember,
1718+
},
1719+
{
1720+
label = '"CCC"',
1721+
kind = define.CompletionItemKind.EnumMember,
1722+
}
1723+
}
1724+
1725+
TEST [[
1726+
---@alias Option "AAA" | "BBB" | "CCC"
1727+
1728+
---@type Option[]
1729+
local l = {"<??>"}
1730+
]]
1731+
{
1732+
{
1733+
label = '"AAA"',
1734+
kind = define.CompletionItemKind.EnumMember,
1735+
textEdit = EXISTS
1736+
},
1737+
{
1738+
label = '"BBB"',
1739+
kind = define.CompletionItemKind.EnumMember,
1740+
textEdit = EXISTS
1741+
},
1742+
{
1743+
label = '"CCC"',
1744+
kind = define.CompletionItemKind.EnumMember,
1745+
textEdit = EXISTS
1746+
}
1747+
}
1748+
1749+
TEST [[
1750+
---@alias Option "AAA" | "BBB" | "CCC"
1751+
1752+
---@type Option[]
1753+
local l = <??>
1754+
]]
1755+
(nil)
1756+
1757+
TEST [[
1758+
---@class OptionObj
1759+
---@field a boolean
1760+
---@field b boolean
1761+
1762+
---@type OptionObj[]
1763+
local l = { {<??>} }
1764+
]]
1765+
{
1766+
{
1767+
label = 'a',
1768+
kind = define.CompletionItemKind.Property,
1769+
},
1770+
{
1771+
label = 'b',
1772+
kind = define.CompletionItemKind.Property,
1773+
}
1774+
}
1775+
1776+
TEST [[
1777+
---@class OptionObj
1778+
---@field a boolean
1779+
---@field b boolean
1780+
1781+
---@type OptionObj[]
1782+
local l = { <??> }
1783+
]]
1784+
(nil)
1785+
1786+
TEST [[
1787+
---@class OptionObj
1788+
---@field a boolean
1789+
---@field b boolean
1790+
1791+
---@type OptionObj[]
1792+
local l = <??>
1793+
]]
1794+
(nil)
1795+
1796+
TEST [[
1797+
---@class OptionObj
1798+
---@field a boolean
1799+
---@field b boolean
1800+
---@field children OptionObj[]
1801+
1802+
---@type OptionObj[]
1803+
local l = {
1804+
{
1805+
a = true,
1806+
children = { {<??>} }
1807+
}
1808+
}
1809+
]]
1810+
{
1811+
{
1812+
label = 'a',
1813+
kind = define.CompletionItemKind.Property,
1814+
},
1815+
{
1816+
label = 'b',
1817+
kind = define.CompletionItemKind.Property,
1818+
},
1819+
{
1820+
label = 'children',
1821+
kind = define.CompletionItemKind.Property,
1822+
}
1823+
}
1824+
1825+
TEST [[
1826+
---@class OptionObj
1827+
---@field a boolean
1828+
---@field b boolean
1829+
---@field children OptionObj[]
1830+
1831+
---@type OptionObj[]
1832+
local l = {
1833+
{
1834+
children = {<??>}
1835+
}
1836+
}
1837+
]]
1838+
(nil)
1839+
1840+
TEST [[
1841+
---@class OptionObj
1842+
---@field a boolean
1843+
---@field b boolean
1844+
---@field children OptionObj[]
1845+
1846+
---@type OptionObj[]
1847+
local l = {
1848+
{
1849+
children = <??>
1850+
}
1851+
}
1852+
]]
1853+
(nil)
1854+
1855+
TEST [[
1856+
---@class OptionObj
1857+
---@field a boolean
1858+
---@field b boolean
1859+
---@param x OptionObj[]
1860+
function f(x)
1861+
end
1862+
1863+
f({ {<??>} })
1864+
]]
1865+
{
1866+
{
1867+
label = 'a',
1868+
kind = define.CompletionItemKind.Property,
1869+
},
1870+
{
1871+
label = 'b',
1872+
kind = define.CompletionItemKind.Property,
1873+
}
1874+
}
1875+
1876+
TEST [[
1877+
---@class OptionObj
1878+
---@field a boolean
1879+
---@field b boolean
1880+
---@param x OptionObj[]
1881+
function f(x)
1882+
end
1883+
1884+
f({<??>})
1885+
]]
1886+
(nil)
1887+
1888+
TEST [[
1889+
---@class OptionObj
1890+
---@field a boolean
1891+
---@field b boolean
1892+
---@param x OptionObj[]
1893+
function f(x)
1894+
end
1895+
1896+
f(<??>)
1897+
]]
1898+
(nil)
1899+
16421900
TEST [[
16431901
---this is
16441902
---a multi line

0 commit comments

Comments
 (0)