chromium/third_party/dawn/src/tint/lang/wgsl/resolver/type_validation_test.cc

// Copyright 2021 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "src/tint/lang/core/type/multisampled_texture.h"
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/wgsl/ast/id_attribute.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/resolver/resolver.h"
#include "src/tint/lang/wgsl/resolver/resolver_helper_test.h"

#include "gmock/gmock.h"

namespace tint::resolver {
namespace {

usingnamespacetint::core::fluent_types;     // NOLINT
usingnamespacetint::core::number_suffixes;  // NOLINT

// Helpers and typedefs
DataType;
alias;
alias1;
alias2;
alias3;

class ResolverTypeValidationTest : public resolver::TestHelper, public testing::Test {};

TEST_F(ResolverTypeValidationTest, VariableDeclNoInitializer_Pass) {}

TEST_F(ResolverTypeValidationTest, GlobalOverrideNoInitializer_Pass) {}

TEST_F(ResolverTypeValidationTest, GlobalVariableWithAddressSpace_Pass) {}

TEST_F(ResolverTypeValidationTest, GlobalConstNoAddressSpace_Pass) {}

TEST_F(ResolverTypeValidationTest, GlobalVariableUnique_Pass) {}

TEST_F(ResolverTypeValidationTest, GlobalVariableFunctionVariableNotUnique_Pass) {}

TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierInnerScope_Pass) {}

TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierInnerScopeBlock_Pass) {}

TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierDifferentFunctions_Pass) {}

TEST_F(ResolverTypeValidationTest, ArraySize_AIntLiteral_Pass) {}

TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Pass) {}

TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Pass) {}

TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConst_Pass) {}

TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Pass) {}

TEST_F(ResolverTypeValidationTest, ArraySize_AIntLiteral_Zero) {}

TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Zero) {}

TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Zero) {}

TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Negative) {}

TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedConst_Zero) {}

TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Zero) {}

TEST_F(ResolverTypeValidationTest, ArraySize_SignedConst_Negative) {}

TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {}

TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) {}

TEST_F(ResolverTypeValidationTest, ArraySize_FloatConst) {}

TEST_F(ResolverTypeValidationTest, ArraySize_IVecConst) {}

TEST_F(ResolverTypeValidationTest, ArraySize_UnderElementCountLimit) {}

TEST_F(ResolverTypeValidationTest, ArraySize_OverElementCountLimit) {}

TEST_F(ResolverTypeValidationTest, ArraySize_StorageBufferLargeArray) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NestedStorageBufferLargeArray) {}

TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) {}

TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ExplicitStride) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_PrivateVar) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_InArray) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_InStruct) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_FunctionVar_Explicit) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_FunctionLet_Explicit) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_FunctionVar_Implicit) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_FunctionLet_Implicit) {}

TEST_F(ResolverTypeValidationTest, ArraySize_UnnamedOverride_Equivalence) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_Param) {}

TEST_F(ResolverTypeValidationTest, ArraySize_NamedOverride_ReturnType) {}

TEST_F(ResolverTypeValidationTest, ArraySize_Workgroup_Overridable) {}

TEST_F(ResolverTypeValidationTest, ArraySize_ModuleVar) {}

TEST_F(ResolverTypeValidationTest, ArraySize_FunctionConst) {}

TEST_F(ResolverTypeValidationTest, ArraySize_FunctionLet) {}

TEST_F(ResolverTypeValidationTest, ArraySize_ComplexExpr) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayInFunction_Fail) {}

TEST_F(ResolverTypeValidationTest, PtrType_ArrayIncomplete) {}

TEST_F(ResolverTypeValidationTest, Struct_Member_VectorIncomplete) {}

TEST_F(ResolverTypeValidationTest, Struct_Member_MatrixIncomplete) {}

TEST_F(ResolverTypeValidationTest, Struct_TooBig) {}

TEST_F(ResolverTypeValidationTest, Struct_MemberOffset_TooBig) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayIsLast_Pass) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayInArray) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayInStructInArray) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayInStructInStruct) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayIsNotLast_Fail) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayAsGlobalVariable) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayAsLocalVariable) {}

TEST_F(ResolverTypeValidationTest, RuntimeArrayAsParameter_Fail) {}

TEST_F(ResolverTypeValidationTest, PtrToPtr_Fail) {}

TEST_F(ResolverTypeValidationTest, PtrToRuntimeArrayAsPointerParameter_Fail) {}

TEST_F(ResolverTypeValidationTest, PtrToRuntimeArrayAsParameter_Fail) {}

TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsNotLast_Fail) {}

TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) {}

TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableType) {}

TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableTypeWithStride) {}

namespace GetCanonicalTests {
struct Params {};

template <typename T>
constexpr Params ParamsFor() {}

static constexpr Params cases[] =;

CanonicalTest;
TEST_P(CanonicalTest, All) {}
INSTANTIATE_TEST_SUITE_P();

}  // namespace GetCanonicalTests

namespace SampledTextureTests {

SampledTextureDimensionTest;
TEST_P(SampledTextureDimensionTest, All) {}
INSTANTIATE_TEST_SUITE_P();

MultisampledTextureDimensionTest;
TEST_P(MultisampledTextureDimensionTest, All) {}
INSTANTIATE_TEST_SUITE_P();

struct TypeParams {};

template <typename T>
constexpr TypeParams TypeParamsFor(bool is_valid) {}

static constexpr TypeParams type_cases[] =;

SampledTextureTypeTest;
TEST_P(SampledTextureTypeTest, All) {}
INSTANTIATE_TEST_SUITE_P();

MultisampledTextureTypeTest;
TEST_P(MultisampledTextureTypeTest, All) {}
INSTANTIATE_TEST_SUITE_P();

}  // namespace SampledTextureTests

namespace StorageTextureTests {
struct DimensionParams {};

static constexpr DimensionParams Dimension_cases[] =;

StorageTextureDimensionTest;
TEST_P(StorageTextureDimensionTest, All) {}
INSTANTIATE_TEST_SUITE_P();

struct FormatParams {};

static constexpr FormatParams format_cases[] =;

StorageTextureFormatTest;
TEST_P(StorageTextureFormatTest, All) {}
INSTANTIATE_TEST_SUITE_P();

StorageTextureAccessTest;

TEST_F(StorageTextureAccessTest, MissingTemplates) {}

TEST_F(StorageTextureAccessTest, MissingAccess_Fail) {}

TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {}

TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Pass) {}

TEST_F(StorageTextureAccessTest, ReadOnlyAccess_FeatureDisallowed) {}

TEST_F(StorageTextureAccessTest, RWAccess_Pass) {}

TEST_F(StorageTextureAccessTest, RWAccess_FeatureDisallowed) {}

}  // namespace StorageTextureTests

namespace MatrixTests {
struct Params {};

template <typename T>
constexpr Params ParamsFor(uint32_t columns, uint32_t rows) {}

ValidMatrixTypes;
TEST_P(ValidMatrixTypes, Okay) {}
INSTANTIATE_TEST_SUITE_P();

InvalidMatrixElementTypes;
TEST_P(InvalidMatrixElementTypes, InvalidElementType) {}
INSTANTIATE_TEST_SUITE_P();
}  // namespace MatrixTests

namespace VectorTests {
struct Params {};

template <typename T>
constexpr Params ParamsFor(uint32_t width) {}

ValidVectorTypes;
TEST_P(ValidVectorTypes, Okay) {}
INSTANTIATE_TEST_SUITE_P();

InvalidVectorElementTypes;
TEST_P(InvalidVectorElementTypes, InvalidElementType) {}
INSTANTIATE_TEST_SUITE_P();
}  // namespace VectorTests

namespace BuiltinTypeAliasTests {
struct Params {};

template <typename T>
constexpr Params Case(const char* alias) {}

BuiltinTypeAliasTest;
TEST_P(BuiltinTypeAliasTest, CheckEquivalent) {}
TEST_P(BuiltinTypeAliasTest, Construct) {}
INSTANTIATE_TEST_SUITE_P();

}  // namespace BuiltinTypeAliasTests

namespace TypeDoesNotTakeTemplateArgs {

ResolverUntemplatedTypeUsedWithTemplateArgs;

TEST_P(ResolverUntemplatedTypeUsedWithTemplateArgs, Builtin_UseWithTemplateArgs) {}

TEST_P(ResolverUntemplatedTypeUsedWithTemplateArgs, BuiltinAlias_UseWithTemplateArgs) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(ResolverUntemplatedTypeUsedWithTemplateArgs, Struct_Type) {}

TEST_F(ResolverUntemplatedTypeUsedWithTemplateArgs, Struct_Ctor) {}

TEST_F(ResolverUntemplatedTypeUsedWithTemplateArgs, AliasedArray_Type) {}

TEST_F(ResolverUntemplatedTypeUsedWithTemplateArgs, AliasedArray_Ctor) {}

}  // namespace TypeDoesNotTakeTemplateArgs

}  // namespace
}  // namespace tint::resolver