e734cc6ea8
Add regression test to verify array with packed, holey and dictionary elements. Change ToUnicodeStringArray to return vector<UnicodeString> instead allocate raw UnicodeString before calling. Simplify ToUnicodeStringArray to loop only once. Bug: chromium:903566 Change-Id: I7ad74179be97d3cf929d2949384dbaa8b66a9a02 Reviewed-on: https://chromium-review.googlesource.com/c/1328642 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#57521}
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
// Copyright 2018 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
|
|
|
|
assertDoesNotThrow(()=>(new Intl.ListFormat()).format());
|
|
// Intl.getCanonicalLocales() will create a HOLEY_ELEMENTS array
|
|
assertDoesNotThrow(()=>(new Intl.ListFormat()).format(Intl.getCanonicalLocales()));
|
|
assertDoesNotThrow(()=>(new Intl.ListFormat()).format(Intl.getCanonicalLocales(["en","fr"])));
|
|
|
|
let arr = ["a","b","c"];
|
|
|
|
// Test under no HasHoleyElements();
|
|
assertFalse(%HasHoleyElements(arr));
|
|
assertDoesNotThrow(()=>(new Intl.ListFormat()).format(arr));
|
|
for (var i = 0; i < 10000; i++) {
|
|
arr.push("xx");
|
|
}
|
|
assertFalse(%HasHoleyElements(arr));
|
|
assertDoesNotThrow(()=>(new Intl.ListFormat()).format(arr));
|
|
|
|
// Test under HasHoleyElements();
|
|
arr[arr.length + 10] = "x";
|
|
assertTrue(%HasHoleyElements(arr));
|
|
assertFalse(%HasDictionaryElements(arr));
|
|
assertThrows(()=>(new Intl.ListFormat()).format(arr), TypeError);
|
|
|
|
// Test it work under HasDictionaryElements();
|
|
arr = ["a","b","c"];
|
|
arr[arr.length + 100000] = "x";
|
|
assertTrue(%HasDictionaryElements(arr));
|
|
assertThrows(()=>(new Intl.ListFormat()).format(arr), TypeError);
|