Skip to content

Commit 8c6556f

Browse files
committed
add coverage badge
1 parent 8805454 commit 8c6556f

File tree

4 files changed

+83
-6
lines changed

4 files changed

+83
-6
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,22 @@ before_install:
2121
- pip install --user hererocks
2222
- hererocks env --$LUA -rlatest # Use latest LuaRocks, install into 'env' directory.
2323
- source env/bin/activate # Add directory with all installed binaries to PATH.
24+
- luarocks install luacov
25+
- luarocks install luacov-coveralls --server=https://rocks.moonscript.org/dev
2426
# - luarocks install busted
2527
# - pip install cpp-coveralls
2628
# - luarocks install Lua-cURL --server=https://rocks.moonscript.org/dev
27-
# - luarocks install luacov-coveralls --server=https://rocks.moonscript.org/dev
2829
# - luarocks install lunitx
2930

3031
install:
3132
- luarocks make
3233

3334
script:
34-
- lua test.lua
35+
- lua -lluacov test.lua
3536
# - lunit.sh test.lua
3637

37-
#after_success:
38+
after_success:
39+
- luacov-coveralls -v -i iter.lua -i test.impl.lua
3840
# - coveralls -b .. -r .. --dump c.report.json
3941
# - luacov-coveralls -j c.report.json -v
4042

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Lua Iteration Library
22
========================
33
[![Build Status](https://travis-ci.org/starwing/luaiter.svg?branch=master)](https://travis-ci.org/starwing/luaiter)
4+
[![Coverage Status](https://coveralls.io/repos/github/starwing/luaiter/badge.svg?branch=master)](https://coveralls.io/github/starwing/luaiter?branch=master)
45

56
luaiter is a rewritten version of [luafun][1]: a high-performance
67
functional programming library for Lua designed with LuaJIT's trace

iter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ end
10561056

10571057
setmetatable(Operator, {
10581058
__call = function(self, op)
1059-
return iter._(assert(self[op], "not such operator"))
1059+
return iter._(assert(self[op], "no such operator"))
10601060
end
10611061
})
10621062

test.impl.lua

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ for _, a in iter(1, 2, 3, 4, 5, 6, 7) do print(a) end
142142
attempt to iterate a number value
143143
--]]
144144

145+
op"--"
146+
--[[ERROR
147+
no such operator
148+
--]]
145149

146150
--! each
147151

@@ -403,6 +407,24 @@ print(all(_"_1 >= 10, _1 <= 20", take(20, rand(10, 20))))
403407
true
404408
--]]
405409

410+
local f, r = split(5, range(10))
411+
f:each(print)
412+
print '---'
413+
r:each(print)
414+
--[[OUTPUT
415+
1
416+
2
417+
3
418+
4
419+
5
420+
---
421+
6
422+
7
423+
8
424+
9
425+
10
426+
--]]
427+
406428

407429
--iter.array = array
408430
--iter.resolve = resolve
@@ -644,6 +666,14 @@ iter {1,2,2,3,3,4,5} :groupby(_"_2, _2"):map(_G.unpack or table.unpack)
644666
5
645667
--]]
646668

669+
iter {1,2,2,3,3,4,5} :group(3):map(_G.unpack or table.unpack)
670+
:each(print)
671+
--[[OUTPUT
672+
1,1,2,2,3,2
673+
4,3,5,3,6,4
674+
7,5
675+
--]]
676+
647677
array {1,2,2,3,3,4,5} :packgroupby():flatmap(array):map(_G.unpack or table.unpack)
648678
:each(print)
649679
--[[OUTPUT
@@ -675,6 +705,14 @@ c,three
675705
d,nil
676706
--]]
677707

708+
zip(array{"a", "b", "c", "d"}, iter{"one", "two", "three"}):each(print)
709+
--[[OUTPUT
710+
a,1,one
711+
b,2,two
712+
c,3,three
713+
d,nil
714+
--]]
715+
678716
zipall(array{"a", "b", "c", "d"}, array{"one", "two", "three"}):each(print)
679717
--[[OUTPUT
680718
a,one
@@ -819,6 +857,35 @@ filter(_"_1 % 3 == 0", range(10)):each(print)
819857
9
820858
--]]
821859

860+
filterout(_"_1 % 3 == 0", range(10)):each(print)
861+
--[[OUTPUT
862+
1
863+
2
864+
4
865+
5
866+
7
867+
8
868+
10
869+
--]]
870+
871+
local f1,r1 = partition(_"_1 % 3 == 0", range(10))
872+
f1:each(print)
873+
print'---'
874+
r1:each(print)
875+
--[[OUTPUT
876+
3
877+
6
878+
9
879+
---
880+
1
881+
2
882+
4
883+
5
884+
7
885+
8
886+
10
887+
--]]
888+
822889
filter(_"_1 % 3 == 0", range(0)):each(print)
823890
--[[OUTPUT
824891
--]]
@@ -880,8 +947,6 @@ Emma
880947

881948
--! reducing
882949

883-
eq(_.self(range(10)).reduce(op.add)(), 55)
884-
885950
eq(range(10):map(-_1):reduce(_1+_2), -55)
886951
eq(foldl(_1 + _2, nil, range(5)), 15)
887952
eq(foldl(_1 + _2, 0, range(5)), 15)
@@ -924,6 +989,15 @@ eq(any(_1, {}), false)
924989

925990
--! operators
926991

992+
eq(_.self(range(10)).reduce(op.add)(), 55)
993+
eq(_(_1.range)(10)(_G):reduce(op.add), 55)
994+
_(_3)(_2, _1.._2, _.dots)("world", "hello", print, "a", "b", "c")
995+
print(_.andor(_.le(_1, _2), _3, _4)(1, 2, "foo", "bar"))
996+
--[[OUTPUT
997+
hello,worldhello,a,b,c
998+
foo
999+
--]]
1000+
9271001
eq(op, operator) -- an alias
9281002

9291003
local comparators = { 'le', 'lt', 'eq', 'ne', 'ge', 'gt' }

0 commit comments

Comments
 (0)