Skip to content

Commit

Permalink
Convert tabs to spaces in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Sep 26, 2017
1 parent 1435364 commit cbdad3e
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 137 deletions.
8 changes: 4 additions & 4 deletions tests/test-array.lua
Expand Up @@ -3,10 +3,10 @@ local asserteq = require('pl.test').asserteq
local L = require 'pl.utils'. string_lambda

local A = {
{1,2,3,4},
{10,20,30,40},
{100,200,300,400},
{1000,2000,3000,4000},
{1,2,3,4},
{10,20,30,40},
{100,200,300,400},
{1000,2000,3000,4000},
}

asserteq(array.column(A,2),{2,20,200,2000})
Expand Down
10 changes: 5 additions & 5 deletions tests/test-compat.lua
Expand Up @@ -5,11 +5,11 @@ local compat = require "pl.compat"
local coroutine = require "coroutine"

local code_generator = coroutine.wrap(function()
local result = {"ret", "urn \"Hello World!\""}
for _,v in ipairs(result) do
coroutine.yield(v)
end
coroutine.yield(nil)
local result = {"ret", "urn \"Hello World!\""}
for _,v in ipairs(result) do
coroutine.yield(v)
end
coroutine.yield(nil)
end)

local f, err = compat.load(code_generator)
Expand Down
16 changes: 8 additions & 8 deletions tests/test-func.lua
Expand Up @@ -11,18 +11,18 @@ function pprint (t)
end

function test (e)
local v = {}
print('test',collect_values(e,v))
if #v > 0 then pprint(v) end
local rep = repr(e)
local v = {}
print('test',collect_values(e,v))
if #v > 0 then pprint(v) end
local rep = repr(e)
print(rep)
end

function teste (e,rs,ve)
local v = {}
collect_values(e,v)
if #v > 0 then asserteq(v,ve,nil,2) end
local rep = repr(e)
local v = {}
collect_values(e,v)
if #v > 0 then asserteq(v,ve,nil,2) end
local rep = repr(e)
asserteq(rep,rs)
end

Expand Down
4 changes: 2 additions & 2 deletions tests/test-path.lua
Expand Up @@ -2,11 +2,11 @@ local path = require 'pl.path'
asserteq = require 'pl.test'.asserteq

function quote(s)
return '"'..s..'"'
return '"'..s..'"'
end

function print2(s1,s2)
print(quote(s1),quote(s2))
print(quote(s1),quote(s2))
end

function testpath(pth,p1,p2,p3)
Expand Down
32 changes: 16 additions & 16 deletions tests/test-sip.lua
Expand Up @@ -52,13 +52,13 @@ check('just a string', 'not that string')
local months={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}

local function adjust_year(res)
if res.year < 100 then
if res.year < 70 then
res.year = res.year + 2000
else
res.year = res.year + 1900
end
end
if res.year < 100 then
if res.year < 70 then
res.year = res.year + 2000
else
res.year = res.year + 1900
end
end
end

local shortdate = sip.compile('$d{day}/$d{month}/$d{year}')
Expand All @@ -71,17 +71,17 @@ local function dcheck (d1,d2)
end

local function dates(str,tbl)
local res = {}
if shortdate(str,res) then
dcheck(res,tbl)
local res = {}
if shortdate(str,res) then
dcheck(res,tbl)
elseif isodate(str,res) then
dcheck(res,tbl)
elseif longdate(str,res) then
res.month = tablex.find(months,res.month)
dcheck(res,tbl)
else
assert(tbl == nil)
end
elseif longdate(str,res) then
res.month = tablex.find(months,res.month)
dcheck(res,tbl)
else
assert(tbl == nil)
end
end

dates ('10/12/2007',{year=2007,month=12,day=10})
Expand Down
48 changes: 24 additions & 24 deletions tests/test-stringx.lua
Expand Up @@ -292,30 +292,30 @@ asserteq(stringx.rstrip('--[hello] -- - ','-[] '),'--[hello')

local assert_str_round_trip = function(s)

local qs = stringx.quote_string(s)
local compiled, err = utils.load("return "..qs)

if not compiled then
print(
("stringx.quote_string assert failed: invalid string created: Received:\n%s\n\nCompiled to\n%s\n\nError:\t%s\n"):
format(s, qs, err)
)
error()
else
compiled = compiled()
end

if compiled ~= s then
print("strinx.quote_string assert Failed: String compiled but did not round trip.")
print("input string:\t\t",s, #s)
print("compiled string:\t", compiled, #compiled)
print("output string:\t\t",qs, #qs)
error()
else
-- print("input string:\t\t",s)
-- print("compiled string:\t", compiled)
-- print("output string:\t\t",qs)
end
local qs = stringx.quote_string(s)
local compiled, err = utils.load("return "..qs)

if not compiled then
print(
("stringx.quote_string assert failed: invalid string created: Received:\n%s\n\nCompiled to\n%s\n\nError:\t%s\n"):
format(s, qs, err)
)
error()
else
compiled = compiled()
end

if compiled ~= s then
print("strinx.quote_string assert Failed: String compiled but did not round trip.")
print("input string:\t\t",s, #s)
print("compiled string:\t", compiled, #compiled)
print("output string:\t\t",qs, #qs)
error()
else
-- print("input string:\t\t",s)
-- print("compiled string:\t", compiled)
-- print("output string:\t\t",qs)
end
end

assert_str_round_trip( "normal string with nothing weird.")
Expand Down
44 changes: 22 additions & 22 deletions tests/test-tablex.lua
Expand Up @@ -16,49 +16,49 @@ end


asserteq(
copy {10,20,30},
{10,20,30}
copy {10,20,30},
{10,20,30}
)

asserteq(
deepcopy {10,20,{30,40}},
{10,20,{30,40}}
deepcopy {10,20,{30,40}},
{10,20,{30,40}}
)

asserteq(
pairmap(function(i,v) return v end,{10,20,30}),
{10,20,30}
pairmap(function(i,v) return v end,{10,20,30}),
{10,20,30}
)

asserteq_no_order(
pairmap(L'_',{fred=10,bonzo=20}),
{'fred','bonzo'}
pairmap(L'_',{fred=10,bonzo=20}),
{'fred','bonzo'}
)

asserteq_no_order(
pairmap(function(k,v) return v end,{fred=10,bonzo=20}),
{10,20}
pairmap(function(k,v) return v end,{fred=10,bonzo=20}),
{10,20}
)

asserteq_no_order(
pairmap(function(i,v) return v,i end,{10,20,30}),
{10,20,30}
pairmap(function(i,v) return v,i end,{10,20,30}),
{10,20,30}
)

asserteq(
pairmap(function(k,v) return {k,v},k end,{one=1,two=2}),
{one={'one',1},two={'two',2}}
pairmap(function(k,v) return {k,v},k end,{one=1,two=2}),
{one={'one',1},two={'two',2}}
)
-- same as above, using string lambdas
asserteq(
pairmap(L'|k,v|{k,v},k',{one=1,two=2}),
{one={'one',1},two={'two',2}}
pairmap(L'|k,v|{k,v},k',{one=1,two=2}),
{one={'one',1},two={'two',2}}
)


asserteq(
map(function(v) return v*v end,{10,20,30}),
{100,400,900}
map(function(v) return v*v end,{10,20,30}),
{100,400,900}
)

-- extra arguments to map() are passed to the function; can use
Expand All @@ -81,13 +81,13 @@ asserteq(

-- mapn operates over an arbitrary number of input tables (but use map2 for n=2)
asserteq(
mapn(function(x,y,z) return x+y+z end, {1,2,3},{10,20,30},{100,200,300}),
{111,222,333}
mapn(function(x,y,z) return x+y+z end, {1,2,3},{10,20,30},{100,200,300}),
{111,222,333}
)

asserteq(
mapn(math.max, {1,20,300},{10,2,3},{100,200,100}),
{100,200,300}
mapn(math.max, {1,20,300},{10,2,3},{100,200,100}),
{100,200,300}
)

asserteq(
Expand Down

0 comments on commit cbdad3e

Please sign in to comment.