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

Side by Side Diff: tools/gn/parse_tree_unittest.cc

Issue 287693002: Support private values in GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix semicolon 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/parse_tree.cc ('k') | tools/gn/scope.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/input_file.h" 6 #include "tools/gn/input_file.h"
7 #include "tools/gn/parse_tree.h" 7 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/scope.h" 8 #include "tools/gn/scope.h"
9 #include "tools/gn/test_with_scope.h" 9 #include "tools/gn/test_with_scope.h"
10 10
(...skipping 30 matching lines...) Expand all
41 // Define b, accessor should succeed now. 41 // Define b, accessor should succeed now.
42 const int64 kBValue = 42; 42 const int64 kBValue = 42;
43 err = Err(); 43 err = Err();
44 setup.scope()->GetMutableValue("a", false)->scope_value()->SetValue( 44 setup.scope()->GetMutableValue("a", false)->scope_value()->SetValue(
45 "b", Value(NULL, kBValue), NULL); 45 "b", Value(NULL, kBValue), NULL);
46 result = accessor.Execute(setup.scope(), &err); 46 result = accessor.Execute(setup.scope(), &err);
47 EXPECT_FALSE(err.has_error()); 47 EXPECT_FALSE(err.has_error());
48 ASSERT_EQ(Value::INTEGER, result.type()); 48 ASSERT_EQ(Value::INTEGER, result.type());
49 EXPECT_EQ(kBValue, result.int_value()); 49 EXPECT_EQ(kBValue, result.int_value());
50 } 50 }
51
52 TEST(ParseTree, BlockUnusedVars) {
53 TestWithScope setup;
54
55 // Printing both values should be OK.
56 TestParseInput input_all_used(
57 "{\n"
58 " a = 12\n"
59 " b = 13\n"
60 " print(\"$a $b\")\n"
61 "}");
62 EXPECT_FALSE(input_all_used.has_error());
63
64 Err err;
65 input_all_used.parsed()->Execute(setup.scope(), &err);
66 EXPECT_FALSE(err.has_error());
67
68 // Skipping one should throw an unused var error.
69 TestParseInput input_unused(
70 "{\n"
71 " a = 12\n"
72 " b = 13\n"
73 " print(\"$a\")\n"
74 "}");
75 EXPECT_FALSE(input_unused.has_error());
76
77 input_unused.parsed()->Execute(setup.scope(), &err);
78 EXPECT_TRUE(err.has_error());
79 }
OLDNEW
« no previous file with comments | « tools/gn/parse_tree.cc ('k') | tools/gn/scope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698