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

Unified Diff: tools/gn/value_unittest.cc

Issue 280273004: Support printing scopes in GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/value.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/value_unittest.cc
diff --git a/tools/gn/value_unittest.cc b/tools/gn/value_unittest.cc
index c7d49488d884798e476888b5a891897977d61d18..3fa990d4a28e915190c927f4fd36153f0a8c9b02 100644
--- a/tools/gn/value_unittest.cc
+++ b/tools/gn/value_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "testing/gtest/include/gtest/gtest.h"
+#include "tools/gn/test_with_scope.h"
#include "tools/gn/value.h"
TEST(Value, ToString) {
@@ -10,6 +11,9 @@ TEST(Value, ToString) {
EXPECT_EQ("hi\" $me\\you\\$\\\"", strval.ToString(false));
EXPECT_EQ("\"hi\\\" \\$me\\you\\\\\\$\\\\\\\"\"", strval.ToString(true));
+ // Void type.
+ EXPECT_EQ("<void>", Value().ToString(false));
+
// Test lists, bools, and ints.
Value listval(NULL, Value::LIST);
listval.list_value().push_back(Value(NULL, "hi\"me"));
@@ -21,9 +25,14 @@ TEST(Value, ToString) {
EXPECT_EQ("[\"hi\\\"me\", true, false, 42]", listval.ToString(false));
EXPECT_EQ("[\"hi\\\"me\", true, false, 42]", listval.ToString(true));
- // Some weird types, we may want to enhance or change printing of these, but
- // here we test the current behavior.
- EXPECT_EQ("<void>", Value().ToString(false));
- EXPECT_EQ("<scope>", Value(NULL, Value::SCOPE).ToString(false));
+ // Scopes.
+ TestWithScope setup;
+ Scope* scope = new Scope(setup.scope());
+ Value scopeval(NULL, scoped_ptr<Scope>(scope));
+ EXPECT_EQ("{ }", scopeval.ToString(false));
+
+ scope->SetValue("a", Value(NULL, static_cast<int64>(42)), NULL);
+ scope->SetValue("b", Value(NULL, "hello, world"), NULL);
+ EXPECT_EQ("{\n a = 42\n b = \"hello, world\"\n}", scopeval.ToString(false));
}
« no previous file with comments | « tools/gn/value.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698