neovim/test/functional/eval/has_spec.lua
Mahmoud Al-Qudsi 5d2dd2ebe2 win: has("wsl") on Windows Subsystem for Linux #7330
Per CMAKE docs, CMAKE_HOST_SYSTEM_VERSION is the result of `uname -r`:
https://cmake.org/cmake/help/v3.4/variable/CMAKE_HOST_SYSTEM_VERSION.html?highlight=uname

    A numeric version string for the system. On systems that support
    uname, this variable is set to the output of uname -r. On other
    systems this is set to major-minor version numbers.

On Windows it is something like "6.1", so it won't match ".*-Microsoft".

Closes #7329
2018-01-30 21:12:49 +01:00

67 lines
1.9 KiB
Lua

local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local clear = helpers.clear
local funcs = helpers.funcs
local iswin = helpers.iswin
describe('has()', function()
before_each(clear)
it('"nvim-x.y.z"', function()
eq(0, funcs.has("nvim-"))
eq(0, funcs.has("nvim- "))
eq(0, funcs.has("nvim- \t "))
eq(0, funcs.has("nvim-0. 1. 1"))
eq(0, funcs.has("nvim-0. 1.1"))
eq(0, funcs.has("nvim-0.1. 1"))
eq(0, funcs.has("nvim-a"))
eq(0, funcs.has("nvim-a.b.c"))
eq(0, funcs.has("nvim-0.b.c"))
eq(0, funcs.has("nvim-0.0.c"))
eq(0, funcs.has("nvim-0.b.0"))
eq(0, funcs.has("nvim-a.b.0"))
eq(0, funcs.has("nvim-.0.0.0"))
eq(0, funcs.has("nvim-.0"))
eq(0, funcs.has("nvim-0."))
eq(0, funcs.has("nvim-0.."))
eq(0, funcs.has("nvim-."))
eq(0, funcs.has("nvim-.."))
eq(0, funcs.has("nvim-..."))
eq(0, funcs.has("nvim-42"))
eq(0, funcs.has("nvim-9999"))
eq(0, funcs.has("nvim-99.001.05"))
eq(1, funcs.has("nvim"))
eq(1, funcs.has("nvim-0"))
eq(1, funcs.has("nvim-0.1"))
eq(1, funcs.has("nvim-0.0.0"))
eq(1, funcs.has("nvim-0.1.1."))
eq(1, funcs.has("nvim-0.1.1.abc"))
eq(1, funcs.has("nvim-0.1.1.."))
eq(1, funcs.has("nvim-0.1.1.. .."))
eq(1, funcs.has("nvim-0.1.1.... "))
eq(1, funcs.has("nvim-0.0.0"))
eq(1, funcs.has("nvim-0.0.1"))
eq(1, funcs.has("nvim-0.1.0"))
eq(1, funcs.has("nvim-0.1.1"))
eq(1, funcs.has("nvim-0.1.5"))
eq(1, funcs.has("nvim-0000.001.05"))
eq(1, funcs.has("nvim-0.01.005"))
eq(1, funcs.has("nvim-00.001.05"))
end)
it('"unnamedplus"', function()
if (not iswin()) and funcs.has("clipboard") == 1 then
eq(1, funcs.has("unnamedplus"))
else
eq(0, funcs.has("unnamedplus"))
end
end)
it('"wsl"', function()
if 1 == funcs.has('win32') or 1 == funcs.has('mac') then
eq(0, funcs.has('wsl'))
end
end)
end)