Skip to content

Commit

Permalink
Test the properties of an array returned by getCanonicalLocales()
Browse files Browse the repository at this point in the history
Will fix #745

The result should be expandable, but each element should be
frozen.
  • Loading branch information
jungshik committed Aug 14, 2016
1 parent 894bbcc commit e480d0a
Showing 1 changed file with 29 additions and 0 deletions.
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');

0 comments on commit e480d0a

Please sign in to comment.