mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-16 12:21:35 +00:00
These uses are already in the ast namespace, so do not need the extra qualification. Change-Id: I5e66048c9485c55b72e61ffa5b85b17ba1c780d0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120761 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org>
68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
// Copyright 2020 The Tint Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "gtest/gtest-spi.h"
|
|
#include "src/tint/ast/test_helper.h"
|
|
|
|
namespace tint::ast {
|
|
namespace {
|
|
|
|
using namespace tint::number_suffixes; // NOLINT
|
|
|
|
using IdentifierExpressionTest = TestHelper;
|
|
|
|
TEST_F(IdentifierExpressionTest, Creation) {
|
|
auto* i = Expr("ident");
|
|
EXPECT_EQ(i->identifier->symbol, Symbol(1, ID()));
|
|
}
|
|
|
|
TEST_F(IdentifierExpressionTest, CreationTemplated) {
|
|
auto* i = Expr(Ident("ident", true));
|
|
EXPECT_EQ(i->identifier->symbol, Symbol(1, ID()));
|
|
auto* tmpl_ident = i->identifier->As<TemplatedIdentifier>();
|
|
ASSERT_NE(tmpl_ident, nullptr);
|
|
EXPECT_EQ(tmpl_ident->arguments.Length(), 1_u);
|
|
EXPECT_TRUE(tmpl_ident->arguments[0]->Is<BoolLiteralExpression>());
|
|
}
|
|
|
|
TEST_F(IdentifierExpressionTest, Creation_WithSource) {
|
|
auto* i = Expr(Source{{20, 2}}, "ident");
|
|
EXPECT_EQ(i->identifier->symbol, Symbol(1, ID()));
|
|
|
|
EXPECT_EQ(i->source.range, (Source::Range{{20, 2}}));
|
|
EXPECT_EQ(i->identifier->source.range, (Source::Range{{20, 2}}));
|
|
}
|
|
|
|
TEST_F(IdentifierExpressionTest, Assert_InvalidSymbol) {
|
|
EXPECT_FATAL_FAILURE(
|
|
{
|
|
ProgramBuilder b;
|
|
b.Expr("");
|
|
},
|
|
"internal compiler error");
|
|
}
|
|
|
|
TEST_F(IdentifierExpressionTest, Assert_DifferentProgramID_Symbol) {
|
|
EXPECT_FATAL_FAILURE(
|
|
{
|
|
ProgramBuilder b1;
|
|
ProgramBuilder b2;
|
|
b1.Expr(b2.Sym("b2"));
|
|
},
|
|
"internal compiler error");
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace tint::ast
|