mirror of
https://github.com/TangentFoxy/semver.lua.git
synced 2025-07-27 18:42:21 +00:00
updates to make 1.1.1 definitive
This commit is contained in:
37
.travis.yml
37
.travis.yml
@@ -1,12 +1,37 @@
|
||||
language: erlang
|
||||
|
||||
env:
|
||||
- LUA=""
|
||||
- LUA="luajit"
|
||||
global:
|
||||
- LUAROCKS_BASE=luarocks-2.0.13
|
||||
matrix:
|
||||
- LUA=lua5.1 LUA_DEV=liblua5.1-dev LUA_VER=5.1 LUA_SFX=5.1 LUA_INCDIR=/usr/include/lua5.1
|
||||
- LUA=lua5.2 LUA_DEV=liblua5.2-dev LUA_VER=5.2 LUA_SFX=5.2 LUA_INCDIR=/usr/include/lua5.2
|
||||
- LUA=luajit LUA_DEV=libluajit-5.1-dev LUA_VER=5.1 LUA_SFX=jit LUA_INCDIR=/usr/include/luajit-2.0
|
||||
|
||||
before_install:
|
||||
- if [ $LUA = "luajit" ]; then
|
||||
sudo add-apt-repository ppa:mwild1/ppa -y && sudo apt-get update -y;
|
||||
fi
|
||||
- sudo apt-get install $LUA
|
||||
- sudo apt-get install $LUA_DEV
|
||||
- lua$LUA_SFX -v
|
||||
# Install a recent luarocks release
|
||||
- wget http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz
|
||||
- tar zxvpf $LUAROCKS_BASE.tar.gz
|
||||
- cd $LUAROCKS_BASE
|
||||
- ./configure
|
||||
--lua-version=$LUA_VER --lua-suffix=$LUA_SFX --with-lua-include="$LUA_INCDIR"
|
||||
- sudo make
|
||||
- sudo make install
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
|
||||
install:
|
||||
- sudo apt-get install luajit
|
||||
- sudo apt-get install luarocks
|
||||
- sudo luarocks install telescope
|
||||
- sudo -E luarocks install busted
|
||||
|
||||
script: "tsc -f spec/*"
|
||||
script:
|
||||
- sudo -E busted -v
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
on_failure: always
|
||||
|
@@ -1,14 +1,14 @@
|
||||
h1. semver.lua
|
||||
# semver.lua
|
||||
|
||||
!https://travis-ci.org/kikito/semver.lua.png?branch=master!:https://travis-ci.org/kikito/semver.lua
|
||||
[](https://travis-ci.org/kikito/semver.lua)
|
||||
|
||||
Semantic versioning for Lua.
|
||||
|
||||
See http://semver.org/ for details about semantic versioning.
|
||||
|
||||
h1. Documentation
|
||||
# Documentation
|
||||
|
||||
<pre class="lua">
|
||||
``` lua
|
||||
local v = require 'semver'
|
||||
|
||||
-- two ways of creating it: with separate parameters, or with one string
|
||||
@@ -54,24 +54,25 @@ v(1,0,0):nextPatch() -- v1.0.1
|
||||
v(1,2,3):nextMinor() -- v1.3.0 . Notice the patch resets to 0
|
||||
v(1,2,3):nextMajor() -- v2.0.0 . Minor and patch are reset to 0
|
||||
|
||||
</pre>
|
||||
```
|
||||
|
||||
# Installation
|
||||
|
||||
h1. Installation
|
||||
Just copy the semver.lua file wherever you want it (for example on a lib/ folder). Then write this in any Lua file where you want to use it. You must assign the require to a global or local variable (I use a local `v`):
|
||||
|
||||
Just copy the semver.lua file wherever you want it (for example on a lib/ folder). Then write this in any Lua file where you want to use it. You must assign the require to a global or local variable (I use a local @v@):
|
||||
``` lua
|
||||
local v = require 'semver'
|
||||
```
|
||||
|
||||
<pre>local v = require 'semver'</pre>
|
||||
Using `v` allows for the nice string syntax: `v'1.2.3-alpha'`.
|
||||
|
||||
Using @v@ allows for the nice string syntax: @v'1.2.3-alpha'@.
|
||||
|
||||
The @package.path@ variable must be configured so that the folder in which middleclass.lua is copied is available, of course.
|
||||
The `package.path` variable must be configured so that the folder in which middleclass.lua is copied is available, of course.
|
||||
|
||||
Please make sure that you read the license, too (for your convenience it's now included at the beginning of the semver.lua file).
|
||||
|
||||
h1. Notes about version comparison
|
||||
# Notes about version comparison
|
||||
|
||||
Version comparison is done according to the specs:
|
||||
Version comparison is done according to the semver 2.0.0 specs:
|
||||
|
||||
Major, minor, and patch versions are always compared numerically.
|
||||
|
||||
@@ -81,11 +82,18 @@ Pre-release and build version precedence MUST be determined by comparing each do
|
||||
* Identifiers with letters or dashes are compared lexically in ASCII sort order.
|
||||
* Numeric identifiers always have lower precedence than non-numeric identifiers
|
||||
|
||||
h1. Specs
|
||||
# Specs
|
||||
|
||||
This project uses "telescope":https://github.com/norman/telescope for its specs. If you want to run the specs, you will have to install telescope first. Then just execute the following from the root inspect folder:
|
||||
This project uses "busted":http://olivinelabs.com/busted/ for its specs. If you want to run the specs, you will have to install telescope first. Then just execute the following from the root inspect folder:
|
||||
|
||||
<pre>
|
||||
tsc -f spec/*
|
||||
</pre>
|
||||
```
|
||||
busted
|
||||
```
|
||||
|
||||
# Changelog
|
||||
|
||||
## v1.1.1:
|
||||
* Removed global variable which was declared by mistake
|
||||
* Changed spec tool from telescope to busted
|
||||
* Changed README format from textile to markdown
|
||||
|
49
semver.lua
49
semver.lua
@@ -1,10 +1,32 @@
|
||||
-- semver.lua - v1.1.0 (2012-01)
|
||||
-- Copyright (c) 2012 Enrique García Cota
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-- See http://semver.org for details
|
||||
local version = {}
|
||||
local semver = {
|
||||
_VERSION = '1.1.1',
|
||||
_DESCRIPTION = 'semver for Lua',
|
||||
_URL = 'https://github.com/kikito/semver.lua',
|
||||
_LICENSE = [[
|
||||
MIT LICENSE
|
||||
|
||||
Copyright (c) 2015 Enrique García Cota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
]]
|
||||
}
|
||||
|
||||
local function checkPositiveInteger(number, name)
|
||||
assert(number >= 0, name .. ' must be a valid positive number')
|
||||
@@ -112,13 +134,13 @@ end
|
||||
local methods = {}
|
||||
|
||||
function methods:nextMajor()
|
||||
return version(self.major + 1, 0, 0)
|
||||
return semver(self.major + 1, 0, 0)
|
||||
end
|
||||
function methods:nextMinor()
|
||||
return version(self.major, self.minor + 1, 0)
|
||||
return semver(self.major, self.minor + 1, 0)
|
||||
end
|
||||
function methods:nextPatch()
|
||||
return version(self.major, self.minor, self.patch + 1)
|
||||
return semver(self.major, self.minor, self.patch + 1)
|
||||
end
|
||||
|
||||
local mt = { __index = methods }
|
||||
@@ -166,8 +188,7 @@ local function new(major, minor, patch, prerelease, build)
|
||||
return setmetatable(result, mt)
|
||||
end
|
||||
|
||||
setmetatable(version, { __call = function(_, ...) return new(...) end })
|
||||
setmetatable(semver, { __call = function(_, ...) return new(...) end })
|
||||
semver._VERSION= semver(semver._VERSION)
|
||||
|
||||
version._VERSION = version('1.1.0')
|
||||
|
||||
return version
|
||||
return semver
|
||||
|
@@ -1,18 +1,18 @@
|
||||
local v = require 'semver'
|
||||
|
||||
local function checkVersion(ver, major, minor, patch, prerelease, build)
|
||||
assert_equal(major, ver.major)
|
||||
assert_equal(minor, ver.minor)
|
||||
assert_equal(patch, ver.patch)
|
||||
assert_equal(prerelease, ver.prerelease)
|
||||
assert_equal(build, ver.build)
|
||||
assert.equal(major, ver.major)
|
||||
assert.equal(minor, ver.minor)
|
||||
assert.equal(patch, ver.patch)
|
||||
assert.equal(prerelease, ver.prerelease)
|
||||
assert.equal(build, ver.build)
|
||||
end
|
||||
|
||||
context('semver', function()
|
||||
describe('semver', function()
|
||||
|
||||
context('creation', function()
|
||||
describe('creation', function()
|
||||
|
||||
context('from numbers', function()
|
||||
describe('from numbers', function()
|
||||
it('parses 3 numbers correctly', function()
|
||||
checkVersion(v(1,2,3), 1,2,3)
|
||||
end)
|
||||
@@ -62,170 +62,170 @@ context('semver', function()
|
||||
|
||||
describe('errors', function()
|
||||
test('no parameters are passed', function()
|
||||
assert_error(function() v() end)
|
||||
assert.error(function() v() end)
|
||||
end)
|
||||
test('negative numbers', function()
|
||||
assert_error(function() v(-1, 0, 0) end)
|
||||
assert_error(function() v( 0,-1, 0) end)
|
||||
assert_error(function() v( 0, 0,-1) end)
|
||||
assert.error(function() v(-1, 0, 0) end)
|
||||
assert.error(function() v( 0,-1, 0) end)
|
||||
assert.error(function() v( 0, 0,-1) end)
|
||||
end)
|
||||
test('floats', function()
|
||||
assert_error(function() v(.1, 0, 0) end)
|
||||
assert_error(function() v( 0,.1, 0) end)
|
||||
assert_error(function() v( 0, 0,.1) end)
|
||||
assert.error(function() v(.1, 0, 0) end)
|
||||
assert.error(function() v( 0,.1, 0) end)
|
||||
assert.error(function() v( 0, 0,.1) end)
|
||||
end)
|
||||
test('empty string', function()
|
||||
assert_error(function() v("") end)
|
||||
assert.error(function() v("") end)
|
||||
end)
|
||||
test('garbage at the beginning of the string', function()
|
||||
assert_error(function() v("foobar1.2.3") end)
|
||||
assert.error(function() v("foobar1.2.3") end)
|
||||
end)
|
||||
test('garbage at the end of the string', function()
|
||||
assert_error(function() v("1.2.3foobar") end)
|
||||
assert.error(function() v("1.2.3foobar") end)
|
||||
end)
|
||||
test('a non-string or number is passed', function()
|
||||
assert_error(function() v({}) end)
|
||||
assert.error(function() v({}) end)
|
||||
end)
|
||||
test('an invalid prerelease', function()
|
||||
assert_error(function() v'1.2.3-%?' end)
|
||||
assert.error(function() v'1.2.3-%?' end)
|
||||
end)
|
||||
test('an invalid build', function()
|
||||
assert_error(function() v'1.2.3+%?' end)
|
||||
assert.error(function() v'1.2.3+%?' end)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("tostring", function()
|
||||
it("works with major, minor and patch", function()
|
||||
assert_equal("1.2.3", tostring(v(1,2,3)))
|
||||
assert.equal("1.2.3", tostring(v(1,2,3)))
|
||||
end)
|
||||
|
||||
it("works with a prerelease", function()
|
||||
assert_equal("1.2.3-beta", tostring(v(1,2,3,'beta')))
|
||||
assert.equal("1.2.3-beta", tostring(v(1,2,3,'beta')))
|
||||
end)
|
||||
it("works with a build", function()
|
||||
assert_equal("1.2.3+foobar", tostring(v(1,2,3,nil,'foobar')))
|
||||
assert.equal("1.2.3+foobar", tostring(v(1,2,3,nil,'foobar')))
|
||||
end)
|
||||
it("works with a prerelease and a build", function()
|
||||
assert_equal("1.2.3-alpha+foobar", tostring(v'1.2.3-alpha+foobar'))
|
||||
assert.equal("1.2.3-alpha+foobar", tostring(v'1.2.3-alpha+foobar'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("==", function()
|
||||
it("is true when major, minor and patch are the same", function()
|
||||
assert_equal(v(1,2,3), v'1.2.3')
|
||||
assert.equal(v(1,2,3), v'1.2.3')
|
||||
end)
|
||||
it("is false when major, minor and patch are not the same", function()
|
||||
assert_not_equal(v(1,2,3), v(4,5,6))
|
||||
assert.not_equal(v(1,2,3), v(4,5,6))
|
||||
end)
|
||||
it("false if all is the same except the prerelease", function()
|
||||
assert_not_equal(v(1,2,3), v'1.2.3-alpha')
|
||||
assert.not_equal(v(1,2,3), v'1.2.3-alpha')
|
||||
end)
|
||||
it("false if all is the same except the build", function()
|
||||
assert_not_equal(v(1,2,3), v'1.2.3+peter.1')
|
||||
assert.not_equal(v(1,2,3), v'1.2.3+peter.1')
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("<", function()
|
||||
test("true if major < minor", function()
|
||||
assert_less_than(v'1.100.10', v'2.0.0')
|
||||
assert.is_true(v'1.100.10' < v'2.0.0')
|
||||
end)
|
||||
test("false if major > minor", function()
|
||||
assert_greater_than(v'2', v'1')
|
||||
assert.is_true(v'2' > v'1')
|
||||
end)
|
||||
test("true if major = major but minor < minor", function()
|
||||
assert_less_than(v'1.2.0', v'1.3.0')
|
||||
assert.is_true(v'1.2.0' < v'1.3.0')
|
||||
end)
|
||||
test("false if minor < minor", function()
|
||||
assert_greater_than(v'1.1', v'1.0')
|
||||
assert.is_false(v'1.1' < v'1.0')
|
||||
end)
|
||||
test("true if major =, minor =, but patch <", function()
|
||||
assert_less_than(v'0.0.1', v'0.0.10')
|
||||
assert.is_true(v'0.0.1' < v'0.0.10')
|
||||
end)
|
||||
test("false if major =, minor =, but patch >", function()
|
||||
assert_greater_than(v'0.0.2', v'0.0.1')
|
||||
assert.is_true(v'0.0.2' > v'0.0.1')
|
||||
end)
|
||||
describe("prereleases", function()
|
||||
test("false if exact same prerelease", function()
|
||||
assert_false(v'1.0.0-beta' < v'1.0.0-beta')
|
||||
assert.is_false(v'1.0.0-beta' < v'1.0.0-beta')
|
||||
end)
|
||||
test("a prerelease version is less than the official version", function()
|
||||
assert_less_than(v'1.0.0-rc1', v'1.0.0')
|
||||
assert.is_true(v'1.0.0-rc1' < v'1.0.0')
|
||||
end)
|
||||
test("identifiers with only digits are compared numerically", function()
|
||||
assert_less_than(v'1.0.0-1', v'1.0.0-2')
|
||||
assert_less_than(v'1.0.0-2', v'1.0.0-10')
|
||||
assert.is_true(v'1.0.0-1' < v'1.0.0-2')
|
||||
assert.is_true(v'1.0.0-2' < v'1.0.0-10')
|
||||
end)
|
||||
test("itendifiers with letters or dashes are compared lexiconumerically", function()
|
||||
assert_less_than(v'1.0.0-alpha', v'1.0.0-beta')
|
||||
assert_less_than(v'1.0.0-alpha-10', v'1.0.0-alpha-2')
|
||||
test("idendifiers with letters or dashes are compared lexiconumerically", function()
|
||||
assert.is_true(v'1.0.0-alpha' < v'1.0.0-beta')
|
||||
assert.is_true(v'1.0.0-alpha-10' < v'1.0.0-alpha-2')
|
||||
end)
|
||||
test("numerical ids always have less priority than lexiconumericals", function()
|
||||
assert_less_than(v'1.0.0-1', v'1.0.0-alpha')
|
||||
assert_less_than(v'1.0.0-2', v'1.0.0-1asdf')
|
||||
assert.is_true(v'1.0.0-1' < v'1.0.0-alpha')
|
||||
assert.is_true(v'1.0.0-2' < v'1.0.0-1asdf')
|
||||
end)
|
||||
test("identifiers can be separated by colons; they must be compared individually", function()
|
||||
assert_less_than(v'1.0.0-alpha', v'1.0.0-alpha.1')
|
||||
assert_less_than(v'1.0.0-alpha.1', v'1.0.0-beta.2')
|
||||
assert_less_than(v'1.0.0-beta.2', v'1.0.0-beta.11')
|
||||
assert_less_than(v'1.0.0-beta.11', v'1.0.0-rc.1')
|
||||
assert.is_true(v'1.0.0-alpha' < v'1.0.0-alpha.1')
|
||||
assert.is_true(v'1.0.0-alpha.1' < v'1.0.0-beta.2')
|
||||
assert.is_true(v'1.0.0-beta.2' < v'1.0.0-beta.11')
|
||||
assert.is_true(v'1.0.0-beta.11' < v'1.0.0-rc.1')
|
||||
end)
|
||||
end)
|
||||
describe("builds", function()
|
||||
test("false if exact same build", function()
|
||||
assert_false(v'1.0.0+build1' < v'1.0.0+build1')
|
||||
assert.is_false(v'1.0.0+build1' < v'1.0.0+build1')
|
||||
end)
|
||||
test("a regular (not-build) version is always less than a build version", function()
|
||||
assert_less_than(v'1.0.0', v'1.0.0+12')
|
||||
assert.is_true(v'1.0.0' < v'1.0.0+12')
|
||||
end)
|
||||
test("identifiers with only digits are compared numerically", function()
|
||||
assert_less_than(v'1.0.0+1', v'1.0.0+2')
|
||||
assert_less_than(v'1.0.0+2', v'1.0.0+10')
|
||||
assert.is_true(v'1.0.0+1' < v'1.0.0+2')
|
||||
assert.is_true(v'1.0.0+2' < v'1.0.0+10')
|
||||
end)
|
||||
test("idendifiers with letters or dashes are compared lexiconumerically", function()
|
||||
assert_less_than(v'1.0.0+build1', v'1.0.0+build2')
|
||||
assert_less_than(v'1.0.0+build10', v'1.0.0+build2')
|
||||
assert.is_true(v'1.0.0+build1' < v'1.0.0+build2')
|
||||
assert.is_true(v'1.0.0+build10' < v'1.0.0+build2')
|
||||
end)
|
||||
test("numerical ids always have less priority than lexiconumericals", function()
|
||||
assert_less_than(v'1.0.0+1', v'1.0.0+build1')
|
||||
assert_less_than(v'1.0.0+2', v'1.0.0+1build')
|
||||
assert.is_true(v'1.0.0+1' < v'1.0.0+build1')
|
||||
assert.is_true(v'1.0.0+2' < v'1.0.0+1build')
|
||||
end)
|
||||
test("identifiers can be separated by colons; they must be compared individually", function()
|
||||
assert_less_than(v'1.0.0+0.3.7', v'1.3.7+build')
|
||||
assert_less_than(v'1.3.7+build', v'1.3.7+build.2.b8f12d7')
|
||||
assert_less_than(v'1.3.7+build.2.b8f12d7', v'1.3.7+build.11.e0f985a')
|
||||
assert.is_true(v'1.0.0+0.3.7' < v'1.3.7+build')
|
||||
assert.is_true(v'1.3.7+build' < v'1.3.7+build.2.b8f12d7')
|
||||
assert.is_true(v'1.3.7+build.2.b8f12d7' < v'1.3.7+build.11.e0f985a')
|
||||
end)
|
||||
end)
|
||||
test("prereleases + builds", function()
|
||||
assert_less_than(v'1.0.0-rc.1', v'1.0.0-rc.1+build.1')
|
||||
assert_less_than(v'1.0.0-rc.1+build.1', v'1.0.0')
|
||||
assert.is_true(v'1.0.0-rc.1' < v'1.0.0-rc.1+build.1')
|
||||
assert.is_true(v'1.0.0-rc.1+build.1' < v'1.0.0')
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("nextPatch", function()
|
||||
it("increases the patch number by 1", function()
|
||||
assert_equal(v'1.0.1', v'1.0.0':nextPatch())
|
||||
assert.equal(v'1.0.1', v'1.0.0':nextPatch())
|
||||
end)
|
||||
it("resets prerelease and build", function()
|
||||
assert_equal(v'1.0.1', v'1.0.0-a+b':nextPatch())
|
||||
assert.equal(v'1.0.1', v'1.0.0-a+b':nextPatch())
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("nextMinor", function()
|
||||
it("increases the minor number by 1", function()
|
||||
assert_equal(v'1.2.0', v'1.1.0':nextMinor())
|
||||
assert.equal(v'1.2.0', v'1.1.0':nextMinor())
|
||||
end)
|
||||
it("resets the patch number, prerelease and build", function()
|
||||
assert_equal(v'1.2.0', v'1.1.7-a+b':nextMinor())
|
||||
assert.equal(v'1.2.0', v'1.1.7-a+b':nextMinor())
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("nextMajor", function()
|
||||
it("increases the major number by 1", function()
|
||||
assert_equal(v'2.0.0', v'1.0.0':nextMajor())
|
||||
assert.equal(v'2.0.0', v'1.0.0':nextMajor())
|
||||
end)
|
||||
it("resets the minor, patch, prerelease and build", function()
|
||||
assert_equal(v'2.0.0', v'1.2.3-a+b':nextMajor())
|
||||
assert.equal(v'2.0.0', v'1.2.3-a+b':nextMajor())
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -235,32 +235,32 @@ context('semver', function()
|
||||
-- in other words, "it's safe to upgrade from a to b"
|
||||
describe("^", function()
|
||||
test("true for self", function()
|
||||
assert_true(v(1,2,3) ^ v(1,2,3))
|
||||
assert.is_true(v(1,2,3) ^ v(1,2,3))
|
||||
end)
|
||||
test("different major versions mean it's always unsafe", function()
|
||||
assert_false(v(2,0,0) ^ v(3,0,0))
|
||||
assert_false(v(2,0,0) ^ v(1,0,0))
|
||||
assert.is_false(v(2,0,0) ^ v(3,0,0))
|
||||
assert.is_false(v(2,0,0) ^ v(1,0,0))
|
||||
end)
|
||||
|
||||
test("patches, prereleases and builds are ignored", function()
|
||||
assert_true(v(1,2,3) ^ v(1,2,0))
|
||||
assert_true(v(1,2,3) ^ v(1,2,5))
|
||||
assert_true(v(1,2,3,'foo') ^ v(1,2,3))
|
||||
assert_true(v(1,2,3,nil,'bar') ^ v(1,2,3))
|
||||
assert.is_true(v(1,2,3) ^ v(1,2,0))
|
||||
assert.is_true(v(1,2,3) ^ v(1,2,5))
|
||||
assert.is_true(v(1,2,3,'foo') ^ v(1,2,3))
|
||||
assert.is_true(v(1,2,3,nil,'bar') ^ v(1,2,3))
|
||||
end)
|
||||
|
||||
test("it's safe to upgrade to a newer minor version", function()
|
||||
assert_true(v(1,2,0) ^ v(1,5,0))
|
||||
assert.is_true(v(1,2,0) ^ v(1,5,0))
|
||||
end)
|
||||
test("it's unsafe to downgrade to an earlier minor version", function()
|
||||
assert_false(v(1,5,0) ^ v(1,2,0))
|
||||
assert.is_false(v(1,5,0) ^ v(1,2,0))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("_VERSION", function()
|
||||
it("can be extracted from the lib", function()
|
||||
local x = v._VERSION
|
||||
assert_equal('table', type(x))
|
||||
assert.equal('table', type(x))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user