test262/test/intl402/Locale/getters-grandfathered.js

46 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-05-11 10:33:32 +02:00
// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.locale
description: >
Verifies getters with grandfathered tags.
info: |
get Intl.Locale.prototype.baseName
4. If locale does not match the langtag production, return locale.
5. Return the substring of locale corresponding to the
language ["-" script] ["-" region] *("-" variant)
subsequence of the langtag grammar.
get Intl.Locale.prototype.language
2018-10-17 16:45:33 +02:00
4. If locale matches the privateuse or the grandfathered production, return locale.
2018-05-11 10:33:32 +02:00
get Intl.Locale.prototype.script
4. If locale matches the privateuse or the grandfathered production, return undefined.
get Intl.Locale.prototype.region
4. If locale matches the privateuse or the grandfathered production, return undefined.
features: [Intl.Locale]
---*/
// Irregular grandfathered language tag.
var loc = new Intl.Locale("i-default");
assert.sameValue(loc.baseName, "i-default"); // Step 4.
2018-10-17 16:45:33 +02:00
assert.sameValue(loc.language, "i-default");
2018-05-11 10:33:32 +02:00
assert.sameValue(loc.script, undefined);
assert.sameValue(loc.region, undefined);
// Regular grandfathered language tag.
var loc = new Intl.Locale("cel-gaulish");
assert.sameValue(loc.baseName, "cel-gaulish"); // Step 5.
2018-10-17 16:45:33 +02:00
assert.sameValue(loc.language, "cel-gaulish");
2018-05-11 10:33:32 +02:00
assert.sameValue(loc.script, undefined);
assert.sameValue(loc.region, undefined);
// Regular grandfathered language tag.
var loc = new Intl.Locale("zh-min");
assert.sameValue(loc.baseName, "zh-min"); // Step 5.
2018-10-17 16:45:33 +02:00
assert.sameValue(loc.language, "zh-min");
2018-05-11 10:33:32 +02:00
assert.sameValue(loc.script, undefined);
assert.sameValue(loc.region, undefined);