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

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

Issue 103593006: Allow GN imports to be processed from imports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/scope.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/input_file.h"
7 #include "tools/gn/parse_tree.h"
8 #include "tools/gn/scope.h"
9 #include "tools/gn/test_with_scope.h"
10
11 TEST(Scope, NonRecursiveMergeTo) {
12 TestWithScope setup;
13
14 // Make a pretend parse node with proper tracking that we can blame for the
15 // given value.
16 InputFile input_file(SourceFile("//foo"));
17 Token assignment_token(Location(&input_file, 1, 1), Token::STRING,
18 "\"hello\"");
19 LiteralNode assignment;
20 assignment.set_value(assignment_token);
21
22 Value old_value(&assignment, "hello");
23 setup.scope()->SetValue("v", old_value, &assignment);
24
25 // Detect collisions of values' values.
26 {
27 Scope new_scope(setup.settings());
28 Value new_value(&assignment, "goodbye");
29 new_scope.SetValue("v", new_value, &assignment);
30
31 Err err;
32 EXPECT_FALSE(new_scope.NonRecursiveMergeTo(
33 setup.scope(), &assignment, "error", &err));
34 EXPECT_TRUE(err.has_error());
35 }
36
37 // Don't flag values that technically collide but have the same value.
38 {
39 Scope new_scope(setup.settings());
40 Value new_value(&assignment, "hello");
41 new_scope.SetValue("v", new_value, &assignment);
42
43 Err err;
44 EXPECT_TRUE(new_scope.NonRecursiveMergeTo(
45 setup.scope(), &assignment, "error", &err));
46 EXPECT_FALSE(err.has_error());
47 }
48 }
OLDNEW
« no previous file with comments | « tools/gn/scope.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698