mirror of https://github.com/tc39/test262.git
Merge pull request #380 from bocoup/String.prototype.endsWith
Add and update tests for String.prototype.endsWith
This commit is contained in:
commit
cd4461c89e
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 21.1.3.6
|
||||
description: >
|
||||
Returns based on coerced values of endPosition.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
12. Let end be min(max(pos, 0), len).
|
||||
13. Let searchLength be the number of elements in searchStr.
|
||||
14. Let start be end - searchLength.
|
||||
15. If start is less than 0, return false.
|
||||
16. If the sequence of elements of S starting at start of length searchLength
|
||||
is the same as the full element sequence of searchStr, return true.
|
||||
17. Otherwise, return false.
|
||||
...
|
||||
---*/
|
||||
|
||||
var str = 'The future is cool!';
|
||||
|
||||
assert(str.endsWith('', NaN), 'NaN coerced to 0');
|
||||
assert(str.endsWith('', null), 'null coerced to 0');
|
||||
assert(str.endsWith('', false), 'false coerced to 0');
|
||||
assert(str.endsWith('', ''), '"" coerced to 0');
|
||||
assert(str.endsWith('', '0'), '"0" coerced to 0');
|
||||
assert(str.endsWith('', undefined), 'undefined coerced to 0');
|
||||
|
||||
assert(str.endsWith('The future', 10.4), '10.4 coerced to 10');
|
||||
assert(str.endsWith('T', true), 'true coerced to 1');
|
||||
|
||||
assert(str.endsWith('The future', '10'), '"10" coerced to 10');
|
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Property type and descriptor.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof String.prototype.endsWith,
|
||||
'function',
|
||||
'`typeof String.prototype.endsWith` is `function`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(String.prototype, 'endsWith');
|
||||
verifyWritable(String.prototype, 'endsWith');
|
||||
verifyConfigurable(String.prototype, 'endsWith');
|
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
String.prototype.endsWith.length value and descriptor.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
The length property of the endsWith method is 1.
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
String.prototype.endsWith.length, 1,
|
||||
'The value of `String.prototype.endsWith.length` is `1`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(String.prototype.endsWith, 'length');
|
||||
verifyNotWritable(String.prototype.endsWith, 'length');
|
||||
verifyConfigurable(String.prototype.endsWith, '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: 21.1.3.6
|
||||
description: >
|
||||
String.prototype.endsWith.name value and descriptor.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
String.prototype.endsWith.name, 'endsWith',
|
||||
'The value of `String.prototype.endsWith.name` is `"endsWith"`'
|
||||
);
|
||||
|
||||
verifyNotEnumerable(String.prototype.endsWith, 'name');
|
||||
verifyNotWritable(String.prototype.endsWith, 'name');
|
||||
verifyConfigurable(String.prototype.endsWith, 'name');
|
22
test/built-ins/String/prototype/endsWith/return-abrupt-from-position-as-symbol.js
vendored
Normal file
22
test/built-ins/String/prototype/endsWith/return-abrupt-from-position-as-symbol.js
vendored
Normal file
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Returns abrupt from ToInteger(endPosition) as a Symbol.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
...
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var position = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
''.endsWith('', position);
|
||||
});
|
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Returns abrupt from ToInteger(endPosition).
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
...
|
||||
---*/
|
||||
|
||||
var position = {
|
||||
valueOf: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
''.endsWith('', position);
|
||||
});
|
21
test/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-as-symbol.js
vendored
Normal file
21
test/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-as-symbol.js
vendored
Normal file
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Returns abrupt from ToString(searchString) as a Symbol
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
7. Let searchStr be ToString(searchString).
|
||||
8. ReturnIfAbrupt(searchStr).
|
||||
...
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var s = Symbol();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
''.endsWith(s);
|
||||
});
|
42
test/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js
vendored
Normal file
42
test/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 21.1.3.6
|
||||
description: >
|
||||
Returns abrupt from IsRegExp(searchString).
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
4. Let isRegExp be IsRegExp(searchString).
|
||||
5. ReturnIfAbrupt(isRegExp).
|
||||
...
|
||||
|
||||
7.2.8 IsRegExp ( argument )
|
||||
|
||||
2. Let isRegExp be Get(argument, @@match).
|
||||
3. ReturnIfAbrupt(isRegExp).
|
||||
features: [Symbol.match]
|
||||
---*/
|
||||
|
||||
var obj = {};
|
||||
Object.defineProperty(obj, Symbol.match, {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
''.endsWith(obj);
|
||||
});
|
||||
|
||||
var regexp = /./;
|
||||
Object.defineProperty(regexp, Symbol.match, {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
''.endsWith(regexp);
|
||||
});
|
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Returns abrupt from ToString(searchString)
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
7. Let searchStr be ToString(searchString).
|
||||
8. ReturnIfAbrupt(searchStr).
|
||||
...
|
||||
---*/
|
||||
|
||||
var obj = {
|
||||
toString: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
''.endsWith(obj);
|
||||
});
|
21
test/built-ins/String/prototype/endsWith/return-abrupt-from-this-as-symbol.js
vendored
Normal file
21
test/built-ins/String/prototype/endsWith/return-abrupt-from-this-as-symbol.js
vendored
Normal file
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Returns abrupt from ToString(this) where this is a Symbol
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
1. Let O be RequireObjectCoercible(this value).
|
||||
2. Let S be ToString(O).
|
||||
3. ReturnIfAbrupt(S).
|
||||
...
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var s = Symbol('');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
String.prototype.endsWith.call(s, '');
|
||||
});
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 21.1.3.6
|
||||
description: >
|
||||
Returns abrupt from ToString(this)
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
1. Let O be RequireObjectCoercible(this value).
|
||||
2. Let S be ToString(O).
|
||||
3. ReturnIfAbrupt(S).
|
||||
---*/
|
||||
|
||||
var o = {
|
||||
toString: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
String.prototype.endsWith.call(o, '');
|
||||
});
|
32
test/built-ins/String/prototype/endsWith/return-false-if-search-start-is-less-than-zero.js
vendored
Normal file
32
test/built-ins/String/prototype/endsWith/return-false-if-search-start-is-less-than-zero.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 21.1.3.6
|
||||
description: >
|
||||
Returns false if search start is less than 0.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
9. Let len be the number of elements in S.
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
12. Let end be min(max(pos, 0), len).
|
||||
13. Let searchLength be the number of elements in searchStr.
|
||||
14. Let start be end - searchLength.
|
||||
15. If start is less than 0, return false.
|
||||
...
|
||||
|
||||
Note: (min(max(pos, 0), len) - searchString.length) < 0;
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
'web'.endsWith('w', 0), false,
|
||||
'"web".endsWith("w", 0) returns false'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
'Bob'.endsWith(' Bob'), false,
|
||||
'"Bob".endsWith(" Bob") returns false'
|
||||
);
|
48
test/built-ins/String/prototype/endsWith/return-true-if-searchstring-is-empty.js
vendored
Normal file
48
test/built-ins/String/prototype/endsWith/return-true-if-searchstring-is-empty.js
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 21.1.3.6
|
||||
description: >
|
||||
Returns true if searchString.length == 0.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
12. Let end be min(max(pos, 0), len).
|
||||
13. Let searchLength be the number of elements in searchStr.
|
||||
14. Let start be end - searchLength.
|
||||
15. If start is less than 0, return false.
|
||||
16. If the sequence of elements of S starting at start of length searchLength
|
||||
is the same as the full element sequence of searchStr, return true.
|
||||
...
|
||||
---*/
|
||||
|
||||
var str = 'The future is cool!';
|
||||
|
||||
assert(
|
||||
str.endsWith(''),
|
||||
'str.endsWith("") returns true'
|
||||
);
|
||||
|
||||
assert(
|
||||
str.endsWith('', str.length),
|
||||
'str.endsWith("", str.length) returns true'
|
||||
);
|
||||
|
||||
assert(
|
||||
str.endsWith('', Infinity),
|
||||
'str.endsWith("", Infinity) returns true'
|
||||
);
|
||||
|
||||
assert(
|
||||
str.endsWith('', -1),
|
||||
'str.endsWith("", -1) returns true'
|
||||
);
|
||||
|
||||
assert(
|
||||
str.endsWith('', -Infinity),
|
||||
'str.endsWith("", -Infinity) returns true'
|
||||
);
|
37
test/built-ins/String/prototype/endsWith/searchstring-found-with-position.js
vendored
Normal file
37
test/built-ins/String/prototype/endsWith/searchstring-found-with-position.js
vendored
Normal file
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Returns true if searchString appears as a substring of the given string with a
|
||||
given position.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
12. Let end be min(max(pos, 0), len).
|
||||
13. Let searchLength be the number of elements in searchStr.
|
||||
14. Let start be end - searchLength.
|
||||
15. If start is less than 0, return false.
|
||||
16. If the sequence of elements of S starting at start of length searchLength
|
||||
is the same as the full element sequence of searchStr, return true.
|
||||
...
|
||||
---*/
|
||||
|
||||
var str = 'The future is cool!';
|
||||
|
||||
assert(
|
||||
str.endsWith('The future', 10),
|
||||
'str.endsWith("The future", 10) === true'
|
||||
);
|
||||
assert(
|
||||
str.endsWith('future', 10),
|
||||
'str.endsWith("future", 10) === true'
|
||||
);
|
||||
assert(
|
||||
str.endsWith(' is cool!', str.length),
|
||||
'str.endsWith(" is cool!", str.length) === true'
|
||||
);
|
27
test/built-ins/String/prototype/endsWith/searchstring-found-without-position.js
vendored
Normal file
27
test/built-ins/String/prototype/endsWith/searchstring-found-without-position.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 21.1.3.6
|
||||
description: >
|
||||
Returns true if searchString appears as a substring of the given string.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
12. Let end be min(max(pos, 0), len).
|
||||
13. Let searchLength be the number of elements in searchStr.
|
||||
14. Let start be end - searchLength.
|
||||
15. If start is less than 0, return false.
|
||||
16. If the sequence of elements of S starting at start of length searchLength
|
||||
is the same as the full element sequence of searchStr, return true.
|
||||
...
|
||||
---*/
|
||||
|
||||
var str = 'The future is cool!';
|
||||
|
||||
assert(str.endsWith('cool!'), 'str.endsWith("cool!") === true');
|
||||
assert(str.endsWith('!'), 'str.endsWith("!") === true');
|
||||
assert(str.endsWith(str), 'str.endsWith(str) === true');
|
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Throws a TypeError if searchString is a RegExp.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
4. Let isRegExp be IsRegExp(searchString).
|
||||
5. ReturnIfAbrupt(isRegExp).
|
||||
6. If isRegExp is true, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
var searchString = /./;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
''.endsWith(searchString);
|
||||
});
|
34
test/built-ins/String/prototype/endsWith/searchstring-not-found-with-position.js
vendored
Normal file
34
test/built-ins/String/prototype/endsWith/searchstring-not-found-with-position.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: 21.1.3.6
|
||||
description: >
|
||||
Returns false if searchString is not found with a given position.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
12. Let end be min(max(pos, 0), len).
|
||||
13. Let searchLength be the number of elements in searchStr.
|
||||
14. Let start be end - searchLength.
|
||||
15. If start is less than 0, return false.
|
||||
16. If the sequence of elements of S starting at start of length searchLength
|
||||
is the same as the full element sequence of searchStr, return true.
|
||||
17. Otherwise, return false.
|
||||
...
|
||||
---*/
|
||||
|
||||
var str = 'The future is cool!';
|
||||
|
||||
assert.sameValue(
|
||||
str.endsWith('is cool!', str.length - 1), false,
|
||||
'str.endsWith("is cool!", str.length - 1) === false'
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
str.endsWith('!', 1), false,
|
||||
'str.endsWith("!", 1) === false'
|
||||
);
|
37
test/built-ins/String/prototype/endsWith/searchstring-not-found-without-position.js
vendored
Normal file
37
test/built-ins/String/prototype/endsWith/searchstring-not-found-without-position.js
vendored
Normal file
|
@ -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: 21.1.3.6
|
||||
description: >
|
||||
Returns false if searchString is not found.
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
...
|
||||
10. If endPosition is undefined, let pos be len, else let pos be
|
||||
ToInteger(endPosition).
|
||||
11. ReturnIfAbrupt(pos).
|
||||
12. Let end be min(max(pos, 0), len).
|
||||
13. Let searchLength be the number of elements in searchStr.
|
||||
14. Let start be end - searchLength.
|
||||
15. If start is less than 0, return false.
|
||||
16. If the sequence of elements of S starting at start of length searchLength
|
||||
is the same as the full element sequence of searchStr, return true.
|
||||
17. Otherwise, return false.
|
||||
...
|
||||
---*/
|
||||
|
||||
var str = 'The future is cool!';
|
||||
|
||||
assert.sameValue(
|
||||
str.endsWith('is Flash!'), false,
|
||||
'str.endsWith("is Flash!") === false'
|
||||
);
|
||||
assert.sameValue(
|
||||
str.endsWith('IS COOL!'), false,
|
||||
'endsWith is case sensitive'
|
||||
);
|
||||
assert.sameValue(
|
||||
str.endsWith('The future'), false,
|
||||
'str.endsWith("The future") === false'
|
||||
);
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 21.1.3.6
|
||||
description: >
|
||||
Throws TypeError when `this` is null
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
1. Let O be RequireObjectCoercible(this value).
|
||||
2. Let S be ToString(O).
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
String.prototype.endsWith.call(null, '');
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 21.1.3.6
|
||||
description: >
|
||||
Throws TypeError when `this` is undefined
|
||||
info: >
|
||||
21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] )
|
||||
|
||||
1. Let O be RequireObjectCoercible(this value).
|
||||
2. Let S be ToString(O).
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
String.prototype.endsWith.call(undefined, '');
|
||||
});
|
Loading…
Reference in New Issue