Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1579)

Unified Diff: test/mjsunit/harmony/async-keyword.js

Issue 1423663006: [es7] Implement async functions parsing Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/harmony/async-await-functions.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « test/mjsunit/harmony/async-await-functions.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698