aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/codes_from_doc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/outputs/codes_from_doc.lua')
-rw-r--r--spec/outputs/codes_from_doc.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua
index d6617a9..de5abdd 100644
--- a/spec/outputs/codes_from_doc.lua
+++ b/spec/outputs/codes_from_doc.lua
@@ -737,6 +737,36 @@ end
737 local first = select(1, ...) 737 local first = select(1, ...)
738 return print(ok, count, first) 738 return print(ok, count, first)
739end)(fn(true)) 739end)(fn(true))
740local f
741f = function(...)
742 local t = {
743 n = select("#", ...),
744 ...
745 }
746 print("argument count:", t.n)
747 print("table length:", #t)
748 for i = 1, t.n do
749 print(t[i])
750 end
751end
752f(1, 2, 3)
753f("a", "b", "c", "d")
754f()
755local process
756process = function(...)
757 local args = {
758 n = select("#", ...),
759 ...
760 }
761 local sum = 0
762 for i = 1, args.n do
763 if args[i] ~= nil and type(args[i]) == "number" then
764 sum = sum + args[i]
765 end
766 end
767 return sum
768end
769process(1, nil, 3, nil, 5)
740Rx.Observable.fromRange(1, 8):filter(function(x) 770Rx.Observable.fromRange(1, 8):filter(function(x)
741 return x % 2 == 0 771 return x % 2 == 0
742end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) 772end):concat(Rx.Observable.of('who do we appreciate')):map(function(value)
@@ -3215,6 +3245,36 @@ end
3215 local first = select(1, ...) 3245 local first = select(1, ...)
3216 return print(ok, count, first) 3246 return print(ok, count, first)
3217end)(fn(true)) 3247end)(fn(true))
3248local f
3249f = function(...)
3250 local t = {
3251 n = select("#", ...),
3252 ...
3253 }
3254 print("argument count:", t.n)
3255 print("table length:", #t)
3256 for i = 1, t.n do
3257 print(t[i])
3258 end
3259end
3260f(1, 2, 3)
3261f("a", "b", "c", "d")
3262f()
3263local process
3264process = function(...)
3265 local args = {
3266 n = select("#", ...),
3267 ...
3268 }
3269 local sum = 0
3270 for i = 1, args.n do
3271 if args[i] ~= nil and type(args[i]) == "number" then
3272 sum = sum + args[i]
3273 end
3274 end
3275 return sum
3276end
3277process(1, nil, 3, nil, 5)
3218Rx.Observable.fromRange(1, 8):filter(function(x) 3278Rx.Observable.fromRange(1, 8):filter(function(x)
3219 return x % 2 == 0 3279 return x % 2 == 0
3220end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) 3280end):concat(Rx.Observable.of('who do we appreciate')):map(function(value)