mirror of https://github.com/tc39/test262.git
Add and update tests for Array.prototype.fill
This commit is contained in:
parent
02fbde769c
commit
e64e17f750
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) 2014 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
The fill() method fills all the elements of an array from a start
|
||||
index to an end index with a static value.
|
||||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
assert.sameValue(1, Array.prototype.fill.length);
|
||||
|
||||
assert(compareArray([].fill(8), []));
|
||||
assert(compareArray(
|
||||
[0, 0, 0, 0, 0].fill(),
|
||||
[undefined, undefined, undefined, undefined, undefined]
|
||||
));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8), [8, 8, 8, 8, 8]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, 1), [0, 8, 8, 8, 8]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, 10), [0, 0, 0, 0, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, -5), [8, 8, 8, 8, 8]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, 1, 4), [0, 8, 8, 8, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, 1, -1), [0, 8, 8, 8, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, 1, 42), [0, 8, 8, 8, 8]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, -3, 42), [0, 0, 8, 8, 8]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, -3, 4), [0, 0, 8, 8, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, -2, -1), [0, 0, 0, 8, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, -1, -3), [0, 0, 0, 0, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, undefined, 4), [8, 8, 8, 8, 0]));
|
||||
assert(compareArray([ , , , , 0].fill(8, 1, 3), [, 8, 8, , 0]));
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) 2014 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
The fill() method fills all the elements of an array from a start
|
||||
index to an end index with a static value.
|
||||
|
||||
Cannot fill a frozen array
|
||||
|
||||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
|
||||
---*/
|
||||
assert.throws(TypeError, function() {
|
||||
Object.freeze([0]).fill();
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) 2014 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
The fill() method fills all the elements of an array from a start
|
||||
index to an end index with a static value.
|
||||
|
||||
this value cannot be null or undefined
|
||||
|
||||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
|
||||
---*/
|
||||
assert.throws(TypeError, function() {
|
||||
Array.prototype.fill.call(null);
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
Array.prototype.fill.call(undefined);
|
||||
});
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright (c) 2014 Hank Yates. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
es6id: 22.1.3.6_T1
|
||||
description: Testing Array#fill
|
||||
author: Hank Yates (hankyates@gmail.com)
|
||||
includes: [runTestCase.js]
|
||||
---*/
|
||||
|
||||
runTestCase(function () {
|
||||
var testArr = new Array('testString', 'anotherTestString', 3),
|
||||
updatedArr = testArr.fill('newValue', 1, 3);
|
||||
|
||||
if (updatedArr[3] !== void 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (updatedArr[2] !== 'newValue') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (updatedArr[1] !== 'newValue') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (updatedArr[0] !== 'testString') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (updatedArr.length !== 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
});
|
|
@ -0,0 +1,89 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Fills elements from coerced to Integer `start` and `end` values
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
7. Let relativeStart be ToInteger(start).
|
||||
8. ReturnIfAbrupt(relativeStart).
|
||||
9. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be
|
||||
min(relativeStart, len).
|
||||
10. If end is undefined, let relativeEnd be len; else let relativeEnd be
|
||||
ToInteger(end).
|
||||
...
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, undefined), [1, 1]),
|
||||
'`undefined` start coerced to 0'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, 0, undefined), [1, 1]),
|
||||
'If end is undefined, let relativeEnd be len'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, null), [1, 1]),
|
||||
'`null` start coerced to 0'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, 0, null), [0, 0]),
|
||||
'`null` end coerced to 0'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, true), [0, 1]),
|
||||
'`true` start coerced to 1'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, 0, true), [1, 0]),
|
||||
'`true` end coerced to 1'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, false), [1, 1]),
|
||||
'`false` start coerced to 0'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, 0, false), [0, 0]),
|
||||
'`false` end coerced to 0'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, NaN), [1, 1]),
|
||||
'`NaN` start coerced to 0'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, 0, NaN), [0, 0]),
|
||||
'`NaN` end coerced to 0'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, '1'), [0, 1]),
|
||||
'string start coerced'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, 0, '1'), [1, 0]),
|
||||
'string end coerced'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, 1.5), [0, 1]),
|
||||
'start as a float number coerced'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0].fill(1, 0, 1.5), [1, 0]),
|
||||
'end as a float number coerced'
|
||||
);
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Fills all the elements from a with a custom start and end indexes.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be
|
||||
min(relativeStart, len).
|
||||
8. If end is undefined, let relativeEnd be len; else let relativeEnd be
|
||||
ToInteger(end).
|
||||
9. ReturnIfAbrupt(relativeEnd).
|
||||
10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let
|
||||
final be min(relativeEnd, len).
|
||||
...
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
assert(compareArray([0, 0, 0].fill(8, 1, 2), [0, 8, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, -3, 4), [0, 0, 8, 8, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, -2, -1), [0, 0, 0, 8, 0]));
|
||||
assert(compareArray([0, 0, 0, 0, 0].fill(8, -1, -3), [0, 0, 0, 0, 0]));
|
||||
assert(compareArray([ , , , , 0].fill(8, 1, 3), [, 8, 8, , 0]));
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Fills all the elements from a with a custom start index.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
8. If end is undefined, let relativeEnd be len; else let relativeEnd be
|
||||
ToInteger(end).
|
||||
9. ReturnIfAbrupt(relativeEnd).
|
||||
10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let
|
||||
final be min(relativeEnd, len).
|
||||
...
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
assert(
|
||||
compareArray([0, 0, 0].fill(8, 0, 1), [8, 0, 0]),
|
||||
'Fill elements from custom end position'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0, 0].fill(8, 0, -1), [8, 8, 0]),
|
||||
'negative end sets final position to max((this.length + relativeEnd), 0)'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0, 0].fill(8, 0, 5), [8, 8, 8]),
|
||||
'end position is never higher than of this.length'
|
||||
);
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Fills all the elements from a with a custom start index.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be
|
||||
min(relativeStart, len).
|
||||
...
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
assert(
|
||||
compareArray([0, 0, 0].fill(8, 1), [0, 8, 8]),
|
||||
'Fill elements from custom start position'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0, 0].fill(8, 4), [0, 0, 0]),
|
||||
'start position is never higher than this.length'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray([0, 0, 0].fill(8, -1), [0, 0, 8]),
|
||||
'negative start sets initial position to max((this.length + relativeStart),0)'
|
||||
);
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Fills all the elements with `value` from a defaul start and index.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be
|
||||
min(relativeStart, len).
|
||||
8. If end is undefined, let relativeEnd be len; else let relativeEnd be
|
||||
ToInteger(end).
|
||||
9. ReturnIfAbrupt(relativeEnd).
|
||||
10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let
|
||||
final be min(relativeEnd, len).
|
||||
11. Repeat, while k < final
|
||||
a. Let Pk be ToString(k).
|
||||
b. Let setStatus be Set(O, Pk, value, true).
|
||||
c. ReturnIfAbrupt(setStatus).
|
||||
d. Increase k by 1.
|
||||
12. Return O.
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
assert(compareArray([].fill(8), []));
|
||||
|
||||
assert(compareArray(
|
||||
[0, 0].fill(),
|
||||
[undefined, undefined]
|
||||
));
|
||||
|
||||
assert(
|
||||
compareArray([0, 0, 0].fill(8), [8, 8, 8]),
|
||||
'Default start and end indexes are 0 and this.length'
|
||||
);
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: Property type and descriptor.
|
||||
info: >
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Array.prototype.fill,
|
||||
'function',
|
||||
'`typeof Array.prototype.fill` is `function`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Array.prototype, 'fill');
|
||||
verifyWritable(Array.prototype, 'fill');
|
||||
verifyConfigurable(Array.prototype, 'fill');
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: Array.prototype.fill.length value and descriptor.
|
||||
info: >
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Array.prototype.fill.length, 1,
|
||||
'The value of `Array.prototype.fill.length` is `1`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Array.prototype.fill, 'length');
|
||||
verifyNotWritable(Array.prototype.fill, 'length');
|
||||
verifyConfigurable(Array.prototype.fill, 'length');
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Array.prototype.fill.name value and descriptor.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Array.prototype.fill.name, 'fill',
|
||||
'The value of `Array.prototype.fill.name` is `"fill"`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Array.prototype.fill, 'name');
|
||||
verifyNotWritable(Array.prototype.fill, 'name');
|
||||
verifyConfigurable(Array.prototype.fill, 'name');
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Return abrupt from ToInteger(end) as a Symbol.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , end [ , end ] ] )
|
||||
|
||||
...
|
||||
8. If end is undefined, let relativeEnd be len; else let relativeEnd be
|
||||
ToInteger(end).
|
||||
9. ReturnIfAbrupt(relativeEnd).
|
||||
...
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var end = Symbol(1);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[].fill(1, 0, end);
|
||||
});
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Return abrupt from ToInteger(end).
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
8. If end is undefined, let relativeEnd be len; else let relativeEnd be
|
||||
ToInteger(end).
|
||||
9. ReturnIfAbrupt(relativeEnd).
|
||||
...
|
||||
---*/
|
||||
|
||||
var end = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[].fill(1, 0, end);
|
||||
});
|
34
test/built-ins/Array/prototype/fill/return-abrupt-from-setting-property-value.js
vendored
Normal file
34
test/built-ins/Array/prototype/fill/return-abrupt-from-setting-property-value.js
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Return abrupt from setting a property value.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
11. Repeat, while k < final
|
||||
a. Let Pk be ToString(k).
|
||||
b. Let setStatus be Set(O, Pk, value, true).
|
||||
c. ReturnIfAbrupt(setStatus).
|
||||
...
|
||||
---*/
|
||||
|
||||
var a1 = [];
|
||||
Object.freeze(a1);
|
||||
|
||||
// won't break on an empty array.
|
||||
a1.fill(1);
|
||||
|
||||
var a2 = {
|
||||
length: 1
|
||||
};
|
||||
Object.defineProperty(a2, '0', {
|
||||
set: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
})
|
||||
assert.throws(Test262Error, function() {
|
||||
Array.prototype.fill.call(a2);
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Return abrupt from ToInteger(start) as a Symbol.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
5. Let relativeStart be ToInteger(start).
|
||||
6. ReturnIfAbrupt(relativeStart).
|
||||
...
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var start = Symbol(1);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
[].fill(1, start);
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Return abrupt from ToInteger(start).
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
...
|
||||
5. Let relativeStart be ToInteger(start).
|
||||
6. ReturnIfAbrupt(relativeStart).
|
||||
...
|
||||
---*/
|
||||
|
||||
var start = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
[].fill(1, start);
|
||||
});
|
24
test/built-ins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js
vendored
Normal file
24
test/built-ins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Return abrupt from ToLength(Get(O, "length")) where length is a Symbol.
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
1. Let O be ToObject(this value).
|
||||
2. ReturnIfAbrupt(O).
|
||||
3. Let len be ToLength(Get(O, "length")).
|
||||
4. ReturnIfAbrupt(len).
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var o = {};
|
||||
|
||||
o.length = Symbol(1);
|
||||
|
||||
// value argument is given to avoid false positives
|
||||
assert.throws(TypeError, function() {
|
||||
[].fill.call(o, 1);
|
||||
});
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Return abrupt from ToLength(Get(O, "length")).
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
1. Let O be ToObject(this value).
|
||||
2. ReturnIfAbrupt(O).
|
||||
3. Let len be ToLength(Get(O, "length")).
|
||||
4. ReturnIfAbrupt(len).
|
||||
---*/
|
||||
|
||||
var o1 = {};
|
||||
|
||||
Object.defineProperty(o1, 'length', {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
assert.throws(Test262Error, function() {
|
||||
[].fill.call(o1, 1);
|
||||
});
|
||||
|
||||
var o2 = {
|
||||
length: {
|
||||
valueOf: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
}
|
||||
};
|
||||
assert.throws(Test262Error, function() {
|
||||
[].fill.call(o2, 1);
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Return abrupt from ToObject(this value).
|
||||
info: >
|
||||
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
|
||||
|
||||
1. Let O be ToObject(this value).
|
||||
2. ReturnIfAbrupt(O).
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Array.prototype.fill.call(undefined, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Array.prototype.fill.call(null, 1);
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.1.3.6
|
||||
description: >
|
||||
Returns `this`.
|
||||
info: >
|
||||
12. Return O.
|
||||
---*/
|
||||
|
||||
var arr = [];
|
||||
var result = arr.fill(1);
|
||||
|
||||
assert.sameValue(result, arr);
|
||||
|
||||
var o = {
|
||||
length: 0
|
||||
};
|
||||
result = Array.prototype.fill.call(o);
|
||||
assert.sameValue(result, o);
|
Loading…
Reference in New Issue