mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-25 00:31:27 +00:00
Required for nested template arguments, like `array<vec2<i32>, 2>` Bug: tint:1810 Change-Id: Ibf24ec8918ef7698232cb2ea0cb786144d6f0604 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119123 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com>
73 lines
2.2 KiB
C++
73 lines
2.2 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<ast::TemplatedIdentifier>();
|
|
ASSERT_NE(tmpl_ident, nullptr);
|
|
EXPECT_EQ(tmpl_ident->arguments.Length(), 1_u);
|
|
EXPECT_TRUE(tmpl_ident->arguments[0]->Is<ast::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, IsIdentifier) {
|
|
auto* i = Expr("ident");
|
|
EXPECT_TRUE(i->Is<IdentifierExpression>());
|
|
}
|
|
|
|
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
|