Index: test/mjsunit/global-hash.js |
diff --git a/test/mjsunit/string-search.js b/test/mjsunit/global-hash.js |
similarity index 77% |
copy from test/mjsunit/string-search.js |
copy to test/mjsunit/global-hash.js |
index 037725b95eb99ee843dc9e3cb511292e05bedaf4..18ea9f9e7786e865f9d550231dd4be3f1f1d16c1 100644 |
--- a/test/mjsunit/string-search.js |
+++ b/test/mjsunit/global-hash.js |
@@ -1,4 +1,4 @@ |
-// Copyright 2008 the V8 project authors. All rights reserved. |
+// Copyright 2015 the V8 project authors. All rights reserved. |
adamk
2015/05/21 19:11:32
Please use the short license header for new tests.
Erik Corry
2015/05/22 06:20:25
Done.
|
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
// met: |
@@ -25,15 +25,18 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-var str="ABC abc"; |
-var r = str.search('a'); |
-assertEquals(r, 4); |
+var global = this; |
-// Test for a lot of different string. |
+assertTrue(typeof(global) === "object"); // Global object. |
-var s = ""; |
+var s = new Set(); |
+s.add(global); // Puts a hash code on the global object. |
+assertTrue(s.has(global)); |
for (var i = 0; i < 100; i++) { |
- s += i; |
- var r = s.search(s); |
- assertEquals(0, r); |
+ // Force rehash. Global object is placed according to the hash code that it |
+ // gets in the C++ runtime. |
+ s.add(i); |
} |
+ |
+// Hopefully still findable using the JS hash code. |
adamk
2015/05/21 19:11:32
This test is good, but can you also add a cctest t
Erik Corry
2015/05/22 06:20:25
We already had this in test-api.cc, but it added t
|
+assertTrue(s.has(global)); |