mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 23:44:27 +02:00
Move tests from
https://source.chromium.org/chromium/chromium/src/+/master:v8/test/test262/local-tests/
This commit is contained in:
parent
9e88ec1354
commit
ab3a86d9b3
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 23.1.1.1
|
||||||
|
description: >
|
||||||
|
The correct error is thrown `Map.prototype.set` throws an error and
|
||||||
|
the IteratorClose throws an error.
|
||||||
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var iterable = {};
|
||||||
|
iterable[Symbol.iterator] = function() {
|
||||||
|
return {
|
||||||
|
next: function() {
|
||||||
|
return { value: [], done: false };
|
||||||
|
},
|
||||||
|
return: function() {
|
||||||
|
throw new TypeError('ignore');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Map.prototype.set = function() { throw new Test262Error(); }
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
35
test/intl402/DateTimeFormat/12.1.1_1.js
Normal file
35
test/intl402/DateTimeFormat/12.1.1_1.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
es5id: 12.1.1_1
|
||||||
|
description: Tests that the this-value is ignored in DateTimeFormat.
|
||||||
|
author: Norbert Lindenberg
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithIntlConstructors(function (Constructor) {
|
||||||
|
var obj, newObj;
|
||||||
|
|
||||||
|
if (Constructor === Intl.DateTimeFormat) {
|
||||||
|
obj = new Constructor();
|
||||||
|
newObj = Intl.DateTimeFormat.call(obj);
|
||||||
|
if (obj !== newObj) {
|
||||||
|
$ERROR("Should have modified existing object.");
|
||||||
|
}
|
||||||
|
var key = Object.getOwnPropertySymbols(newObj)[0];
|
||||||
|
if (!(newObj[key] instanceof Intl.DateTimeFormat)) {
|
||||||
|
$ERROR("Should have installed a DateTimeFormat instance.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// variant 1: use constructor in a "new" expression
|
||||||
|
obj = new Constructor();
|
||||||
|
newObj = Intl.DateTimeFormat.call(obj);
|
||||||
|
if (obj === newObj) {
|
||||||
|
$ERROR("DateTimeFormat object created with \"new\" was not ignored as this-value.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
35
test/intl402/NumberFormat/11.1.1_1.js
Normal file
35
test/intl402/NumberFormat/11.1.1_1.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2012 Mozilla Corporation. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
es5id: 11.1.1_1
|
||||||
|
description: Tests that the this-value is ignored in NumberFormat.
|
||||||
|
author: Norbert Lindenberg
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithIntlConstructors(function (Constructor) {
|
||||||
|
var obj, newObj;
|
||||||
|
|
||||||
|
if (Constructor === Intl.NumberFormat) {
|
||||||
|
obj = new Constructor();
|
||||||
|
newObj = Intl.NumberFormat.call(obj);
|
||||||
|
if (obj !== newObj) {
|
||||||
|
$ERROR("Should have modified existing object.");
|
||||||
|
}
|
||||||
|
var key = Object.getOwnPropertySymbols(newObj)[0];
|
||||||
|
if (!(newObj[key] instanceof Intl.NumberFormat)) {
|
||||||
|
$ERROR("Should have installed a NumberFormat instance.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// variant 1: use constructor in a "new" expression
|
||||||
|
obj = new Constructor();
|
||||||
|
newObj = Intl.NumberFormat.call(obj);
|
||||||
|
if (obj === newObj) {
|
||||||
|
$ERROR("NumberFormat object created with \"new\" was not ignored as this-value.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: ECMA-402 #sec-setnfdigitoptions
|
||||||
|
description: >
|
||||||
|
When a currency is used in Intl.NumberFormat and minimumFractionDigits is
|
||||||
|
not provided, maximumFractionDigits should be range-checked against it.
|
||||||
|
include: [assert.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(RangeError,
|
||||||
|
() => new Intl.NumberFormat('en', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'USD',
|
||||||
|
maximumFractionDigits: 1
|
||||||
|
}));
|
@ -0,0 +1,26 @@
|
|||||||
|
/*---
|
||||||
|
description: Syntax error if `arguments` used in class field (arrow function expression)
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
features: [class, class-fields-public, arrow-function]
|
||||||
|
flags: [generated]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
Static Semantics: Early Errors
|
||||||
|
FieldDefinition:
|
||||||
|
PropertyNameInitializeropt
|
||||||
|
- It is a Syntax Error if ContainsArguments of Initializer is true.
|
||||||
|
Static Semantics: ContainsArguments
|
||||||
|
IdentifierReference : Identifier
|
||||||
|
1. If the StringValue of Identifier is "arguments", return true.
|
||||||
|
...
|
||||||
|
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
|
||||||
|
---*/
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
var C = class {
|
||||||
|
x = () => {
|
||||||
|
var t = () => { arguments; };
|
||||||
|
t();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*---
|
||||||
|
description: error if `arguments` in StatementList of eval (direct eval)
|
||||||
|
esid: sec-performeval-rules-in-initializer
|
||||||
|
features: [class, class-fields-public, arrow-function]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Static Semantics: Early Errors
|
||||||
|
|
||||||
|
FieldDefinition:
|
||||||
|
PropertyNameInitializeropt
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsArguments of Initializer is true.
|
||||||
|
|
||||||
|
Static Semantics: ContainsArguments
|
||||||
|
IdentifierReference : Identifier
|
||||||
|
|
||||||
|
1. If the StringValue of Identifier is "arguments", return true.
|
||||||
|
...
|
||||||
|
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
x = () => {
|
||||||
|
var t = () => { eval("arguments"); };
|
||||||
|
t();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
var c = new C();
|
||||||
|
c.x();
|
||||||
|
});
|
@ -0,0 +1,30 @@
|
|||||||
|
/*---
|
||||||
|
description: error if `arguments` in StatementList of eval (direct eval)
|
||||||
|
esid: sec-performeval-rules-in-initializer
|
||||||
|
features: [class, class-fields-public, arrow-function]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Static Semantics: Early Errors
|
||||||
|
|
||||||
|
FieldDefinition:
|
||||||
|
PropertyNameInitializeropt
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsArguments of Initializer is true.
|
||||||
|
|
||||||
|
Static Semantics: ContainsArguments
|
||||||
|
IdentifierReference : Identifier
|
||||||
|
|
||||||
|
1. If the StringValue of Identifier is "arguments", return true.
|
||||||
|
...
|
||||||
|
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
x = eval("() => arguments");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
var c = new C();
|
||||||
|
c.x();
|
||||||
|
});
|
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
HTML-like comments are not available in module code
|
||||||
|
(SingleLineHTMLCloseComment)
|
||||||
|
esid: sec-html-like-comments
|
||||||
|
es6id: B1.3
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
flags: [module]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
-->
|
||||||
|
function f(){}
|
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) 2017 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
HTML-like comments are not available in module code
|
||||||
|
(SingleLineHTMLCloseComment)
|
||||||
|
esid: sec-html-like-comments
|
||||||
|
es6id: B1.3
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
flags: [module]
|
||||||
|
---*/
|
||||||
|
-->
|
||||||
|
function f(){}
|
@ -0,0 +1,26 @@
|
|||||||
|
/*---
|
||||||
|
description: Syntax error if `arguments` used in class field (arrow function expression)
|
||||||
|
esid: sec-class-definitions-static-semantics-early-errors
|
||||||
|
features: [class, class-fields-public, arrow-function]
|
||||||
|
flags: [generated]
|
||||||
|
negative:
|
||||||
|
phase: early
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
Static Semantics: Early Errors
|
||||||
|
FieldDefinition:
|
||||||
|
PropertyNameInitializeropt
|
||||||
|
- It is a Syntax Error if ContainsArguments of Initializer is true.
|
||||||
|
Static Semantics: ContainsArguments
|
||||||
|
IdentifierReference : Identifier
|
||||||
|
1. If the StringValue of Identifier is "arguments", return true.
|
||||||
|
...
|
||||||
|
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
|
||||||
|
---*/
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
class C {
|
||||||
|
x = () => {
|
||||||
|
var t = () => { arguments; };
|
||||||
|
t();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*---
|
||||||
|
description: error if `arguments` in StatementList of eval (direct eval)
|
||||||
|
esid: sec-performeval-rules-in-initializer
|
||||||
|
features: [class, class-fields-public, arrow-function]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Static Semantics: Early Errors
|
||||||
|
|
||||||
|
FieldDefinition:
|
||||||
|
PropertyNameInitializeropt
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsArguments of Initializer is true.
|
||||||
|
|
||||||
|
Static Semantics: ContainsArguments
|
||||||
|
IdentifierReference : Identifier
|
||||||
|
|
||||||
|
1. If the StringValue of Identifier is "arguments", return true.
|
||||||
|
...
|
||||||
|
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
class C {
|
||||||
|
x = () => {
|
||||||
|
var t = () => { eval("arguments"); };
|
||||||
|
t();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
var c = new C();
|
||||||
|
c.x();
|
||||||
|
});
|
@ -0,0 +1,30 @@
|
|||||||
|
/*---
|
||||||
|
description: error if `arguments` in StatementList of eval (direct eval)
|
||||||
|
esid: sec-performeval-rules-in-initializer
|
||||||
|
features: [class, class-fields-public, arrow-function]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Static Semantics: Early Errors
|
||||||
|
|
||||||
|
FieldDefinition:
|
||||||
|
PropertyNameInitializeropt
|
||||||
|
|
||||||
|
- It is a Syntax Error if ContainsArguments of Initializer is true.
|
||||||
|
|
||||||
|
Static Semantics: ContainsArguments
|
||||||
|
IdentifierReference : Identifier
|
||||||
|
|
||||||
|
1. If the StringValue of Identifier is "arguments", return true.
|
||||||
|
...
|
||||||
|
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
class C {
|
||||||
|
x = eval("() => arguments");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(SyntaxError, function() {
|
||||||
|
var c = new C();
|
||||||
|
c.x();
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user