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

Unified Diff: test/mjsunit/compare-known-objects-tostringtag.js

Issue 1360723002: [crankshaft] Handle @@toStringTag accessor correctly for BuildCompareInstruction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 | « src/hydrogen.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/compare-known-objects-tostringtag.js
diff --git a/test/mjsunit/compare-known-objects-tostringtag.js b/test/mjsunit/compare-known-objects-tostringtag.js
new file mode 100644
index 0000000000000000000000000000000000000000..81544ca69fa86410f88fbb0ae88261017e0799fb
--- /dev/null
+++ b/test/mjsunit/compare-known-objects-tostringtag.js
@@ -0,0 +1,57 @@
+// Copyright 2015 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 --harmony-tostring
+
+function le(a, b) {
+ return a <= b;
+}
+
+function lt(a, b) {
+ return a < b;
+}
+
+function ge(a, b) {
+ return a >= b;
+}
+
+function gt(a, b) {
+ return a > b;
+}
+
+function test(a, b) {
+ // Check CompareIC for less than or equal of known objects.
+ assertThrows(function() {le(a, a)});
+ assertThrows(function() {le(a, b)});
+ assertThrows(function() {le(b, a)});
+ // Check CompareIC for less than of known objects.
+ assertThrows(function() {lt(a, a)});
+ assertThrows(function() {lt(a, b)});
+ assertThrows(function() {lt(b, a)});
+ // Check CompareIC for greater than or equal of known objects.
+ assertThrows(function() {ge(a, a)});
+ assertThrows(function() {ge(a, b)});
+ assertThrows(function() {ge(b, a)});
+ // Check CompareIC for greater than of known objects.
+ assertThrows(function() {gt(a, a)});
+ assertThrows(function() {gt(a, b)});
+ assertThrows(function() {gt(b, a)});
+}
+
+function O() { }
+Object.defineProperty(O.prototype, Symbol.toStringTag, {
+ get: function() { throw "@@toStringTag called!" }
+});
+
+var obj1 = new O;
+var obj2 = new O;
+
+assertTrue(%HaveSameMap(obj1, obj2));
+test(obj1, obj2);
+test(obj1, obj2);
+%OptimizeFunctionOnNextCall(le);
+%OptimizeFunctionOnNextCall(lt);
+%OptimizeFunctionOnNextCall(ge);
+%OptimizeFunctionOnNextCall(gt);
+test(obj1, obj2);
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698