| Index: test/mjsunit/harmony/async-keyword.js
|
| diff --git a/test/mjsunit/harmony/async-keyword.js b/test/mjsunit/harmony/async-keyword.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ab85aabe3ce682730479229bb515af539c15260f
|
| --- /dev/null
|
| +++ b/test/mjsunit/harmony/async-keyword.js
|
| @@ -0,0 +1,149 @@
|
| +// Copyright 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.
|
| +
|
| +// Flags: --harmony-sloppy-let
|
| +
|
| +// Make sure we parse async keyword correctly
|
| +// as an identifier (in both sloppy and strict mode)
|
| +
|
| +
|
| +function TestAsyncKeywordSloppyVar() {
|
| + var async = 10;
|
| + async = 20;
|
| + async = function() {};
|
| + async = function(async) { async: return async; };
|
| + async = async(30);
|
| + var t = async + async;
|
| + assertEquals(async, 30);
|
| + assertEquals(t, 60);
|
| +}
|
| +TestAsyncKeywordSloppyVar();
|
| +
|
| +
|
| +function TestAsyncKeywordSloppyLet() {
|
| + let async = 10;
|
| + async = 20;
|
| + async = function() {};
|
| + async = function(async) { async: return async; };
|
| + async = async(30);
|
| + var t = async + async;
|
| + assertEquals(async, 30);
|
| + assertEquals(t, 60);
|
| +}
|
| +TestAsyncKeywordSloppyLet();
|
| +
|
| +
|
| +function TestAsyncKeywordStrictVar() {
|
| + 'use strict';
|
| + var async = 10;
|
| + async = 20;
|
| + async = function() {};
|
| + async = function(async) { async: return async; };
|
| + async = async(30);
|
| + var t = async + async;
|
| + assertEquals(async, 30);
|
| + assertEquals(t, 60);
|
| +}
|
| +TestAsyncKeywordStrictVar();
|
| +
|
| +
|
| +function TestAsyncKeywordStrictLet() {
|
| + 'use strict';
|
| + let async = 10;
|
| + async = 20;
|
| + async = function() {};
|
| + async = function(async) { async: return async; };
|
| + async = async(30);
|
| + var t = async + async;
|
| + assertEquals(async, 30);
|
| + assertEquals(t, 60);
|
| +}
|
| +TestAsyncKeywordStrictLet();
|
| +
|
| +
|
| +function TestAsyncKeywordStrictConst() {
|
| + 'use strict';
|
| + const async = function() { async: return 10; };
|
| + assertEquals(async(), 10);
|
| +}
|
| +TestAsyncKeywordStrictConst();
|
| +
|
| +
|
| +function TestAsyncClassNameOrObjectSloppy() {
|
| + class async {
|
| + async() { return 1; }
|
| + }
|
| +
|
| + var c = new async();
|
| + assertEquals(c.async(), 1);
|
| +
|
| + var obj = {
|
| + async: function() {
|
| + async: var async = 10;
|
| + return async;
|
| + }
|
| + };
|
| +
|
| + assertEquals(obj.async(), 10);
|
| +
|
| + var obj2 = {
|
| + get async() {
|
| + return 42;
|
| + }
|
| + };
|
| +
|
| + assertEquals(obj2.async, 42);
|
| +}
|
| +TestAsyncClassNameOrObjectSloppy();
|
| +
|
| +
|
| +function TestAsyncClassNameOrObjectStrict() {
|
| + 'use strict';
|
| + class async {
|
| + async() { return 1; }
|
| + }
|
| +
|
| + var c = new async();
|
| + assertEquals(c.async(), 1);
|
| +
|
| + var obj = {
|
| + async: function() {
|
| + async: var async = 10;
|
| + return async;
|
| + }
|
| + };
|
| +
|
| + assertEquals(obj.async(), 10);
|
| +
|
| + var obj2 = {
|
| + get async() {
|
| + return 42;
|
| + }
|
| + };
|
| +
|
| + assertEquals(obj2.async, 42);
|
| +}
|
| +TestAsyncClassNameOrObjectStrict();
|
| +
|
| +
|
| +function TestAsyncGeneratorName() {
|
| + function* async() { async: yield 1; }
|
| + assertEquals(async().next().value, 1);
|
| +}
|
| +TestAsyncGeneratorName();
|
| +
|
| +
|
| +function TestAsyncKeywordLineTerminator() {
|
| + // async identifier followed by a function
|
| + // keyword on the next line
|
| + var async = 10;
|
| + var b = async
|
| + function foo() {
|
| + return 15;
|
| + }
|
| +
|
| + assertEquals(b, 10);
|
| + assertEquals(foo(), 15);
|
| +}
|
| +TestAsyncKeywordLineTerminator();
|
|
|