Skip to content

Commit 9125e91

Browse files
committed
Add new compatibility tests; fix an issue with "Yielded Reducers", which no one was using anyway. Common Reducers worked.
1 parent 2081e80 commit 9125e91

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

bench/compatible.json

+71
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,45 @@
18881888
null,
18891889
"apple"
18901890
],
1891+
[
1892+
[
1893+
1,
1894+
{
1895+
"var": "x"
1896+
},
1897+
3
1898+
],
1899+
{
1900+
"x": 2
1901+
},
1902+
[
1903+
1,
1904+
2,
1905+
3
1906+
]
1907+
],
1908+
[
1909+
{
1910+
"if": [
1911+
{
1912+
"var": "x"
1913+
},
1914+
[
1915+
{
1916+
"var": "y"
1917+
}
1918+
],
1919+
99
1920+
]
1921+
},
1922+
{
1923+
"x": true,
1924+
"y": 42
1925+
},
1926+
[
1927+
42
1928+
]
1929+
],
18911930
[
18921931
{
18931932
"and": [
@@ -2853,6 +2892,38 @@
28532892
},
28542893
10
28552894
],
2895+
[
2896+
{
2897+
"reduce": [
2898+
{
2899+
"var": "integers"
2900+
},
2901+
{
2902+
"+": [
2903+
{
2904+
"var": "current"
2905+
},
2906+
{
2907+
"var": "accumulator"
2908+
}
2909+
]
2910+
},
2911+
{
2912+
"var": "start_with"
2913+
}
2914+
]
2915+
},
2916+
{
2917+
"integers": [
2918+
1,
2919+
2,
2920+
3,
2921+
4
2922+
],
2923+
"start_with": 59
2924+
},
2925+
69
2926+
],
28562927
[
28572928
{
28582929
"reduce": [

bench/format-tests.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import fs from 'fs'
2+
const tests = JSON.parse(fs.readFileSync('tests.json', 'utf8'))
3+
fs.writeFileSync('tests.json', JSON.stringify(tests, undefined, 2))

bench/tests.json

+72
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,46 @@
19861986
null,
19871987
"apple"
19881988
],
1989+
"Arrays with logic",
1990+
[
1991+
[
1992+
1,
1993+
{
1994+
"var": "x"
1995+
},
1996+
3
1997+
],
1998+
{
1999+
"x": 2
2000+
},
2001+
[
2002+
1,
2003+
2,
2004+
3
2005+
]
2006+
],
2007+
[
2008+
{
2009+
"if": [
2010+
{
2011+
"var": "x"
2012+
},
2013+
[
2014+
{
2015+
"var": "y"
2016+
}
2017+
],
2018+
99
2019+
]
2020+
},
2021+
{
2022+
"x": true,
2023+
"y": 42
2024+
},
2025+
[
2026+
42
2027+
]
2028+
],
19892029
"# Compound Tests",
19902030
[
19912031
{
@@ -2973,6 +3013,38 @@
29733013
},
29743014
10
29753015
],
3016+
[
3017+
{
3018+
"reduce": [
3019+
{
3020+
"var": "integers"
3021+
},
3022+
{
3023+
"+": [
3024+
{
3025+
"var": "current"
3026+
},
3027+
{
3028+
"var": "accumulator"
3029+
}
3030+
]
3031+
},
3032+
{
3033+
"var": "start_with"
3034+
}
3035+
]
3036+
},
3037+
{
3038+
"integers": [
3039+
1,
3040+
2,
3041+
3,
3042+
4
3043+
],
3044+
"start_with": 59
3045+
},
3046+
69
3047+
],
29763048
[
29773049
{
29783050
"reduce": [

yieldingIterators.js

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function createYieldingControl (name, method, asyncMethod) {
4242
arr = input.arr
4343
cur = input.cur
4444
}
45+
cur = engine.run(cur, context, { above })
4546
const executed = method(input, context, above, engine)
4647
const iter = new ReduceIterator(arr, cur, executed)
4748
while (!iter.done()) {
@@ -63,6 +64,7 @@ function createYieldingControl (name, method, asyncMethod) {
6364
arr = input.arr
6465
cur = input.cur
6566
}
67+
cur = await engine.run(cur, context, { above })
6668
const executed = asyncMethod(input, context, above, engine)
6769
const iter = new AsyncReduceIterator(arr, cur, executed)
6870
while (!iter.done()) {
@@ -316,6 +318,7 @@ function createArrayIterativeMethod (
316318
cur = input.cur
317319
map = input.map
318320
}
321+
cur = engine.run(cur, context, { above })
319322
const executed = method(input, context, above, engine)
320323
const iter = new ReduceIterator(arr, cur, executed)
321324
iter.map = map
@@ -364,6 +367,7 @@ function createArrayIterativeMethod (
364367
cur = input.cur
365368
map = input.map
366369
}
370+
cur = await engine.run(cur, context, { above })
367371
const executed = asyncMethod(input, context, above, engine)
368372
const iter = new AsyncReduceIterator(arr, cur, executed)
369373
iter.map = map

0 commit comments

Comments
 (0)