2024-04-09 04:26:16 -07:00
|
|
|
local t = require('test.functional.testutil')()
|
2024-04-08 02:03:20 -07:00
|
|
|
local clear = t.clear
|
|
|
|
local eq = t.eq
|
|
|
|
local ok = t.ok
|
|
|
|
local exec_lua = t.exec_lua
|
|
|
|
local matches = t.matches
|
|
|
|
local pcall_err = t.pcall_err
|
|
|
|
local fn = t.fn
|
2023-02-19 04:33:57 -07:00
|
|
|
|
2023-03-16 06:50:20 -07:00
|
|
|
local function v(ver)
|
2023-03-16 17:12:33 -07:00
|
|
|
return vim.version._version(ver)
|
2023-03-16 06:50:20 -07:00
|
|
|
end
|
|
|
|
|
2023-02-19 04:33:57 -07:00
|
|
|
describe('version', function()
|
2023-03-06 05:23:03 -07:00
|
|
|
it('package', function()
|
|
|
|
clear()
|
|
|
|
eq({ major = 42, minor = 3, patch = 99 }, exec_lua("return vim.version.parse('v42.3.99')"))
|
|
|
|
end)
|
|
|
|
|
2023-06-11 16:14:33 -07:00
|
|
|
it('version() returns Nvim version', function()
|
2024-04-02 06:45:19 -07:00
|
|
|
local expected = fn.api_info().version
|
2023-06-11 16:14:33 -07:00
|
|
|
local actual = exec_lua('return vim.version()')
|
|
|
|
eq(expected.major, actual.major)
|
|
|
|
eq(expected.minor, actual.minor)
|
|
|
|
eq(expected.patch, actual.patch)
|
|
|
|
eq(expected.prerelease and 'dev' or nil, actual.prerelease)
|
|
|
|
|
|
|
|
-- tostring() #23863
|
|
|
|
matches([[%d+%.%d+%.%d+]], exec_lua('return tostring(vim.version())'))
|
|
|
|
end)
|
|
|
|
|
2023-03-16 17:12:33 -07:00
|
|
|
describe('_version()', function()
|
2023-03-16 06:50:20 -07:00
|
|
|
local tests = {
|
|
|
|
['v1.2.3'] = { major = 1, minor = 2, patch = 3 },
|
|
|
|
['v1.2'] = { major = 1, minor = 2, patch = 0 },
|
|
|
|
['v1.2.3-prerelease'] = { major = 1, minor = 2, patch = 3, prerelease = 'prerelease' },
|
|
|
|
['v1.2-prerelease'] = { major = 1, minor = 2, patch = 0, prerelease = 'prerelease' },
|
2023-03-16 17:12:33 -07:00
|
|
|
['v1.2.3-prerelease+build'] = {
|
|
|
|
major = 1,
|
|
|
|
minor = 2,
|
|
|
|
patch = 3,
|
|
|
|
prerelease = 'prerelease',
|
|
|
|
build = 'build',
|
|
|
|
},
|
2023-03-16 06:50:20 -07:00
|
|
|
['1.2.3+build'] = { major = 1, minor = 2, patch = 3, build = 'build' },
|
|
|
|
}
|
|
|
|
for input, output in pairs(tests) do
|
|
|
|
it('parses ' .. input, function()
|
2023-03-16 14:49:12 -07:00
|
|
|
eq(output, v(input))
|
2023-03-16 06:50:20 -07:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2023-03-16 17:12:33 -07:00
|
|
|
describe('range', function()
|
2023-03-16 06:50:20 -07:00
|
|
|
local tests = {
|
|
|
|
['1.2.3'] = { from = { 1, 2, 3 }, to = { 1, 2, 4 } },
|
|
|
|
['1.2'] = { from = { 1, 2, 0 }, to = { 1, 3, 0 } },
|
|
|
|
['=1.2.3'] = { from = { 1, 2, 3 }, to = { 1, 2, 4 } },
|
|
|
|
['>1.2.3'] = { from = { 1, 2, 4 } },
|
|
|
|
['>=1.2.3'] = { from = { 1, 2, 3 } },
|
2023-06-06 06:38:45 -07:00
|
|
|
['<1.2.3'] = { from = { 0, 0, 0 }, to = { 1, 2, 3 } },
|
|
|
|
['<=1.2.3'] = { from = { 0, 0, 0 }, to = { 1, 2, 4 } },
|
2023-03-16 06:50:20 -07:00
|
|
|
['~1.2.3'] = { from = { 1, 2, 3 }, to = { 1, 3, 0 } },
|
|
|
|
['^1.2.3'] = { from = { 1, 2, 3 }, to = { 2, 0, 0 } },
|
|
|
|
['^0.2.3'] = { from = { 0, 2, 3 }, to = { 0, 3, 0 } },
|
|
|
|
['^0.0.1'] = { from = { 0, 0, 1 }, to = { 0, 0, 2 } },
|
|
|
|
['^1.2'] = { from = { 1, 2, 0 }, to = { 2, 0, 0 } },
|
|
|
|
['~1.2'] = { from = { 1, 2, 0 }, to = { 1, 3, 0 } },
|
|
|
|
['~1'] = { from = { 1, 0, 0 }, to = { 2, 0, 0 } },
|
|
|
|
['^1'] = { from = { 1, 0, 0 }, to = { 2, 0, 0 } },
|
|
|
|
['1.*'] = { from = { 1, 0, 0 }, to = { 2, 0, 0 } },
|
|
|
|
['1'] = { from = { 1, 0, 0 }, to = { 2, 0, 0 } },
|
|
|
|
['1.x'] = { from = { 1, 0, 0 }, to = { 2, 0, 0 } },
|
|
|
|
['1.2.x'] = { from = { 1, 2, 0 }, to = { 1, 3, 0 } },
|
|
|
|
['1.2.*'] = { from = { 1, 2, 0 }, to = { 1, 3, 0 } },
|
|
|
|
['*'] = { from = { 0, 0, 0 } },
|
|
|
|
['1.2 - 2.3.0'] = { from = { 1, 2, 0 }, to = { 2, 3, 0 } },
|
|
|
|
['1.2.3 - 2.3.4'] = { from = { 1, 2, 3 }, to = { 2, 3, 4 } },
|
|
|
|
['1.2.3 - 2'] = { from = { 1, 2, 3 }, to = { 3, 0, 0 } },
|
|
|
|
}
|
|
|
|
for input, output in pairs(tests) do
|
|
|
|
output.from = v(output.from)
|
|
|
|
output.to = output.to and v(output.to)
|
2023-03-16 17:12:33 -07:00
|
|
|
local range = vim.version.range(input)
|
2023-03-16 06:50:20 -07:00
|
|
|
|
|
|
|
it('parses ' .. input, function()
|
2023-03-16 14:49:12 -07:00
|
|
|
eq(output, range)
|
2023-03-16 06:50:20 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('[from] in range ' .. input, function()
|
2023-03-16 17:12:33 -07:00
|
|
|
assert(range:has(output.from))
|
2023-03-16 06:50:20 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('[from-1] not in range ' .. input, function()
|
|
|
|
local lower = vim.deepcopy(range.from)
|
|
|
|
lower.major = lower.major - 1
|
2023-03-16 17:12:33 -07:00
|
|
|
assert(not range:has(lower))
|
2023-03-16 06:50:20 -07:00
|
|
|
end)
|
|
|
|
|
2023-03-16 17:12:33 -07:00
|
|
|
it('[to] not in range ' .. input .. ' to:' .. tostring(range.to), function()
|
2023-03-16 06:50:20 -07:00
|
|
|
if range.to then
|
|
|
|
assert(not (range.to < range.to))
|
2023-03-16 17:12:33 -07:00
|
|
|
assert(not range:has(range.to))
|
2023-03-16 06:50:20 -07:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2023-03-16 17:12:33 -07:00
|
|
|
it('handles prerelease', function()
|
|
|
|
assert(not vim.version.range('1.2.3'):has('1.2.3-alpha'))
|
|
|
|
assert(vim.version.range('1.2.3-alpha'):has('1.2.3-alpha'))
|
|
|
|
assert(not vim.version.range('1.2.3-alpha'):has('1.2.3-beta'))
|
2023-03-16 06:50:20 -07:00
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2023-02-19 04:33:57 -07:00
|
|
|
describe('cmp()', function()
|
|
|
|
local testcases = {
|
2023-03-16 14:49:12 -07:00
|
|
|
{ v1 = 'v0.0.99', v2 = 'v9.0.0', want = -1 },
|
|
|
|
{ v1 = 'v0.4.0', v2 = 'v0.9.99', want = -1 },
|
|
|
|
{ v1 = 'v0.2.8', v2 = 'v1.0.9', want = -1 },
|
|
|
|
{ v1 = 'v0.0.0', v2 = 'v0.0.0', want = 0 },
|
|
|
|
{ v1 = 'v9.0.0', v2 = 'v0.9.0', want = 1 },
|
|
|
|
{ v1 = 'v0.9.0', v2 = 'v0.0.0', want = 1 },
|
|
|
|
{ v1 = 'v0.0.9', v2 = 'v0.0.0', want = 1 },
|
2023-03-20 05:36:06 -07:00
|
|
|
{ v1 = 'v0.0.9+aaa', v2 = 'v0.0.9+bbb', want = 0 },
|
|
|
|
|
|
|
|
-- prerelease 💩 https://semver.org/#spec-item-11
|
2023-03-16 14:49:12 -07:00
|
|
|
{ v1 = 'v1.0.0-alpha', v2 = 'v1.0.0', want = -1 },
|
|
|
|
{ v1 = '1.0.0', v2 = '1.0.0-alpha', want = 1 },
|
|
|
|
{ v1 = '1.0.0-2', v2 = '1.0.0-1', want = 1 },
|
|
|
|
{ v1 = '1.0.0-2', v2 = '1.0.0-9', want = -1 },
|
|
|
|
{ v1 = '1.0.0-2', v2 = '1.0.0-2.0', want = -1 },
|
|
|
|
{ v1 = '1.0.0-2.0', v2 = '1.0.0-2', want = 1 },
|
|
|
|
{ v1 = '1.0.0-2.0', v2 = '1.0.0-2.0', want = 0 },
|
|
|
|
{ v1 = '1.0.0-alpha', v2 = '1.0.0-alpha', want = 0 },
|
|
|
|
{ v1 = '1.0.0-alpha', v2 = '1.0.0-beta', want = -1 },
|
|
|
|
{ v1 = '1.0.0-beta', v2 = '1.0.0-alpha', want = 1 },
|
|
|
|
{ v1 = '1.0.0-alpha', v2 = '1.0.0-alpha.1', want = -1 },
|
|
|
|
{ v1 = '1.0.0-alpha.1', v2 = '1.0.0-alpha', want = 1 },
|
|
|
|
{ v1 = '1.0.0-alpha.beta', v2 = '1.0.0-alpha', want = 1 },
|
|
|
|
{ v1 = '1.0.0-alpha', v2 = '1.0.0-alpha.beta', want = -1 },
|
|
|
|
{ v1 = '1.0.0-alpha.beta', v2 = '1.0.0-beta', want = -1 },
|
2023-03-20 05:36:06 -07:00
|
|
|
{ v1 = '1.0.0-beta.2', v2 = '1.0.0-beta.11', want = -1 },
|
|
|
|
{ v1 = '1.0.0-beta.20', v2 = '1.0.0-beta.11', want = 1 },
|
|
|
|
{ v1 = '1.0.0-alpha.20', v2 = '1.0.0-beta.11', want = -1 },
|
|
|
|
{ v1 = '1.0.0-a.01.x.3', v2 = '1.0.0-a.1.x.003', want = 0 },
|
|
|
|
{ v1 = 'v0.9.0-dev-92+9', v2 = 'v0.9.0-dev-120+3', want = -1 },
|
2023-02-19 04:33:57 -07:00
|
|
|
}
|
|
|
|
for _, tc in ipairs(testcases) do
|
2023-03-16 17:12:33 -07:00
|
|
|
local msg = function(s)
|
|
|
|
return ('v1 %s v2'):format(s == 0 and '==' or (s == 1 and '>' or '<'))
|
|
|
|
end
|
2023-03-16 14:49:12 -07:00
|
|
|
it(string.format('(v1 = %s, v2 = %s)', tc.v1, tc.v2), function()
|
2023-03-16 17:12:33 -07:00
|
|
|
local rv = vim.version.cmp(tc.v1, tc.v2, { strict = true })
|
|
|
|
ok(tc.want == rv, msg(tc.want), msg(rv))
|
2023-02-19 04:33:57 -07:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('parse()', function()
|
2023-03-06 05:23:03 -07:00
|
|
|
describe('strict=true', function()
|
2023-02-19 04:33:57 -07:00
|
|
|
local testcases = {
|
2023-03-16 17:12:33 -07:00
|
|
|
{
|
|
|
|
desc = 'Nvim version',
|
|
|
|
version = 'v0.9.0-dev-1233+g210120dde81e',
|
|
|
|
want = {
|
|
|
|
major = 0,
|
|
|
|
minor = 9,
|
|
|
|
patch = 0,
|
|
|
|
prerelease = 'dev-1233',
|
|
|
|
build = 'g210120dde81e',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc = 'no v',
|
|
|
|
version = '10.20.123',
|
|
|
|
want = { major = 10, minor = 20, patch = 123, prerelease = nil, build = nil },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc = 'with v',
|
|
|
|
version = 'v1.2.3',
|
|
|
|
want = { major = 1, minor = 2, patch = 3 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc = 'prerelease',
|
|
|
|
version = '1.2.3-alpha',
|
|
|
|
want = { major = 1, minor = 2, patch = 3, prerelease = 'alpha' },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc = 'prerelease.x',
|
|
|
|
version = '1.2.3-alpha.1',
|
|
|
|
want = { major = 1, minor = 2, patch = 3, prerelease = 'alpha.1' },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc = 'build.x',
|
|
|
|
version = '1.2.3+build.15',
|
|
|
|
want = { major = 1, minor = 2, patch = 3, build = 'build.15' },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc = 'prerelease and build',
|
|
|
|
version = '1.2.3-rc1+build.15',
|
|
|
|
want = { major = 1, minor = 2, patch = 3, prerelease = 'rc1', build = 'build.15' },
|
|
|
|
},
|
2023-02-19 04:33:57 -07:00
|
|
|
}
|
|
|
|
for _, tc in ipairs(testcases) do
|
2023-03-16 14:49:12 -07:00
|
|
|
it(string.format('%q: version = %q', tc.desc, tc.version), function()
|
2023-03-16 17:12:33 -07:00
|
|
|
eq(tc.want, vim.version.parse(tc.version))
|
2023-03-06 05:23:03 -07:00
|
|
|
end)
|
2023-02-19 04:33:57 -07:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2023-03-06 05:23:03 -07:00
|
|
|
describe('strict=false', function()
|
2023-02-19 04:33:57 -07:00
|
|
|
local testcases = {
|
2023-03-16 14:49:12 -07:00
|
|
|
{ version = '1.2', want = { major = 1, minor = 2, patch = 0 } },
|
|
|
|
{ version = '1', want = { major = 1, minor = 0, patch = 0 } },
|
|
|
|
{ version = '1.1-0', want = { major = 1, minor = 1, patch = 0, prerelease = '0' } },
|
|
|
|
{ version = '1-1.0', want = { major = 1, minor = 0, patch = 0, prerelease = '1.0' } },
|
|
|
|
{ version = 'v1.2.3 ', want = { major = 1, minor = 2, patch = 3 } },
|
|
|
|
{ version = ' v1.2.3', want = { major = 1, minor = 2, patch = 3 } },
|
2023-03-16 17:12:33 -07:00
|
|
|
{ version = 'tmux 3.2a', want = { major = 3, minor = 2, patch = 0 } },
|
2023-02-19 04:33:57 -07:00
|
|
|
}
|
|
|
|
for _, tc in ipairs(testcases) do
|
2023-03-16 14:49:12 -07:00
|
|
|
it(string.format('version = %q', tc.version), function()
|
2023-03-16 17:12:33 -07:00
|
|
|
eq(tc.want, vim.version.parse(tc.version, { strict = false }))
|
2023-03-06 05:23:03 -07:00
|
|
|
end)
|
2023-02-19 04:33:57 -07:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2023-03-06 05:23:03 -07:00
|
|
|
describe('invalid semver', function()
|
2023-02-19 04:33:57 -07:00
|
|
|
local testcases = {
|
2023-03-16 14:49:12 -07:00
|
|
|
{ version = 'foo' },
|
|
|
|
{ version = '' },
|
|
|
|
{ version = '0.0.0.' },
|
|
|
|
{ version = '.0.0.0' },
|
|
|
|
{ version = '-1.0.0' },
|
|
|
|
{ version = '0.-1.0' },
|
|
|
|
{ version = '0.0.-1' },
|
|
|
|
{ version = 'foobar1.2.3' },
|
|
|
|
{ version = '1.2.3foobar' },
|
|
|
|
{ version = '1.2.3-%?' },
|
|
|
|
{ version = '1.2.3+%?' },
|
|
|
|
{ version = '1.2.3+build.0-rc1' },
|
2023-03-16 17:12:33 -07:00
|
|
|
{ version = '3.2a' },
|
|
|
|
{ version = 'tmux 3.2a' },
|
2023-02-19 04:33:57 -07:00
|
|
|
}
|
2023-03-16 14:49:12 -07:00
|
|
|
|
|
|
|
local function quote_empty(s)
|
|
|
|
return tostring(s) == '' and '""' or tostring(s)
|
|
|
|
end
|
|
|
|
|
2023-02-19 04:33:57 -07:00
|
|
|
for _, tc in ipairs(testcases) do
|
2023-03-16 14:49:12 -07:00
|
|
|
it(quote_empty(tc.version), function()
|
2023-03-16 17:12:33 -07:00
|
|
|
eq(nil, vim.version.parse(tc.version, { strict = true }))
|
2023-03-06 05:23:03 -07:00
|
|
|
end)
|
2023-02-19 04:33:57 -07:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2023-03-06 05:23:03 -07:00
|
|
|
describe('invalid shape', function()
|
2023-02-19 04:33:57 -07:00
|
|
|
local testcases = {
|
2023-03-06 05:23:03 -07:00
|
|
|
{ desc = 'no parameters' },
|
|
|
|
{ desc = 'nil', version = nil },
|
|
|
|
{ desc = 'number', version = 0 },
|
|
|
|
{ desc = 'float', version = 0.01 },
|
|
|
|
{ desc = 'table', version = {} },
|
2023-02-19 04:33:57 -07:00
|
|
|
}
|
|
|
|
for _, tc in ipairs(testcases) do
|
2023-03-06 05:23:03 -07:00
|
|
|
it(string.format('(%s): %s', tc.desc, tostring(tc.version)), function()
|
2023-03-06 07:08:22 -07:00
|
|
|
local expected = string.format(
|
|
|
|
type(tc.version) == 'string' and 'invalid version: "%s"' or 'invalid version: %s',
|
|
|
|
tostring(tc.version)
|
2024-01-02 18:09:18 -07:00
|
|
|
)
|
2023-03-16 17:12:33 -07:00
|
|
|
matches(expected, pcall_err(vim.version.parse, tc.version, { strict = true }))
|
2023-02-19 04:33:57 -07:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
2023-03-16 17:12:33 -07:00
|
|
|
it('relational metamethods (== < >)', function()
|
|
|
|
assert(v('v1.2.3') == v('1.2.3'))
|
|
|
|
assert(not (v('v1.2.3') < v('1.2.3')))
|
|
|
|
assert(v('v1.2.3') > v('1.2.3-prerelease'))
|
|
|
|
assert(v('v1.2.3-alpha') < v('1.2.3-beta'))
|
|
|
|
assert(v('v1.2.3-prerelease') < v('1.2.3'))
|
|
|
|
assert(v('v1.2.3') >= v('1.2.3'))
|
|
|
|
assert(v('v1.2.3') >= v('1.0.3'))
|
|
|
|
assert(v('v1.2.3') >= v('1.2.2'))
|
|
|
|
assert(v('v1.2.3') > v('1.2.2'))
|
|
|
|
assert(v('v1.2.3') > v('1.0.3'))
|
|
|
|
eq(vim.version.last({ v('1.2.3'), v('2.0.0') }), v('2.0.0'))
|
|
|
|
eq(vim.version.last({ v('2.0.0'), v('1.2.3') }), v('2.0.0'))
|
|
|
|
end)
|
|
|
|
|
2024-01-15 10:13:09 -07:00
|
|
|
it('le()', function()
|
|
|
|
eq(true, vim.version.le('1', '1'))
|
|
|
|
eq(true, vim.version.le({ 3, 1, 4 }, '3.1.4'))
|
|
|
|
eq(true, vim.version.le('1', '2'))
|
|
|
|
eq(true, vim.version.le({ 0, 7, 4 }, { 3 }))
|
|
|
|
eq(false, vim.version.le({ 3 }, { 0, 7, 4 }))
|
|
|
|
eq(false, vim.version.le({ major = 3, minor = 3, patch = 0 }, { 3, 2, 0 }))
|
|
|
|
eq(false, vim.version.le('2', '1'))
|
|
|
|
end)
|
|
|
|
|
2023-03-06 07:08:22 -07:00
|
|
|
it('lt()', function()
|
2024-01-15 10:13:09 -07:00
|
|
|
eq(false, vim.version.lt('1', '1'))
|
|
|
|
eq(false, vim.version.lt({ 3, 1, 4 }, '3.1.4'))
|
2023-03-16 17:12:33 -07:00
|
|
|
eq(true, vim.version.lt('1', '2'))
|
2024-01-15 10:13:09 -07:00
|
|
|
eq(true, vim.version.lt({ 0, 7, 4 }, { 3 }))
|
2023-03-16 17:12:33 -07:00
|
|
|
eq(false, vim.version.lt({ 3 }, { 0, 7, 4 }))
|
|
|
|
eq(false, vim.version.lt({ major = 3, minor = 3, patch = 0 }, { 3, 2, 0 }))
|
2024-01-15 10:13:09 -07:00
|
|
|
eq(false, vim.version.lt('2', '1'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('ge()', function()
|
|
|
|
eq(true, vim.version.ge('1', '1'))
|
|
|
|
eq(true, vim.version.ge({ 3, 1, 4 }, '3.1.4'))
|
|
|
|
eq(true, vim.version.ge('2', '1'))
|
|
|
|
eq(true, vim.version.ge({ 3 }, { 0, 7, 4 }))
|
|
|
|
eq(true, vim.version.ge({ major = 3, minor = 3, patch = 0 }, { 3, 2, 0 }))
|
|
|
|
eq(false, vim.version.ge('1', '2'))
|
|
|
|
eq(false, vim.version.ge({ 0, 7, 4 }, { 3 }))
|
2023-03-06 05:23:03 -07:00
|
|
|
end)
|
|
|
|
|
2023-03-06 07:08:22 -07:00
|
|
|
it('gt()', function()
|
2024-01-15 10:13:09 -07:00
|
|
|
eq(false, vim.version.gt('1', '1'))
|
|
|
|
eq(false, vim.version.gt({ 3, 1, 4 }, '3.1.4'))
|
2023-03-16 17:12:33 -07:00
|
|
|
eq(true, vim.version.gt('2', '1'))
|
|
|
|
eq(true, vim.version.gt({ 3 }, { 0, 7, 4 }))
|
|
|
|
eq(true, vim.version.gt({ major = 3, minor = 3, patch = 0 }, { 3, 2, 0 }))
|
2024-01-15 10:13:09 -07:00
|
|
|
eq(false, vim.version.gt('1', '2'))
|
|
|
|
eq(false, vim.version.gt({ 0, 7, 4 }, { 3 }))
|
2023-03-06 05:23:03 -07:00
|
|
|
end)
|
2023-02-19 04:33:57 -07:00
|
|
|
|
2023-03-06 07:08:22 -07:00
|
|
|
it('eq()', function()
|
2023-03-16 17:12:33 -07:00
|
|
|
eq(true, vim.version.eq('2', '2'))
|
|
|
|
eq(true, vim.version.eq({ 3, 1, 0 }, '3.1.0'))
|
|
|
|
eq(true, vim.version.eq({ major = 3, minor = 3, patch = 0 }, { 3, 3, 0 }))
|
2024-01-15 10:13:09 -07:00
|
|
|
eq(false, vim.version.eq('2', '3'))
|
|
|
|
|
|
|
|
-- semver: v3 == v3.0 == v3.0.0
|
|
|
|
eq(true, vim.version.eq('3', { 3, 0, 0 }))
|
|
|
|
eq(true, vim.version.eq({ 3, 0 }, { 3 }))
|
|
|
|
eq(true, vim.version.eq({ 3, 0, 0 }, { 3 }))
|
2023-02-19 04:33:57 -07:00
|
|
|
end)
|
|
|
|
end)
|