-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the properties of an array returned by getCanonicalLocales()
Will fix #745 The result should be expandable, but each element should be frozen.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
test/intl402/Intl/getCanonicalLocales/returned-object-is-an-array-with-frozen-elements.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2015 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-intl.getcanonicallocales | ||
description: Tests that the value returned by getCanonicalLocales is an Array | ||
with each element frozen that can be expanded. | ||
info: | | ||
8.2.1 Intl.getCanonicalLocales (locales) | ||
1. Let ll be ? CanonicalizeLocaleList(locales). | ||
2. Return CreateArrayFromList(ll). | ||
includes: [compareArray.js] | ||
---*/ | ||
|
||
var locales = ['en-US', 'fr']; | ||
var result = Intl.getCanonicalLocales(locales); | ||
var len = result.length | ||
|
||
// Individual elements should not be mutable. | ||
for (var key in result) { | ||
var desc = Object.getOwnPropertyDescriptor(result, key); | ||
assert.sameValue(desc.writable, false, 'element is not writable'); | ||
assert.sameValue(desc.configurable, false, 'element is not configurable'); | ||
assert(desc.enumerable, 'element is enumerable'); | ||
} | ||
|
||
// However, the array should be expandable. | ||
var desc = Object.getOwnPropertyDescriptor(result, 'length'); | ||
assert(desc.writable, 'result.length is writable'); | ||
assert.sameValue(result.push('de'), desc.value + 1, 'result is expandable'); |