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

Unified Diff: test/cctest/test-date.cc

Issue 2080183003: Only count legacy parser usage if legacy parser had effect. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add test Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/dateparser-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-date.cc
diff --git a/test/cctest/test-date.cc b/test/cctest/test-date.cc
index c2f196c0a48a5fecc90eb9f5df8b6b88b01fa7a6..a745949fbdbc544bed26a85c16faf320012c12c2 100644
--- a/test/cctest/test-date.cc
+++ b/test/cctest/test-date.cc
@@ -167,6 +167,32 @@ TEST(DaylightSavingsTime) {
CheckDST(august_20);
}
+namespace {
+int legacy_parse_count = 0;
+void DateParseLegacyCounterCallback(v8::Isolate* isolate,
+ v8::Isolate::UseCounterFeature feature) {
+ if (feature == v8::Isolate::kLegacyDateParser) legacy_parse_count++;
+}
+} // anonymous namespace
+
+TEST(DateParseLegacyUseCounter) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ LocalContext context;
+ CcTest::isolate()->SetUseCounterCallback(DateParseLegacyCounterCallback);
+ CHECK_EQ(0, legacy_parse_count);
+ CompileRun("Date.parse('2015-02-31')");
+ CHECK_EQ(0, legacy_parse_count);
+ CompileRun("Date.parse('2015-02-31T11:22:33.444Z01:23')");
+ CHECK_EQ(0, legacy_parse_count);
+ CompileRun("Date.parse('2015-02-31T11:22:33.444')");
+ CHECK_EQ(0, legacy_parse_count);
+ CompileRun("Date.parse('2000 01 01')");
+ CHECK_EQ(1, legacy_parse_count);
+ CompileRun("Date.parse('2015-02-31T11:22:33.444 ')");
+ CHECK_EQ(1, legacy_parse_count);
+}
+
#ifdef V8_I18N_SUPPORT
TEST(DateCacheVersion) {
FLAG_allow_natives_syntax = true;
« no previous file with comments | « src/dateparser-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698