-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that getCanonicalLocales() returns a mutable object. (#746)
Will fix #745 Besides, add additional checks to make sure that getCanonicalLocales() returns an array.
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
test/intl402/Intl/getCanonicalLocales/returned-object-is-mutable.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,35 @@ | ||
// Copyright (C) 2016 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 a mutable array. | ||
info: | | ||
8.2.1 Intl.getCanonicalLocales (locales) | ||
1. Let ll be ? CanonicalizeLocaleList(locales). | ||
2. Return CreateArrayFromList(ll). | ||
includes: [propertyHelper.js] | ||
---*/ | ||
|
||
var locales = ['en-US', 'fr']; | ||
var result = Intl.getCanonicalLocales(locales); | ||
|
||
verifyEnumerable(result, 0); | ||
verifyWritable(result, 0); | ||
verifyConfigurable(result, 0); | ||
|
||
result = Intl.getCanonicalLocales(locales); | ||
verifyEnumerable(result, 1); | ||
verifyWritable(result, 1); | ||
verifyConfigurable(result, 1); | ||
|
||
result = Intl.getCanonicalLocales(locales); | ||
verifyNotEnumerable(result, 'length'); | ||
verifyNotConfigurable(result, 'length'); | ||
|
||
assert.sameValue(result.length, 2); | ||
result.length = 42; | ||
assert.sameValue(result.length, 42); | ||
assert.throws(RangeError, function() { | ||
result.length = "Leo"; | ||
}, "a non-numeric value can't be set to result.length"); |