Fixup validator tests added during split from resolver.
This PR adds the validator_is_storable test into the CMakeList file correctly and removes the helper files. The resolver helper is used instead and a test helper to return the validator added into the resolver. Change-Id: I5b18bcc6373e3b39807af05cf5c058fab61ed4ca Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88041 Auto-Submit: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
8e2a1f9ab9
commit
d3a5080c7b
|
@ -772,6 +772,7 @@ if(TINT_BUILD_TESTS)
|
||||||
resolver/type_constructor_validation_test.cc
|
resolver/type_constructor_validation_test.cc
|
||||||
resolver/type_validation_test.cc
|
resolver/type_validation_test.cc
|
||||||
resolver/validation_test.cc
|
resolver/validation_test.cc
|
||||||
|
resolver/validator_is_storeable_test.cc
|
||||||
resolver/var_let_test.cc
|
resolver/var_let_test.cc
|
||||||
resolver/var_let_validation_test.cc
|
resolver/var_let_validation_test.cc
|
||||||
scope_stack_test.cc
|
scope_stack_test.cc
|
||||||
|
|
|
@ -108,6 +108,9 @@ class Resolver {
|
||||||
return validator_.IsHostShareable(type);
|
return validator_.IsHostShareable(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @returns the validator for testing
|
||||||
|
const Validator* GetValidatorForTesting() const { return &validator_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Describes the context in which a variable is declared
|
/// Describes the context in which a variable is declared
|
||||||
enum class VariableKind { kParameter, kLocal, kGlobal };
|
enum class VariableKind { kParameter, kLocal, kGlobal };
|
||||||
|
|
|
@ -40,6 +40,9 @@ class TestHelper : public ProgramBuilder {
|
||||||
/// @return a pointer to the Resolver
|
/// @return a pointer to the Resolver
|
||||||
Resolver* r() const { return resolver_.get(); }
|
Resolver* r() const { return resolver_.get(); }
|
||||||
|
|
||||||
|
/// @return a pointer to the validator
|
||||||
|
const Validator* v() const { return resolver_->GetValidatorForTesting(); }
|
||||||
|
|
||||||
/// Returns the statement that holds the given expression.
|
/// Returns the statement that holds the given expression.
|
||||||
/// @param expr the ast::Expression
|
/// @param expr the ast::Expression
|
||||||
/// @return the ast::Statement of the ast::Expression, or nullptr if the
|
/// @return the ast::Statement of the ast::Expression, or nullptr if the
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
#include "src/tint/resolver/validator.h"
|
#include "src/tint/resolver/validator.h"
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "src/tint/resolver/validator_test_helper.h"
|
#include "src/tint/resolver/resolver_test_helper.h"
|
||||||
#include "src/tint/sem/atomic_type.h"
|
#include "src/tint/sem/atomic_type.h"
|
||||||
|
|
||||||
namespace tint::resolver {
|
namespace tint::resolver {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ValidatorIsStorableTest = ValidatorTest;
|
using ValidatorIsStorableTest = ResolverTest;
|
||||||
|
|
||||||
TEST_F(ValidatorIsStorableTest, Void) {
|
TEST_F(ValidatorIsStorableTest, Void) {
|
||||||
EXPECT_FALSE(v()->IsStorable(create<sem::Void>()));
|
EXPECT_FALSE(v()->IsStorable(create<sem::Void>()));
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
// Copyright 2022 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/resolver/validator_test_helper.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace tint::resolver {
|
|
||||||
|
|
||||||
TestHelper::TestHelper()
|
|
||||||
: validator_(
|
|
||||||
std::make_unique<Validator>(this->Symbols(), this->Diagnostics())) {}
|
|
||||||
|
|
||||||
TestHelper::~TestHelper() = default;
|
|
||||||
|
|
||||||
} // namespace tint::resolver
|
|
|
@ -1,46 +0,0 @@
|
||||||
// Copyright 2022 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.
|
|
||||||
|
|
||||||
#ifndef SRC_TINT_RESOLVER_VALIDATOR_TEST_HELPER_H_
|
|
||||||
#define SRC_TINT_RESOLVER_VALIDATOR_TEST_HELPER_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
#include "src/tint/program_builder.h"
|
|
||||||
#include "src/tint/resolver/validator.h"
|
|
||||||
|
|
||||||
namespace tint::resolver {
|
|
||||||
|
|
||||||
/// Helper class for testing
|
|
||||||
class TestHelper : public ProgramBuilder {
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
TestHelper();
|
|
||||||
|
|
||||||
/// Destructor
|
|
||||||
~TestHelper() override;
|
|
||||||
|
|
||||||
/// @return a pointer to the Validator
|
|
||||||
Validator* v() const { return validator_.get(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<Validator> validator_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ValidatorTest : public TestHelper, public testing::Test {};
|
|
||||||
|
|
||||||
} // namespace tint::resolver
|
|
||||||
|
|
||||||
#endif // SRC_TINT_RESOLVER_VALIDATOR_TEST_HELPER_H_
|
|
|
@ -274,6 +274,7 @@ tint_unittests_source_set("tint_unittests_resolver_src") {
|
||||||
"../../src/tint/resolver/type_constructor_validation_test.cc",
|
"../../src/tint/resolver/type_constructor_validation_test.cc",
|
||||||
"../../src/tint/resolver/type_validation_test.cc",
|
"../../src/tint/resolver/type_validation_test.cc",
|
||||||
"../../src/tint/resolver/validation_test.cc",
|
"../../src/tint/resolver/validation_test.cc",
|
||||||
|
"../../src/tint/resolver/validator_is_storeable_test.cc",
|
||||||
"../../src/tint/resolver/var_let_test.cc",
|
"../../src/tint/resolver/var_let_test.cc",
|
||||||
"../../src/tint/resolver/var_let_validation_test.cc",
|
"../../src/tint/resolver/var_let_validation_test.cc",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue