-
Notifications
You must be signed in to change notification settings - Fork 54
/
constructor.any.js
46 lines (42 loc) · 1.62 KB
/
constructor.any.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// META: global=worker,jsshell
// META: script=../resources/constructor-ordering.js
'use strict';
const operations = [
op('get', 'size', 'writable'),
op('get', 'highWaterMark', 'writable'),
op('get', 'size', 'readable'),
op('get', 'highWaterMark', 'readable'),
op('get', 'writableType'),
op('validate', 'writableType'),
op('validate', 'size', 'writable'),
op('tonumber', 'highWaterMark', 'writable'),
op('validate', 'highWaterMark', 'writable'),
op('get', 'readableType'),
op('validate', 'readableType'),
op('validate', 'size', 'readable'),
op('tonumber', 'highWaterMark', 'readable'),
op('validate', 'highWaterMark', 'readable'),
op('get', 'transform'),
op('validate', 'transform'),
op('get', 'flush'),
op('validate', 'flush'),
op('get', 'start'),
op('validate', 'start')
];
for (const failureOp of operations) {
test(() => {
const record = new OpRecorder(failureOp);
const transformer = createRecordingObjectWithProperties(
record, ['readableType', 'writableType', 'start', 'transform', 'flush']);
const writableStrategy = createRecordingStrategy(record, 'writable');
const readableStrategy = createRecordingStrategy(record, 'readable');
try {
new TransformStream(transformer, writableStrategy, readableStrategy);
assert_unreached('constructor should throw');
} catch (e) {
assert_equals(typeof e, 'object', 'e should be an object');
}
assert_equals(record.actual(), expectedAsString(operations, failureOp),
'operations should be performed in the right order');
}, `TransformStream constructor should stop after ${failureOp} fails`);
}