|
1 |
| -// KLUDGE HAZARD The core-js shims are written as sloppy code |
2 |
| -// and so introduce sloppy functions. |
| 1 | +import './enforce-cjs-strict.js'; |
| 2 | +import './core-js-configuration.js'; |
3 | 3 | import 'core-js/actual/async-iterator/index.js';
|
4 |
| -import test from 'ava'; |
5 | 4 | import '../index.js';
|
| 5 | +import './lockdown-safe.js'; |
| 6 | +import test from 'ava'; |
6 | 7 |
|
7 |
| -// KLUDGE HAZARD only for testing with the sloppy modules of the |
8 |
| -// core-js iterator shim. |
9 |
| -// We mutate the permits to tolerates the sloppy functions for testing |
10 |
| -// by sacrificing security. The caller and arguments properties of |
11 |
| -// sloppy functions violate ocap encapsulation rules. |
12 |
| -import { AsyncFunctionInstance } from '../src/permits.js'; |
13 |
| - |
14 |
| -AsyncFunctionInstance.arguments = {}; |
15 |
| -AsyncFunctionInstance.caller = {}; |
16 |
| - |
17 |
| -// Skipped because the core-js shim seems to miss the |
18 |
| -// actual %AsyncIteratorPrototype%, |
19 |
| -// so it creates a new one, causing us to fail because lockdown correctly |
20 |
| -// detects the conflicting definitions. |
21 |
| -// TODO report the bug to core-js |
22 |
| -test.skip('shimmed async-iterator helpers', t => { |
23 |
| - lockdown(); |
| 8 | +test('shimmed async-iterator helpers', async t => { |
| 9 | + t.deepEqual( |
| 10 | + await (async function* g(i) { |
| 11 | + // eslint-disable-next-line no-plusplus |
| 12 | + while (true) yield i++; |
| 13 | + })(1) |
| 14 | + .drop(1) |
| 15 | + .take(5) |
| 16 | + .filter(it => it % 2) |
| 17 | + .map(it => it ** 2) |
| 18 | + .toArray(), |
| 19 | + [9, 25], |
| 20 | + ); |
24 | 21 |
|
25 | 22 | const AsyncIteratorHelperPrototype = Object.getPrototypeOf(
|
26 | 23 | AsyncIterator.from([]).take(0),
|
|
0 commit comments