test262/test/intl402/9.2.1_4.js

34 lines
1.5 KiB
JavaScript
Raw Normal View History

// Copyright 2012 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
2014-07-25 00:41:42 +02:00
es5id: 9.2.1_4
description: >
Tests that non-objects are converted to objects before
canonicalization.
author: Norbert Lindenberg
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
// undefined is handled separately
// null should result in a TypeError
2017-05-04 21:16:14 +02:00
assert.throws(TypeError, function() {
var supportedForNull = Constructor.supportedLocalesOf(null);
2017-05-04 21:16:14 +02:00
}, "Null as locale list was not rejected.");
// let's use an empty list for comparison
var supportedForEmptyList = Constructor.supportedLocalesOf([]);
// we don't compare the elements because length should be 0 - let's just verify that
2017-05-04 21:16:14 +02:00
assert.sameValue(supportedForEmptyList.length, 0, "Internal test error: Assumption about length being 0 is invalid.");
// most non-objects will be interpreted as empty lists because a missing length property is interpreted as 0
var supportedForNumber = Constructor.supportedLocalesOf(5);
2017-05-04 21:16:14 +02:00
assert.sameValue(supportedForNumber.length, supportedForEmptyList.length, "Supported locales differ between numeric and empty list input.");
var supportedForBoolean = Constructor.supportedLocalesOf(true);
2017-05-04 21:16:14 +02:00
assert.sameValue(supportedForBoolean.length, supportedForEmptyList.length, "Supported locales differ between boolean and empty list input.");
return true;
});