mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-18 18:01:37 +00:00
Remove the direct use of BuilderImpl from TestHelperBase to cut down the amount of internal state management required by the tests, and removing confusing conflation between the BuilderImpl and Builder. This change removes the following methods from TestHelperBase: * CreateBuilder() * InjectFlowBlock() * CreateEmptyBuilder() * FlowNodeForAstNode() Tests now just use FromProgram() function for testing AST -> IR. The downside to the black-box testing is that the per-method granularity of the unit testing increases to whole FromProgram() granularity. However, my personal opinion is that this is more than offset by the lack of state leakage from the implementation to the tests. Bug tint:1718 Change-Id: Iba2560e0fbcbd3dfb936694e50997d716f09fbd8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132960 Kokoro: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
// Copyright 2023 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 "src/tint/ir/test_helper.h"
|
|
|
|
#include "gmock/gmock.h"
|
|
#include "src/tint/ast/case_selector.h"
|
|
#include "src/tint/ast/int_literal_expression.h"
|
|
#include "src/tint/constant/scalar.h"
|
|
|
|
namespace tint::ir {
|
|
namespace {
|
|
|
|
using namespace tint::number_suffixes; // NOLINT
|
|
|
|
using IR_BuilderImplTest = TestHelper;
|
|
|
|
TEST_F(IR_BuilderImplTest, EmitExpression_MaterializedCall) {
|
|
auto* expr = Return(Call("trunc", 2.5_f));
|
|
|
|
Func("test_function", {}, ty.f32(), expr, utils::Empty);
|
|
|
|
auto m = Build();
|
|
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
|
|
|
|
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():f32
|
|
%fn2 = block
|
|
ret 2.0f
|
|
func_end
|
|
|
|
)");
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace tint::ir
|