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

Unified Diff: tools/gn/parse_tree_unittest.cc

Issue 439513003: Improve GN value origins for error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/value.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 fc06c3255a8dab1d02e451e1f7770320ed2c9f36..4a9cf214c22ffff447ad9e779579495e5ff7e989 100644
--- a/tools/gn/parse_tree_unittest.cc
+++ b/tools/gn/parse_tree_unittest.cc
@@ -76,4 +76,28 @@ TEST(ParseTree, BlockUnusedVars) {
input_unused.parsed()->Execute(setup.scope(), &err);
EXPECT_TRUE(err.has_error());
+
+ // Also verify that the unused variable has the correct origin set. The
+ // origin will point to the value assigned to the variable (in this case, the
+ // "13" assigned to "b".
+ EXPECT_EQ(3, err.location().line_number());
+ EXPECT_EQ(7, err.location().char_offset());
+
+}
+
+TEST(ParseTree, OriginForDereference) {
+ TestWithScope setup;
+ TestParseInput input(
+ "a = 6\n"
+ "get_target_outputs(a)");
+ EXPECT_FALSE(input.has_error());
+
+ Err err;
+ input.parsed()->Execute(setup.scope(), &err);
+ EXPECT_TRUE(err.has_error());
+
+ // The origin for the "not a string" error message should be where the value
+ // was dereferenced (the "a" on the second line).
+ EXPECT_EQ(2, err.location().line_number());
+ EXPECT_EQ(20, err.location().char_offset());
}
« no previous file with comments | « tools/gn/parse_tree.cc ('k') | tools/gn/value.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698