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

Side by Side Diff: test/cctest/test-date.cc

Issue 12716010: Added a version of the v8::HandleScope constructor with an Isolate and use that consistently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed rest Created 7 years, 9 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
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 DateCache* date_cache = isolate->date_cache(); 112 DateCache* date_cache = isolate->date_cache();
113 int64_t actual = date_cache->ToLocal(time); 113 int64_t actual = date_cache->ToLocal(time);
114 int64_t expected = time + date_cache->GetLocalOffsetFromOS() + 114 int64_t expected = time + date_cache->GetLocalOffsetFromOS() +
115 date_cache->GetDaylightSavingsOffsetFromOS(time / 1000); 115 date_cache->GetDaylightSavingsOffsetFromOS(time / 1000);
116 CHECK_EQ(actual, expected); 116 CHECK_EQ(actual, expected);
117 } 117 }
118 118
119 119
120 TEST(DaylightSavingsTime) { 120 TEST(DaylightSavingsTime) {
121 LocalContext context; 121 LocalContext context;
122 v8::HandleScope scope; 122 v8::Isolate* isolate = context->GetIsolate();
123 Isolate* isolate = Isolate::Current(); 123 v8::HandleScope scope(isolate);
124 DateCacheMock::Rule rules[] = { 124 DateCacheMock::Rule rules[] = {
125 {0, 2, 0, 10, 0, 3600}, // DST from March to November in any year. 125 {0, 2, 0, 10, 0, 3600}, // DST from March to November in any year.
126 {2010, 2, 0, 7, 20, 3600}, // DST from March to August 20 in 2010. 126 {2010, 2, 0, 7, 20, 3600}, // DST from March to August 20 in 2010.
127 {2010, 7, 20, 8, 10, 0}, // No DST from August 20 to September 10 in 2010. 127 {2010, 7, 20, 8, 10, 0}, // No DST from August 20 to September 10 in 2010.
128 {2010, 8, 10, 10, 0, 3600}, // DST from September 10 to November in 2010. 128 {2010, 8, 10, 10, 0, 3600}, // DST from September 10 to November in 2010.
129 }; 129 };
130 130
131 int local_offset_ms = -36000000; // -10 hours. 131 int local_offset_ms = -36000000; // -10 hours.
132 132
133 DateCacheMock* date_cache = 133 DateCacheMock* date_cache =
134 new DateCacheMock(local_offset_ms, rules, ARRAY_SIZE(rules)); 134 new DateCacheMock(local_offset_ms, rules, ARRAY_SIZE(rules));
135 135
136 isolate->set_date_cache(date_cache); 136 reinterpret_cast<Isolate*>(isolate)->set_date_cache(date_cache);
137 137
138 int64_t start_of_2010 = TimeFromYearMonthDay(date_cache, 2010, 0, 1); 138 int64_t start_of_2010 = TimeFromYearMonthDay(date_cache, 2010, 0, 1);
139 int64_t start_of_2011 = TimeFromYearMonthDay(date_cache, 2011, 0, 1); 139 int64_t start_of_2011 = TimeFromYearMonthDay(date_cache, 2011, 0, 1);
140 int64_t august_20 = TimeFromYearMonthDay(date_cache, 2010, 7, 20); 140 int64_t august_20 = TimeFromYearMonthDay(date_cache, 2010, 7, 20);
141 int64_t september_10 = TimeFromYearMonthDay(date_cache, 2010, 8, 10); 141 int64_t september_10 = TimeFromYearMonthDay(date_cache, 2010, 8, 10);
142 CheckDST((august_20 + september_10) / 2); 142 CheckDST((august_20 + september_10) / 2);
143 CheckDST(september_10); 143 CheckDST(september_10);
144 CheckDST(september_10 + 2 * 3600); 144 CheckDST(september_10 + 2 * 3600);
145 CheckDST(september_10 + 2 * 3600 - 1000); 145 CheckDST(september_10 + 2 * 3600 - 1000);
146 CheckDST(august_20 + 2 * 3600); 146 CheckDST(august_20 + 2 * 3600);
(...skipping 12 matching lines...) Expand all
159 CheckDST(TimeFromYearMonthDay(date_cache, year, 5, 5)); 159 CheckDST(TimeFromYearMonthDay(date_cache, year, 5, 5));
160 } 160 }
161 CheckDST((august_20 + september_10) / 2); 161 CheckDST((august_20 + september_10) / 2);
162 CheckDST(september_10); 162 CheckDST(september_10);
163 CheckDST(september_10 + 2 * 3600); 163 CheckDST(september_10 + 2 * 3600);
164 CheckDST(september_10 + 2 * 3600 - 1000); 164 CheckDST(september_10 + 2 * 3600 - 1000);
165 CheckDST(august_20 + 2 * 3600); 165 CheckDST(august_20 + 2 * 3600);
166 CheckDST(august_20 + 2 * 3600 - 1000); 166 CheckDST(august_20 + 2 * 3600 - 1000);
167 CheckDST(august_20); 167 CheckDST(august_20);
168 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698