diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c75ca8b289..d3b6c84f87 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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] diff --git a/test/language/import/dup-bound-names.js b/test/language/import/dup-bound-names.js new file mode 100644 index 0000000000..ffad6f4e95 --- /dev/null +++ b/test/language/import/dup-bound-names.js @@ -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'; diff --git a/test/language/module-code/dup-export-decl.js b/test/language/module-code/dup-export-decl.js new file mode 100644 index 0000000000..11ad18500c --- /dev/null +++ b/test/language/module-code/dup-export-decl.js @@ -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() {} diff --git a/test/language/module-code/dup-export-dflt.js b/test/language/module-code/dup-export-dflt.js new file mode 100644 index 0000000000..7acb62a9dd --- /dev/null +++ b/test/language/module-code/dup-export-dflt.js @@ -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; diff --git a/test/language/module-code/dup-export-id-as.js b/test/language/module-code/dup-export-id-as.js new file mode 100644 index 0000000000..7bf78a2752 --- /dev/null +++ b/test/language/module-code/dup-export-id-as.js @@ -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 }; diff --git a/test/language/module-code/dup-export-id.js b/test/language/module-code/dup-export-id.js new file mode 100644 index 0000000000..65ae1ceecc --- /dev/null +++ b/test/language/module-code/dup-export-id.js @@ -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 }; diff --git a/test/language/module-code/dup-lables.js b/test/language/module-code/dup-lables.js new file mode 100644 index 0000000000..3dd2e5f039 --- /dev/null +++ b/test/language/module-code/dup-lables.js @@ -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; +} diff --git a/test/language/module-code/dup-lex.js b/test/language/module-code/dup-lex.js new file mode 100644 index 0000000000..766795c3bd --- /dev/null +++ b/test/language/module-code/dup-lex.js @@ -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; diff --git a/test/language/module-code/export-unresolvable.js b/test/language/module-code/export-unresolvable.js new file mode 100644 index 0000000000..fccb3cf62f --- /dev/null +++ b/test/language/module-code/export-unresolvable.js @@ -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 }; diff --git a/test/language/module-code/import-as-stmt-list-item.js b/test/language/module-code/import-as-stmt-list-item.js new file mode 100644 index 0000000000..4cb68de6d7 --- /dev/null +++ b/test/language/module-code/import-as-stmt-list-item.js @@ -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'; +} diff --git a/test/language/module-code/lex-and-var.js b/test/language/module-code/lex-and-var.js new file mode 100644 index 0000000000..6e269e6310 --- /dev/null +++ b/test/language/module-code/lex-and-var.js @@ -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; diff --git a/test/language/module-code/new-target.js b/test/language/module-code/new-target.js new file mode 100644 index 0000000000..805d94ffae --- /dev/null +++ b/test/language/module-code/new-target.js @@ -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; diff --git a/test/language/module-code/super.js b/test/language/module-code/super.js new file mode 100644 index 0000000000..ea787f1bec --- /dev/null +++ b/test/language/module-code/super.js @@ -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; diff --git a/test/language/module-code/undef-break.js b/test/language/module-code/undef-break.js new file mode 100644 index 0000000000..e1b828fbeb --- /dev/null +++ b/test/language/module-code/undef-break.js @@ -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; +} diff --git a/test/language/module-code/undef-continue.js b/test/language/module-code/undef-continue.js new file mode 100644 index 0000000000..e6e0457293 --- /dev/null +++ b/test/language/module-code/undef-continue.js @@ -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; +}