Test on iterator filter and map
This commit is contained in:
parent
d7a7b3218c
commit
cde2efacf1
@ -23,6 +23,6 @@ func TestIteratorParser(t *testing.T) {
|
|||||||
/* 12 */ {`include "test-resources/filter.expr"; it=$(ds,10); it++`, int64(2), nil},
|
/* 12 */ {`include "test-resources/filter.expr"; it=$(ds,10); it++`, int64(2), nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
runTestSuiteSpec(t, section, inputs, 12)
|
//runTestSuiteSpec(t, section, inputs, 12)
|
||||||
//runTestSuite(t, section, inputs)
|
runTestSuite(t, section, inputs)
|
||||||
}
|
}
|
||||||
|
15
test-resources/filter.expr
Normal file
15
test-resources/filter.expr
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
ds={
|
||||||
|
"init":func(end){@end=end; @current=0 but true},
|
||||||
|
"current":func(){current},
|
||||||
|
"next":func(){
|
||||||
|
((next=current+1) <= end) ? [true] {@current=next but current} :: {nil}
|
||||||
|
}
|
||||||
|
, "filter":func(item,index) { item > 0 }
|
||||||
|
, "map": func(item,index) { item * 2 }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Example
|
||||||
|
;
|
||||||
|
it=$(ds,3);
|
||||||
|
add(it)
|
||||||
|
*/
|
Loading…
Reference in New Issue
Block a user