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

Unified Diff: test/mjsunit/string-wrapper.js

Issue 1857163002: [elements] cleaning up string wrapper elements kind and adding tests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup Created 4 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 | « src/elements.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/string-wrapper.js
diff --git a/test/mjsunit/string-wrapper.js b/test/mjsunit/string-wrapper.js
new file mode 100644
index 0000000000000000000000000000000000000000..2d44eaef8e482778ba5a980c69d81777d76d7d75
--- /dev/null
+++ b/test/mjsunit/string-wrapper.js
@@ -0,0 +1,41 @@
+// Copyright 2016 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.
+
+var limit = 10000;
+
+function testStringWrapper(string) {
+ assertEquals('a', string[0]);
+ assertEquals('b', string[1]);
+ assertEquals('c', string[2]);
+}
+
+(function testFastStringWrapperGrow() {
+ var string = new String("abc");
+ for (var i = 0; i < limit; i += 2) {
+ string[i] = {};
+ }
+ testStringWrapper(string);
+
+ for (var i = limit; i > 0; i -= 2) {
+ delete string[i];
+ }
+ testStringWrapper(string);
+})();
+
+(function testSlowStringWrapperGrow() {
+ var string = new String("abc");
+ // Force Slow String Wrapper Elements Kind
+ string[limit] = limit;
+ for (var i = 0; i < limit; i += 2) {
+ string[i] = {};
+ }
+ testStringWrapper(string);
+ assertEquals(limit, string[limit]);
+
+ for (var i = limit; i > 0; i -= 2) {
+ delete string[i];
+ }
+ testStringWrapper(string);
+ assertEquals(undefined, string[limit]);
+})();
« no previous file with comments | « src/elements.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698