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

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: Just "auto"; it's cleaner 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
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..51b88f037116f1434ed091568e28e91578aa8a75 100644
--- a/tools/gn/parse_tree_unittest.cc
+++ b/tools/gn/parse_tree_unittest.cc
@@ -212,3 +212,41 @@ TEST(ParseTree, SortRangeExtraction) {
EXPECT_EQ(3u, ranges[0].end);
}
}
+
+TEST(ParseTree, Integers) {
+ const char *good[] = {
+ "0",
+ "10",
+ "-54321",
+ "9223372036854775807",
+ "-9223372036854775808",
+ };
+
+ const char *bad[] = {
+ "-0",
+ "010",
+ "-010",
+ "9223372036854775808",
+ "-9223372036854775809",
+ };
+
+ for (auto s : good) {
+ 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());
+ }
+
+ for (auto s : bad) {
+ 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());
+ }
+}
« tools/gn/parse_tree.cc ('K') | « 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