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

Unified Diff: test/mjsunit/compiler/array-constructor.js

Issue 2843033002: [test] Increase test coverage for Array constructor inlining. (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/compiler/array-constructor.js
diff --git a/test/mjsunit/compiler/array-constructor.js b/test/mjsunit/compiler/array-constructor.js
new file mode 100644
index 0000000000000000000000000000000000000000..583817b7d840f8c6c5a87f1e268f83132e3d9e06
--- /dev/null
+++ b/test/mjsunit/compiler/array-constructor.js
@@ -0,0 +1,89 @@
+// Copyright 2017 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: --allow-natives-syntax
+
+// Test Array call with known Boolean.
+(() => {
+ function foo(x) { return Array(!!x); }
+
+ assertEquals([true], foo(true));
+ assertEquals([false], foo(false));
+ %OptimizeFunctionOnNextCall(foo);
+ assertEquals([true], foo(true));
+ assertEquals([false], foo(false));
+})();
+
+// Test Array construct with known Boolean.
+(() => {
+ function foo(x) { return new Array(!!x); }
+
+ assertEquals([true], foo(true));
+ assertEquals([false], foo(false));
+ %OptimizeFunctionOnNextCall(foo);
+ assertEquals([true], foo(true));
+ assertEquals([false], foo(false));
+})();
+
+// Test Array call with known String.
+(() => {
+ function foo(x) { return Array("" + x); }
+
+ assertEquals(["a"], foo("a"));
+ assertEquals(["b"], foo("b"));
+ %OptimizeFunctionOnNextCall(foo);
+ assertEquals(["a"], foo("a"));
+ assertEquals(["b"], foo("b"));
+})();
+
+// Test Array construct with known String.
+(() => {
+ function foo(x) { return new Array("" + x); }
+
+ assertEquals(["a"], foo("a"));
+ assertEquals(["b"], foo("b"));
+ %OptimizeFunctionOnNextCall(foo);
+ assertEquals(["a"], foo("a"));
+ assertEquals(["b"], foo("b"));
+})();
+
+// Test Array call with known fixed small integer.
+(() => {
+ function foo() { return Array(2); }
+
+ assertEquals(2, foo().length);
+ assertEquals(2, foo().length);
+ %OptimizeFunctionOnNextCall(foo);
+ assertEquals(2, foo().length);
+})();
+
+// Test Array construct with known fixed small integer.
+(() => {
+ function foo() { return new Array(2); }
+
+ assertEquals(2, foo().length);
+ assertEquals(2, foo().length);
+ %OptimizeFunctionOnNextCall(foo);
+ assertEquals(2, foo().length);
+})();
+
+// Test Array call with multiple parameters.
+(() => {
+ function foo(x, y, z) { return Array(x, y, z); }
+
+ assertEquals([1, 2, 3], foo(1, 2, 3));
+ assertEquals([1, 2, 3], foo(1, 2, 3));
+ %OptimizeFunctionOnNextCall(foo);
+ assertEquals([1, 2, 3], foo(1, 2, 3));
+})();
+
+// Test Array construct with multiple parameters.
+(() => {
+ function foo(x, y, z) { return new Array(x, y, z); }
+
+ assertEquals([1, 2, 3], foo(1, 2, 3));
+ assertEquals([1, 2, 3], foo(1, 2, 3));
+ %OptimizeFunctionOnNextCall(foo);
+ assertEquals([1, 2, 3], foo(1, 2, 3));
+})();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698