Replace command buffer FlushSync with WaitForTokenInRange and WaitForGetOffsetInRange
[chromium-blink-merge.git] / tools / gn / scope_unittest.cc
bloba693957923ee543c04a4dc52b1efd28c52e5d421
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.
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"
11 TEST(Scope, NonRecursiveMergeTo) {
12 TestWithScope setup;
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);
22 Value old_value(&assignment, "hello");
23 setup.scope()->SetValue("v", old_value, &assignment);
25 // Detect collisions of values' values.
27 Scope new_scope(setup.settings());
28 Value new_value(&assignment, "goodbye");
29 new_scope.SetValue("v", new_value, &assignment);
31 Err err;
32 EXPECT_FALSE(new_scope.NonRecursiveMergeTo(
33 setup.scope(), &assignment, "error", &err));
34 EXPECT_TRUE(err.has_error());
37 // Don't flag values that technically collide but have the same value.
39 Scope new_scope(setup.settings());
40 Value new_value(&assignment, "hello");
41 new_scope.SetValue("v", new_value, &assignment);
43 Err err;
44 EXPECT_TRUE(new_scope.NonRecursiveMergeTo(
45 setup.scope(), &assignment, "error", &err));
46 EXPECT_FALSE(err.has_error());