Index: test/mjsunit/array-sort.js |
diff --git a/test/mjsunit/array-sort.js b/test/mjsunit/array-sort.js |
index a082abcb1746d26984d1fd72d5f9abd05b309ef4..8dfa544d6cf9cc74bcb4cba8d5cb3e52b08d5f87 100644 |
--- a/test/mjsunit/array-sort.js |
+++ b/test/mjsunit/array-sort.js |
@@ -360,3 +360,18 @@ function TestSpecialCasesInheritedElementSort() { |
} |
TestSpecialCasesInheritedElementSort(); |
+ |
+// Test that sort calls compare function with global object as receiver, |
+// and with only elements of the array as arguments. |
+function o(v) { |
+ return {__proto__: o.prototype, val: v}; |
+} |
+var arr = [o(1), o(2), o(4), o(8), o(16), o(32), o(64), o(128), o(256), o(-0)]; |
+var global = this; |
+function cmpTest(a, b) { |
+ assertEquals(global, this); |
+ assertTrue(a instanceof o); |
+ assertTrue(b instanceof o); |
+ return a.val - b.val; |
+} |
+arr.sort(cmpTest); |