Add tests for early errors in module syntax

Introduce the `module` flag to unambiguously identify tests that are
intended to be interpreted as module code.
This commit is contained in:
Mike Pennisi 2015-05-28 14:41:22 -04:00
parent 21b739f1dc
commit b8b462316b
15 changed files with 186 additions and 0 deletions

View File

@ -115,6 +115,8 @@ This tag is for boolean properties associated with the test.
- **`onlyStrict`** - only run the test in strict mode (*not supported by the browser runner*)
- **`noStrict`** - only run the test in "sloppy" mode
- **`module`** - interpret the source text as [module
code](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-modules)
#### features
**features**: [list]

View File

@ -0,0 +1,12 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if the BoundNames of ImportDeclaration contains any
duplicate entries.
flags: [module]
negative: SyntaxError
---*/
import { x, y as x } from 'z';

View File

@ -0,0 +1,13 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if the ExportedNames of ModuleItemList contains any
duplicate entries.
flags: [module]
negative: SyntaxError
---*/
export function f() {}
export function *f() {}

View File

@ -0,0 +1,13 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if the ExportedNames of ModuleItemList contains any
duplicate entries.
flags: [module]
negative: SyntaxError
---*/
export default var x = null;
export default var x = null;

View File

@ -0,0 +1,14 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if the ExportedNames of ModuleItemList contains any
duplicate entries.
flags: [module]
negative: SyntaxError
---*/
var x, y;
export { x as z };
export { y as z };

View File

@ -0,0 +1,14 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if the ExportedNames of ModuleItemList contains any
duplicate entries.
flags: [module]
negative: SyntaxError
---*/
var x;
export { x };
export { x };

View File

@ -0,0 +1,14 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if ContainsDuplicateLabels of ModuleItemList with
argument « » is true.
flags: [module]
negative: SyntaxError
---*/
label: {
label: 0;
}

View File

@ -0,0 +1,14 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 10.2.1
description: >
It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList
contains any duplicate entries.
flags: [module]
features: [let, const]
negative: SyntaxError
---*/
let x;
const x;

View File

@ -0,0 +1,13 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if any element of the ExportedBindings of
ModuleItemList does not also occur in either the VarDeclaredNames of
ModuleItemList, or the LexicallyDeclaredNames of ModuleItemList.
flags: [module]
negative: SyntaxError
---*/
export { unresolvable };

View File

@ -0,0 +1,14 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2
description: >
An ImportDeclaration is not a valid StatementListItem and is therefore
restricted from appearing within statements in a ModuleBody.
flags: [module]
negative: SyntaxError
---*/
{
import { x } from 'y';
}

View File

@ -0,0 +1,13 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 10.2.1
description: >
It is a Syntax Error if any element of the LexicallyDeclaredNames of
ModuleItemList also occurs in the VarDeclaredNames of ModuleItemList.
flags: [module]
features: [let]
---*/
let x;
var x;

View File

@ -0,0 +1,11 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if ModuleItemList Contains NewTarget
flags: [module]
negative: SyntaxError
---*/
new.target;

View File

@ -0,0 +1,11 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if ModuleItemList Contains super.
flags: [module]
negative: SyntaxError
---*/
super;

View File

@ -0,0 +1,14 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if ContainsUndefinedBreakTarget of ModuleItemList with
argument « » is true.
flags: [module]
negative: SyntaxError
---*/
while (false) {
break undef;
}

View File

@ -0,0 +1,14 @@
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 15.2.1.1
description: >
It is a Syntax Error if ContainsUndefinedContinueTarget of ModuleItemList
with arguments « » and « » is true.
flags: [module]
negative: SyntaxError
---*/
while (false) {
continue undef;
}