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

Unified Diff: tools/gn/parse_tree_unittest.cc

Issue 1038233002: tools/gn: disallow non-canonical integer literals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move kBad tests down by usage Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/parse_tree.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/parse_tree_unittest.cc
diff --git a/tools/gn/parse_tree_unittest.cc b/tools/gn/parse_tree_unittest.cc
index 827f3d54a5ce55d630a750fdee6163f183646598..29a0faf36f951890f5475f1416908c3d3e5deceb 100644
--- a/tools/gn/parse_tree_unittest.cc
+++ b/tools/gn/parse_tree_unittest.cc
@@ -212,3 +212,39 @@ TEST(ParseTree, SortRangeExtraction) {
EXPECT_EQ(3u, ranges[0].end);
}
}
+
+TEST(ParseTree, Integers) {
+ static const char* const kGood[] = {
+ "0",
+ "10",
+ "-54321",
+ "9223372036854775807", // INT64_MAX
+ "-9223372036854775808", // INT64_MIN
+ };
+ for (auto s : kGood) {
+ TestParseInput input(std::string("x = ") + s);
+ EXPECT_FALSE(input.has_error());
+
+ TestWithScope setup;
+ Err err;
+ input.parsed()->Execute(setup.scope(), &err);
+ EXPECT_FALSE(err.has_error());
+ }
+
+ static const char* const kBad[] = {
+ "-0",
+ "010",
+ "-010",
+ "9223372036854775808", // INT64_MAX + 1
+ "-9223372036854775809", // INT64_MIN - 1
+ };
+ for (auto s : kBad) {
+ TestParseInput input(std::string("x = ") + s);
+ EXPECT_FALSE(input.has_error());
+
+ TestWithScope setup;
+ Err err;
+ input.parsed()->Execute(setup.scope(), &err);
+ EXPECT_TRUE(err.has_error());
+ }
+}
« no previous file with comments | « tools/gn/parse_tree.cc ('k') | tools/gn/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698