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

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

Issue 2187523003: Allow creation and modification of scopes in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 4 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
« no previous file with comments | « tools/gn/parse_tree.cc ('k') | tools/gn/parser.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 "tools/gn/parse_tree.h" 5 #include "tools/gn/parse_tree.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 29 matching lines...) Expand all
40 "a", Value(nullptr, std::unique_ptr<Scope>(new Scope(setup.scope()))), 40 "a", Value(nullptr, std::unique_ptr<Scope>(new Scope(setup.scope()))),
41 nullptr); 41 nullptr);
42 result = accessor.Execute(setup.scope(), &err); 42 result = accessor.Execute(setup.scope(), &err);
43 EXPECT_TRUE(err.has_error()); 43 EXPECT_TRUE(err.has_error());
44 EXPECT_EQ(Value::NONE, result.type()); 44 EXPECT_EQ(Value::NONE, result.type());
45 45
46 // Define b, accessor should succeed now. 46 // Define b, accessor should succeed now.
47 const int64_t kBValue = 42; 47 const int64_t kBValue = 42;
48 err = Err(); 48 err = Err();
49 setup.scope() 49 setup.scope()
50 ->GetMutableValue("a", false) 50 ->GetMutableValue("a", Scope::SEARCH_NESTED, false)
51 ->scope_value() 51 ->scope_value()
52 ->SetValue("b", Value(nullptr, kBValue), nullptr); 52 ->SetValue("b", Value(nullptr, kBValue), nullptr);
53 result = accessor.Execute(setup.scope(), &err); 53 result = accessor.Execute(setup.scope(), &err);
54 EXPECT_FALSE(err.has_error()); 54 EXPECT_FALSE(err.has_error());
55 ASSERT_EQ(Value::INTEGER, result.type()); 55 ASSERT_EQ(Value::INTEGER, result.type());
56 EXPECT_EQ(kBValue, result.int_value()); 56 EXPECT_EQ(kBValue, result.int_value());
57 } 57 }
58 58
59 TEST(ParseTree, BlockUnusedVars) { 59 TEST(ParseTree, BlockUnusedVars) {
60 TestWithScope setup; 60 TestWithScope setup;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 for (auto* s : kBad) { 245 for (auto* s : kBad) {
246 TestParseInput input(std::string("x = ") + s); 246 TestParseInput input(std::string("x = ") + s);
247 EXPECT_FALSE(input.has_error()); 247 EXPECT_FALSE(input.has_error());
248 248
249 TestWithScope setup; 249 TestWithScope setup;
250 Err err; 250 Err err;
251 input.parsed()->Execute(setup.scope(), &err); 251 input.parsed()->Execute(setup.scope(), &err);
252 EXPECT_TRUE(err.has_error()); 252 EXPECT_TRUE(err.has_error());
253 } 253 }
254 } 254 }
OLDNEW
« no previous file with comments | « tools/gn/parse_tree.cc ('k') | tools/gn/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698