Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: test/intl/date-format/resolved-options.js

Issue 148883002: Synchronize with r15594. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 // Test if resolvedOptions() returns expected fields/values.
29
30 // Default (year, month, day) formatter.
31 var dtfDefault = Intl.DateTimeFormat('en-US');
32 var resolved = dtfDefault.resolvedOptions();
33
34 assertTrue(resolved.hasOwnProperty('locale'));
35 assertEquals('en-US', resolved.locale);
36 assertTrue(resolved.hasOwnProperty('numberingSystem'));
37 assertEquals('latn', resolved.numberingSystem);
38 assertTrue(resolved.hasOwnProperty('calendar'));
39 assertEquals('gregory', resolved.calendar);
40 assertTrue(resolved.hasOwnProperty('timeZone'));
41 assertEquals(getDefaultTimeZone(), resolved.timeZone);
42 // These are in by default.
43 assertTrue(resolved.hasOwnProperty('year'));
44 assertEquals('numeric', resolved.year);
45 assertTrue(resolved.hasOwnProperty('month'));
46 assertEquals('numeric', resolved.month);
47 assertTrue(resolved.hasOwnProperty('day'));
48 assertEquals('numeric', resolved.day);
49 // These shouldn't be in by default.
50 assertFalse(resolved.hasOwnProperty('era'));
51 assertFalse(resolved.hasOwnProperty('timeZoneName'));
52 assertFalse(resolved.hasOwnProperty('weekday'));
53 assertFalse(resolved.hasOwnProperty('hour12'));
54 assertFalse(resolved.hasOwnProperty('hour'));
55 assertFalse(resolved.hasOwnProperty('minute'));
56 assertFalse(resolved.hasOwnProperty('second'));
57
58 // Time formatter.
59 var dtfTime = Intl.DateTimeFormat(
60 'sr-RS', {hour: 'numeric', minute: 'numeric', second: 'numeric'});
61 resolved = dtfTime.resolvedOptions();
62
63 assertTrue(resolved.hasOwnProperty('locale'));
64 assertTrue(resolved.hasOwnProperty('numberingSystem'));
65 assertTrue(resolved.hasOwnProperty('calendar'));
66 assertTrue(resolved.hasOwnProperty('timeZone'));
67 assertTrue(resolved.hasOwnProperty('hour12'));
68 assertEquals(false, resolved.hour12);
69 assertTrue(resolved.hasOwnProperty('hour'));
70 assertEquals('2-digit', resolved.hour);
71 assertTrue(resolved.hasOwnProperty('minute'));
72 assertEquals('2-digit', resolved.minute);
73 assertTrue(resolved.hasOwnProperty('second'));
74 assertEquals('2-digit', resolved.second);
75 // Didn't ask for them.
76 assertFalse(resolved.hasOwnProperty('year'));
77 assertFalse(resolved.hasOwnProperty('month'));
78 assertFalse(resolved.hasOwnProperty('day'));
79 assertFalse(resolved.hasOwnProperty('era'));
80 assertFalse(resolved.hasOwnProperty('timeZoneName'));
81 assertFalse(resolved.hasOwnProperty('weekday'));
82
83 // Full formatter.
84 var dtfFull = Intl.DateTimeFormat(
85 'en-US', {weekday: 'short', era: 'short', year: 'numeric', month: 'short',
86 day: 'numeric', hour: 'numeric', minute: 'numeric',
87 second: 'numeric', timeZoneName: 'short', timeZone: 'UTC'});
88 resolved = dtfFull.resolvedOptions();
89
90 assertTrue(resolved.hasOwnProperty('locale'));
91 assertTrue(resolved.hasOwnProperty('numberingSystem'));
92 assertTrue(resolved.hasOwnProperty('calendar'));
93 assertTrue(resolved.hasOwnProperty('timeZone'));
94 assertTrue(resolved.hasOwnProperty('hour12'));
95 assertEquals(true, resolved.hour12);
96 assertTrue(resolved.hasOwnProperty('hour'));
97 assertTrue(resolved.hasOwnProperty('minute'));
98 assertTrue(resolved.hasOwnProperty('second'));
99 assertTrue(resolved.hasOwnProperty('year'));
100 assertTrue(resolved.hasOwnProperty('month'));
101 assertTrue(resolved.hasOwnProperty('day'));
102 assertTrue(resolved.hasOwnProperty('era'));
103 assertEquals('short', resolved.era);
104 assertTrue(resolved.hasOwnProperty('timeZoneName'));
105 assertEquals('short', resolved.timeZoneName);
106 assertTrue(resolved.hasOwnProperty('weekday'));
107 assertEquals('short', resolved.weekday);
OLDNEW
« no previous file with comments | « test/intl/date-format/protected-icu-internals.js ('k') | test/intl/date-format/resolved-options-is-method.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698