aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAsbjørn Sloth Tønnesen <ast@fiberby.net>2017-03-06 10:54:38 +0000
committerAsbjørn Sloth Tønnesen <ast@2e8.dk>2017-03-06 10:54:38 +0000
commita2216e14521763e702f69a9bfd046aa15a5b3f52 (patch)
tree2d676a793e27d66360b470223cc61d9d0ebd5dae /test
parent57d276460839518fdecfcde16f256415417e0164 (diff)
downloadlua-inet-a2216e14521763e702f69a9bfd046aa15a5b3f52.tar.gz
lua-inet-a2216e14521763e702f69a9bfd046aa15a5b3f52.tar.xz
lua-inet-a2216e14521763e702f69a9bfd046aa15a5b3f52.zip
luacheck: clean up
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Diffstat (limited to 'test')
-rw-r--r--test/inet.lua15
-rw-r--r--test/inet_set.lua4
2 files changed, 9 insertions, 10 deletions
diff --git a/test/inet.lua b/test/inet.lua
index 43432cc..e86c074 100644
--- a/test/inet.lua
+++ b/test/inet.lua
@@ -12,6 +12,7 @@ local function dontparse(...)
end
return test.new(function()
+ local ip
-- parsing
parse('1:2:3:4:5:6:7:8')
parse('::1/33')
@@ -35,10 +36,10 @@ return test.new(function()
assert(tostring(parse('1:ffff:ffff:fe00::/56') * 2) == '2::/56')
assert(tostring(parse('1:ffff:ffff:fe00::/56') * 2 * -2)
== '1:ffff:ffff:fe00::/56')
- local ip = inet('10.0.0.0/33')
+ ip = inet('10.0.0.0/33')
assert(ip == nil)
- local ip = inet('10.0.0.0/24')
+ ip = inet('10.0.0.0/24')
assert(type(ip) == 'table')
assert(#ip == 24, 'incorrect netmask')
assert(tostring(ip) == '10.0.0.0/24', 'not human readable')
@@ -84,14 +85,14 @@ return test.new(function()
-- test inet*.network
assert(inet('10.0.0.1/30'):network() == inet('10.0.0.0/30'), 'inet4.network() is broken')
assert(inet('1::2/64'):network() == inet('1::/64'), 'inet6.network() is broken')
- local ip = inet('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/62')
+ ip = inet('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/62')
assert((ip/22):network() == inet('ffff:fc00::/22'), 'inet6.network() is broken')
assert((ip/27):network() == inet('ffff:ffe0::/27'), 'inet6.network() is broken')
--- test inet4:flip
- assert(inet('10.0.0.1/24'):flip() == inet('10.0.1.1/24'), 'inet.flip() is broken')
- assert(inet('10.0.0.0/24'):flip() == inet('10.0.1.0/24'), 'inet.flip() is broken')
- assert(inet('10.0.0.0/24'):flip():flip() == inet('10.0.0.0/24'), 'inet.flip() is broken')
+ assert(inet('10.0.0.1/24'):flip() == inet('10.0.1.1/24'), 'inet4.flip() is broken')
+ assert(inet('10.0.0.0/24'):flip() == inet('10.0.1.0/24'), 'inet4.flip() is broken')
+ assert(inet('10.0.0.0/24'):flip():flip() == inet('10.0.0.0/24'), 'inet4.flip() is broken')
assert(inet('10.20.30.0/24'):flip() == inet('10.20.31.0/24'))
assert(inet('10.20.30.5/24'):flip() == inet('10.20.31.5/24'))
assert(inet('10.20.30.5/32'):flip() == inet('10.20.30.4/32'))
@@ -104,7 +105,7 @@ return test.new(function()
assert(inet('::1/32'):flip() == inet('0:1::1/32'))
assert(inet('::1/48'):flip() == inet('0:0:1::1/48'))
for i=1,#ips do
- local ip = ips[i]
+ ip = ips[i]
for j=1,128 do
local foo = ip / j
local bar = foo:flip()
diff --git a/test/inet_set.lua b/test/inet_set.lua
index ec16d8c..4c673d5 100644
--- a/test/inet_set.lua
+++ b/test/inet_set.lua
@@ -2,7 +2,7 @@ local inet = require 'inet'
local inet_set = require 'inet.set'
local test = require 'test'
-function agg_set(a, b)
+local function agg_set(a, b)
inet_set.aggregate(a)
assert(#a == #b, 'wrong set size')
for i=1,#a do
@@ -13,8 +13,6 @@ end
return test.new(function()
- local ip = inet('10.0.0.0/24')
-
agg_set({
inet('10.0.0.0/24'),
inet('10.0.1.0/24'),