summaryrefslogtreecommitdiff
path: root/deps/v8/test/intl/regress-903566.js
blob: 9346fa63a8c60d2f08138acc9b075255e1cbae63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// 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);