summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Locale/subclassing.js
blob: 4afc3a5a836cc6c91e14afa318d3a7ce34d0d2bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Locale
description: Checks that Locale can be subclassed.
info: |
    Intl.Locale( tag [, options] )

    6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, %LocalePrototype%, internalSlotsList).

features: [Intl.Locale]
---*/

class CustomLocale extends Intl.Locale {
  constructor(locales, options) {
    super(locales, options);
    this.isCustom = true;
  }
}

var locale = new CustomLocale("de");
assert.sameValue(locale.isCustom, true, "Custom property");
assert.sameValue(locale.toString(), "de", "Direct call");
assert.sameValue(Intl.Locale.prototype.toString.call(locale), "de", "Indirect call");
assert.sameValue(Object.getPrototypeOf(locale), CustomLocale.prototype, "Prototype");

reportCompare(0, 0);