js/src/tests/test262/intl402/ch12/12.1/12.1.2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/intl402/ch12/12.1/12.1.2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
     1.5 +// Copyright 2012 Mozilla Corporation. All rights reserved.
     1.6 +// This code is governed by the BSD license found in the LICENSE file.
     1.7 +
     1.8 +/**
     1.9 + * @description Tests that Intl.DateTimeFormat can be subclassed.
    1.10 + * @author Norbert Lindenberg
    1.11 + */
    1.12 +
    1.13 +$INCLUDE("testIntl.js");
    1.14 +
    1.15 +// get a date-time format and have it format an array of dates for comparison with the subclass
    1.16 +var locales = ["tlh", "id", "en"];
    1.17 +var a = [new Date(0), Date.now(), new Date(Date.parse("1989-11-09T17:57:00Z"))];
    1.18 +var referenceDateTimeFormat = new Intl.DateTimeFormat(locales);
    1.19 +var referenceFormatted = a.map(referenceDateTimeFormat.format);
    1.20 +
    1.21 +function MyDateTimeFormat(locales, options) {
    1.22 +    Intl.DateTimeFormat.call(this, locales, options);
    1.23 +    // could initialize MyDateTimeFormat properties
    1.24 +}
    1.25 +
    1.26 +MyDateTimeFormat.prototype = Object.create(Intl.DateTimeFormat.prototype);
    1.27 +MyDateTimeFormat.prototype.constructor = MyDateTimeFormat;
    1.28 +// could add methods to MyDateTimeFormat.prototype
    1.29 +
    1.30 +var format = new MyDateTimeFormat(locales);
    1.31 +var actual = a.map(format.format);
    1.32 +testArraysAreSame(referenceFormatted, actual);
    1.33 +

mercurial