v8/test/mjsunit/string-wrapper.js
cbruni ca5b896fab [elements] cleaning up string wrapper elements kind and adding tests
drive-by-fix: unify template parameters

BUG=chromium:586068
LOG=n

Review URL: https://codereview.chromium.org/1857163002

Cr-Commit-Position: refs/heads/master@{#35302}
2016-04-06 13:38:34 +00:00

42 lines
1009 B
JavaScript

// 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]);
})();