Skip to content

Commit ecb83f2

Browse files
change to TypeError
1 parent 2a513d8 commit ecb83f2

10 files changed

Lines changed: 99 additions & 95 deletions

test/built-ins/Iterator/prototype/chunks/argument-effect-order.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ info: |
1010
1. Let O be the this value.
1111
2. If O is not an Object, throw a TypeError exception.
1212
3. Let iterated be the Iterator Record { [[Iterator]]: O, [[NextMethod]]: undefined, [[Done]]: false }.
13-
4. If chunkSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
13+
4. If chunkSize is not a Number, throw a TypeError ... IteratorClose.
14+
5. If chunkSize is not an integral Number, throw a TypeError ... IteratorClose.
15+
6. If chunkSize is not in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
1416
a. Let error be ThrowCompletion(a newly created RangeError object).
1517
b. Return ? IteratorClose(iterated, error).
16-
5. Set iterated to ? GetIteratorDirect(O).
18+
7. Set iterated to ? GetIteratorDirect(O).
1719
1820
includes: [compareArray.js]
1921
features: [iterator-chunking]

test/built-ins/Iterator/prototype/chunks/argument-validation-failure-closes-underlying.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ info: |
88
Iterator.prototype.chunks ( chunkSize )
99
1010
3. Let iterated be the Iterator Record { [[Iterator]]: O, [[NextMethod]]: undefined, [[Done]]: false }.
11-
4. If chunkSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
11+
4. If chunkSize is not a Number, throw a TypeError exception ... IteratorClose(iterated, error).
12+
5. If chunkSize is not an integral Number, throw a TypeError exception ... IteratorClose(iterated, error).
13+
6. If chunkSize is not in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
1214
a. Let error be ThrowCompletion(a newly created RangeError object).
1315
b. Return ? IteratorClose(iterated, error).
1416
@@ -27,7 +29,7 @@ let closable = {
2729
},
2830
};
2931

30-
assert.throws(RangeError, function () {
32+
assert.throws(TypeError, function () {
3133
closable.chunks();
3234
});
3335
assert.sameValue(closed, true, 'iterator closed when chunkSize is undefined');
@@ -39,13 +41,13 @@ assert.throws(RangeError, function () {
3941
assert.sameValue(closed, true, 'iterator closed when chunkSize is 0');
4042

4143
closed = false;
42-
assert.throws(RangeError, function () {
44+
assert.throws(TypeError, function () {
4345
closable.chunks(NaN);
4446
});
4547
assert.sameValue(closed, true, 'iterator closed when chunkSize is NaN');
4648

4749
closed = false;
48-
assert.throws(RangeError, function () {
50+
assert.throws(TypeError, function () {
4951
closable.chunks('1');
5052
});
5153
assert.sameValue(closed, true, 'iterator closed when chunkSize is a string');

test/built-ins/Iterator/prototype/chunks/chunkSize-no-coercion.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ description: >
99
info: |
1010
Iterator.prototype.chunks ( chunkSize )
1111
12-
4. If chunkSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
13-
a. Let error be ThrowCompletion(a newly created RangeError object).
14-
b. Return ? IteratorClose(iterated, error).
12+
4. If chunkSize is not a Number, throw a TypeError exception.
1513
1614
features: [iterator-chunking]
1715
---*/
1816
let iterator = (function* () {})();
1917

2018
let valueOfCalled = false;
21-
assert.throws(RangeError, () => {
19+
assert.throws(TypeError, () => {
2220
iterator.chunks({
2321
valueOf() {
2422
valueOfCalled = true;
@@ -29,7 +27,7 @@ assert.throws(RangeError, () => {
2927
assert.sameValue(valueOfCalled, false, 'valueOf must not be called');
3028

3129
let toStringCalled = false;
32-
assert.throws(RangeError, () => {
30+
assert.throws(TypeError, () => {
3331
iterator.chunks({
3432
toString() {
3533
toStringCalled = true;

test/built-ins/Iterator/prototype/chunks/chunkSize-not-a-number.js

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,66 @@
33
/*---
44
esid: sec-iterator.prototype.chunks
55
description: >
6-
Iterator.prototype.chunks throws RangeError when chunkSize is not a Number
6+
Iterator.prototype.chunks throws TypeError when chunkSize is not an integral
7+
Number
78
info: |
89
Iterator.prototype.chunks ( chunkSize )
910
10-
4. If chunkSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
11-
a. Let error be ThrowCompletion(a newly created RangeError object).
12-
b. Return ? IteratorClose(iterated, error).
11+
4. If chunkSize is not a Number, throw a TypeError exception.
12+
5. If chunkSize is not an integral Number, throw a TypeError exception.
1313
1414
features: [iterator-chunking]
1515
---*/
1616
let iterator = (function* () {})();
1717

18-
assert.throws(RangeError, () => {
18+
assert.throws(TypeError, () => {
1919
iterator.chunks();
2020
});
2121

22-
assert.throws(RangeError, () => {
22+
assert.throws(TypeError, () => {
2323
iterator.chunks(undefined);
2424
});
2525

26-
assert.throws(RangeError, () => {
26+
assert.throws(TypeError, () => {
2727
iterator.chunks('1');
2828
});
2929

30-
assert.throws(RangeError, () => {
30+
assert.throws(TypeError, () => {
3131
iterator.chunks(true);
3232
});
3333

34-
assert.throws(RangeError, () => {
34+
assert.throws(TypeError, () => {
3535
iterator.chunks(null);
3636
});
3737

38-
assert.throws(RangeError, () => {
38+
assert.throws(TypeError, () => {
3939
iterator.chunks({});
4040
});
4141

42-
assert.throws(RangeError, () => {
42+
assert.throws(TypeError, () => {
4343
iterator.chunks(Symbol());
4444
});
4545

46-
assert.throws(RangeError, () => {
46+
assert.throws(TypeError, () => {
4747
iterator.chunks([2]);
4848
});
49+
50+
assert.throws(TypeError, () => {
51+
iterator.chunks(NaN);
52+
});
53+
54+
assert.throws(TypeError, () => {
55+
iterator.chunks(0.5);
56+
});
57+
58+
assert.throws(TypeError, () => {
59+
iterator.chunks(1.5);
60+
});
61+
62+
assert.throws(TypeError, () => {
63+
iterator.chunks(Infinity);
64+
});
65+
66+
assert.throws(TypeError, () => {
67+
iterator.chunks(-Infinity);
68+
});

test/built-ins/Iterator/prototype/chunks/chunkSize-out-of-range.js

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
/*---
44
esid: sec-iterator.prototype.chunks
55
description: >
6-
Iterator.prototype.chunks throws RangeError when chunkSize is out of the
7-
valid range [1, 2^32 - 1]
6+
Iterator.prototype.chunks throws RangeError when chunkSize is an integral
7+
Number outside the valid range [1, 2^32 - 1]
88
info: |
99
Iterator.prototype.chunks ( chunkSize )
1010
11-
4. If chunkSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
11+
6. If chunkSize is not in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
1212
a. Let error be ThrowCompletion(a newly created RangeError object).
1313
b. Return ? IteratorClose(iterated, error).
1414
@@ -28,26 +28,6 @@ assert.throws(RangeError, () => {
2828
iterator.chunks(-1);
2929
});
3030

31-
assert.throws(RangeError, () => {
32-
iterator.chunks(-Infinity);
33-
});
34-
35-
assert.throws(RangeError, () => {
36-
iterator.chunks(0.5);
37-
});
38-
39-
assert.throws(RangeError, () => {
40-
iterator.chunks(1.5);
41-
});
42-
43-
assert.throws(RangeError, () => {
44-
iterator.chunks(NaN);
45-
});
46-
47-
assert.throws(RangeError, () => {
48-
iterator.chunks(Infinity);
49-
});
50-
5131
assert.throws(RangeError, () => {
5232
iterator.chunks(2 ** 32);
5333
});

test/built-ins/Iterator/prototype/windows/argument-effect-order.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ info: |
1010
1. Let O be the this value.
1111
2. If O is not an Object, throw a TypeError exception.
1212
3. Let iterated be the Iterator Record { [[Iterator]]: O, [[NextMethod]]: undefined, [[Done]]: false }.
13-
4. If windowSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
13+
4. If windowSize is not a Number, throw a TypeError ... IteratorClose.
14+
5. If windowSize is not an integral Number, throw a TypeError ... IteratorClose.
15+
6. If windowSize is not in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
1416
a. Let error be ThrowCompletion(a newly created RangeError object).
1517
b. Return ? IteratorClose(iterated, error).
16-
5. If undersized is undefined, set undersized to "only-full".
17-
6. If undersized is neither "only-full" nor "allow-partial", then
18+
7. If undersized is undefined, set undersized to "only-full".
19+
8. If undersized is neither "only-full" nor "allow-partial", then
1820
a. Let error be ThrowCompletion(a newly created TypeError object).
1921
b. Return ? IteratorClose(iterated, error).
20-
7. Set iterated to ? GetIteratorDirect(O).
22+
9. Set iterated to ? GetIteratorDirect(O).
2123
2224
includes: [compareArray.js]
2325
features: [iterator-chunking]

test/built-ins/Iterator/prototype/windows/argument-validation-failure-closes-underlying.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ info: |
88
Iterator.prototype.windows ( windowSize [ , undersized ] )
99
1010
3. Let iterated be the Iterator Record { [[Iterator]]: O, [[NextMethod]]: undefined, [[Done]]: false }.
11-
4. If windowSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
11+
4. If windowSize is not a Number, throw a TypeError exception ... IteratorClose(iterated, error).
12+
5. If windowSize is not an integral Number, throw a TypeError exception ... IteratorClose(iterated, error).
13+
6. If windowSize is not in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
1214
a. Let error be ThrowCompletion(a newly created RangeError object).
1315
b. Return ? IteratorClose(iterated, error).
1416
...
15-
6. If undersized is neither "only-full" nor "allow-partial", then
17+
8. If undersized is neither "only-full" nor "allow-partial", then
1618
a. Let error be ThrowCompletion(a newly created TypeError object).
1719
b. Return ? IteratorClose(iterated, error).
1820
@@ -32,7 +34,7 @@ let closable = {
3234
};
3335

3436
// windowSize validation failure closes
35-
assert.throws(RangeError, function () {
37+
assert.throws(TypeError, function () {
3638
closable.windows();
3739
});
3840
assert.sameValue(closed, true, 'iterator closed when windowSize is undefined');
@@ -44,13 +46,13 @@ assert.throws(RangeError, function () {
4446
assert.sameValue(closed, true, 'iterator closed when windowSize is 0');
4547

4648
closed = false;
47-
assert.throws(RangeError, function () {
49+
assert.throws(TypeError, function () {
4850
closable.windows(NaN);
4951
});
5052
assert.sameValue(closed, true, 'iterator closed when windowSize is NaN');
5153

5254
closed = false;
53-
assert.throws(RangeError, function () {
55+
assert.throws(TypeError, function () {
5456
closable.windows('1');
5557
});
5658
assert.sameValue(closed, true, 'iterator closed when windowSize is a string');

test/built-ins/Iterator/prototype/windows/windowSize-no-coercion.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ description: >
99
info: |
1010
Iterator.prototype.windows ( windowSize [ , undersized ] )
1111
12-
4. If windowSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
13-
a. Let error be ThrowCompletion(a newly created RangeError object).
14-
b. Return ? IteratorClose(iterated, error).
12+
4. If windowSize is not a Number, throw a TypeError exception.
1513
1614
features: [iterator-chunking]
1715
---*/
1816
let iterator = (function* () {})();
1917

2018
let valueOfCalled = false;
21-
assert.throws(RangeError, () => {
19+
assert.throws(TypeError, () => {
2220
iterator.windows({
2321
valueOf() {
2422
valueOfCalled = true;
@@ -29,7 +27,7 @@ assert.throws(RangeError, () => {
2927
assert.sameValue(valueOfCalled, false, 'valueOf must not be called');
3028

3129
let toStringCalled = false;
32-
assert.throws(RangeError, () => {
30+
assert.throws(TypeError, () => {
3331
iterator.windows({
3432
toString() {
3533
toStringCalled = true;

test/built-ins/Iterator/prototype/windows/windowSize-not-a-number.js

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,66 @@
33
/*---
44
esid: sec-iterator.prototype.windows
55
description: >
6-
Iterator.prototype.windows throws RangeError when windowSize is not a Number
6+
Iterator.prototype.windows throws TypeError when windowSize is not an
7+
integral Number
78
info: |
89
Iterator.prototype.windows ( windowSize [ , undersized ] )
910
10-
4. If windowSize is not an integral Number in the inclusive interval from 1𝔽 to 𝔽(2^32 - 1), then
11-
a. Let error be ThrowCompletion(a newly created RangeError object).
12-
b. Return ? IteratorClose(iterated, error).
11+
4. If windowSize is not a Number, throw a TypeError exception.
12+
5. If windowSize is not an integral Number, throw a TypeError exception.
1313
1414
features: [iterator-chunking]
1515
---*/
1616
let iterator = (function* () {})();
1717

18-
assert.throws(RangeError, () => {
18+
assert.throws(TypeError, () => {
1919
iterator.windows();
2020
});
2121

22-
assert.throws(RangeError, () => {
22+
assert.throws(TypeError, () => {
2323
iterator.windows(undefined);
2424
});
2525

26-
assert.throws(RangeError, () => {
26+
assert.throws(TypeError, () => {
2727
iterator.windows('1');
2828
});
2929

30-
assert.throws(RangeError, () => {
30+
assert.throws(TypeError, () => {
3131
iterator.windows(true);
3232
});
3333

34-
assert.throws(RangeError, () => {
34+
assert.throws(TypeError, () => {
3535
iterator.windows(null);
3636
});
3737

38-
assert.throws(RangeError, () => {
38+
assert.throws(TypeError, () => {
3939
iterator.windows({});
4040
});
4141

42-
assert.throws(RangeError, () => {
42+
assert.throws(TypeError, () => {
4343
iterator.windows(Symbol());
4444
});
4545

46-
assert.throws(RangeError, () => {
46+
assert.throws(TypeError, () => {
4747
iterator.windows([2]);
4848
});
49+
50+
assert.throws(TypeError, () => {
51+
iterator.windows(NaN);
52+
});
53+
54+
assert.throws(TypeError, () => {
55+
iterator.windows(0.5);
56+
});
57+
58+
assert.throws(TypeError, () => {
59+
iterator.windows(1.5);
60+
});
61+
62+
assert.throws(TypeError, () => {
63+
iterator.windows(Infinity);
64+
});
65+
66+
assert.throws(TypeError, () => {
67+
iterator.windows(-Infinity);
68+
});

0 commit comments

Comments
 (0)