chromium/third_party/dawn/src/tint/lang/wgsl/resolver/value_constructor_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 "gmock/gmock.h"
#include "src/tint/lang/core/type/reference.h"
#include "src/tint/lang/wgsl/resolver/resolver_helper_test.h"
#include "src/tint/lang/wgsl/sem/array.h"
#include "src/tint/lang/wgsl/sem/value_constructor.h"
#include "src/tint/lang/wgsl/sem/value_conversion.h"
#include "src/tint/utils/text/string_stream.h"

namespace tint::resolver {
namespace {

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

HasSubstr;

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

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

namespace InferTypeTest {
struct Params {};

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

TEST_F(ResolverValueConstructorValidationTest, InferTypeTest_Simple) {}

InferTypeTest_FromConstructorExpression;
TEST_P(InferTypeTest_FromConstructorExpression, All) {}

static constexpr Params from_constructor_expression_cases[] =;
INSTANTIATE_TEST_SUITE_P();

InferTypeTest_FromArithmeticExpression;
TEST_P(InferTypeTest_FromArithmeticExpression, All) {}
static constexpr Params from_arithmetic_expression_cases[] =;
INSTANTIATE_TEST_SUITE_P();

InferTypeTest_FromCallExpression;
TEST_P(InferTypeTest_FromCallExpression, All) {}
static constexpr Params from_call_expression_cases[] =;
INSTANTIATE_TEST_SUITE_P();

}  // namespace InferTypeTest

namespace ConversionConstructTest {
enum class Kind {};

struct Params {};

template <typename LhsType, typename RhsType>
constexpr Params ParamsFor(Kind kind) {}

static constexpr Params valid_cases[] =;

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

constexpr CreatePtrs all_types[] =;

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

TEST_F(ResolverValueConstructorValidationTest, ConversionConstructorInvalid_TooManyConstructors) {}

TEST_F(ResolverValueConstructorValidationTest, ConversionConstructorInvalid_InvalidConstructor) {}

}  // namespace ConversionConstructTest

namespace ArrayConstructor {

TEST_F(ResolverValueConstructorValidationTest, Array_ZeroValue_Pass) {}

TEST_F(ResolverValueConstructorValidationTest, Array_U32U32U32) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArray_U32U32U32) {}

TEST_F(ResolverValueConstructorValidationTest, Array_U32AIU32) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArray_U32AIU32) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayU32_AIAIAI) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArray_AIAIAI) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayU32_VecI32_VecAI) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayU32_VecAI_VecF32) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_U32F32) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_U32F32) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_F32I32) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_F32I32) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_U32I32) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_U32I32) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_I32Vec2) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_I32Vec2) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_Vec3i32_Vec3u32) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3u32) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3AF) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayArgumentTypeMismatch_Vec3i32_Vec3bool) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayArgumentTypeMismatch_Vec3i32_Vec3bool) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayOfArray_SubElemSizeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayOfArray_SubElemSizeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, ArrayOfArray_SubElemTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, InferredArrayOfArray_SubElemTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Array_TooFewElements) {}

TEST_F(ResolverValueConstructorValidationTest, Array_TooManyElements) {}

TEST_F(ResolverValueConstructorValidationTest, Array_Runtime) {}

TEST_F(ResolverValueConstructorValidationTest, Array_RuntimeZeroValue) {}

}  // namespace ArrayConstructor

namespace ScalarConstructor {

TEST_F(ResolverValueConstructorValidationTest, I32_Success) {}

TEST_F(ResolverValueConstructorValidationTest, U32_Success) {}

TEST_F(ResolverValueConstructorValidationTest, F32_Success) {}

TEST_F(ResolverValueConstructorValidationTest, F16_Success) {}

TEST_F(ResolverValueConstructorValidationTest, Convert_f32_to_i32_Success) {}

TEST_F(ResolverValueConstructorValidationTest, Convert_i32_to_u32_Success) {}

TEST_F(ResolverValueConstructorValidationTest, Convert_u32_to_f16_Success) {}

TEST_F(ResolverValueConstructorValidationTest, Convert_f16_to_f32_Success) {}

}  // namespace ScalarConstructor

namespace VectorConstructor {

TEST_F(ResolverValueConstructorValidationTest, Vec2F32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2F16_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2U32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2I32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2Bool_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_Vec3ArgumentCardinalityTooLarge) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_Vec4ArgumentCardinalityTooLarge) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_TooManyArgumentsScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_TooManyArgumentsVector) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_TooManyArgumentsVectorAndScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Error_InvalidArgumentType) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Success_ZeroValue) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2F32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2F16_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2U32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2I32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2Bool_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Success_Identity) {}

TEST_F(ResolverValueConstructorValidationTest, Vec2_Success_Vec2TypeConversion) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3F32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3F16_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3U32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3I32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3Bool_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_Vec4ArgumentCardinalityTooLarge) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooFewArgumentsScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooManyArgumentsScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooFewArgumentsVec2) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooManyArgumentsVec2) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooManyArgumentsVec2AndScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_TooManyArgumentsVec3) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Error_InvalidArgumentType) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_ZeroValue) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3F32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3F16_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3U32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3I32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3Bool_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_Vec2AndScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_ScalarAndVec2) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_Identity) {}

TEST_F(ResolverValueConstructorValidationTest, Vec3_Success_Vec3TypeConversion) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4F32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4F16_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4U32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4I32_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4Bool_Error_ScalarArgumentTypeMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooFewArgumentsScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooFewArgumentsVec2AndScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec2AndScalars) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec2Vec2Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec2Vec2Vec2) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooFewArgumentsVec3) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec3AndScalars) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec3AndVec2) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec2AndVec3) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_TooManyArgumentsVec3AndVec3) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Error_InvalidArgumentType) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_ZeroValue) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4F32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4F16_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4U32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4I32_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4Bool_Success_Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Vec2ScalarScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_ScalarVec2Scalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_ScalarScalarVec2) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Vec2AndVec2) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Vec3AndScalar) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_ScalarAndVec3) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Identity) {}

TEST_F(ResolverValueConstructorValidationTest, Vec4_Success_Vec4TypeConversion) {}

TEST_F(ResolverValueConstructorValidationTest, NestedVectorConstructors_InnerError) {}

TEST_F(ResolverValueConstructorValidationTest, NestedVectorConstructors_Success) {}

TEST_F(ResolverValueConstructorValidationTest, Vector_Alias_Argument_Error) {}

TEST_F(ResolverValueConstructorValidationTest, Vector_Alias_Argument_Success) {}

TEST_F(ResolverValueConstructorValidationTest, Vector_ElementTypeAlias_Error) {}

TEST_F(ResolverValueConstructorValidationTest, Vector_ElementTypeAlias_Success) {}

TEST_F(ResolverValueConstructorValidationTest, Vector_ArgumentElementTypeAlias_Error) {}

TEST_F(ResolverValueConstructorValidationTest, Vector_ArgumentElementTypeAlias_Success) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec2ElementTypeFromScalars) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec2ElementTypeFromVec2) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec3ElementTypeFromScalars) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec3ElementTypeFromVec3) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec3ElementTypeFromScalarAndVec2) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec4ElementTypeFromScalars) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec4ElementTypeFromVec4) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec4ElementTypeFromScalarAndVec3) {}

TEST_F(ResolverValueConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec2) {}

TEST_F(ResolverValueConstructorValidationTest, InferVecNoArgs) {}

TEST_F(ResolverValueConstructorValidationTest, CannotInferVec2ElementTypeFromScalarsMismatch) {}

TEST_F(ResolverValueConstructorValidationTest, CannotInferVec3ElementTypeFromScalarsMismatch) {}

TEST_F(ResolverValueConstructorValidationTest,
       CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) {}

TEST_F(ResolverValueConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) {}

TEST_F(ResolverValueConstructorValidationTest,
       CannotInferVec4ElementTypeFromScalarAndVec3Mismatch) {}

TEST_F(ResolverValueConstructorValidationTest, CannotInferVec4ElementTypeFromVec2AndVec2Mismatch) {}

}  // namespace VectorConstructor

namespace MatrixConstructor {

struct MatrixParams {};

template <typename T, uint32_t R, uint32_t C>
constexpr MatrixParams MatrixParamsFor() {}

static std::string MatrixStr(const MatrixParams& param) {}

MatrixConstructorTest;

TEST_P(MatrixConstructorTest, ColumnConstructor_Error_TooFewArguments) {}

TEST_P(MatrixConstructorTest, ElementConstructor_Error_TooFewArguments) {}

TEST_P(MatrixConstructorTest, ColumnConstructor_Error_TooManyArguments) {}

TEST_P(MatrixConstructorTest, ElementConstructor_Error_TooManyArguments) {}

TEST_P(MatrixConstructorTest, ColumnConstructor_Error_InvalidArgumentType) {}

TEST_P(MatrixConstructorTest, ElementConstructor_Error_InvalidArgumentType) {}

TEST_P(MatrixConstructorTest, ColumnConstructor_Error_TooFewRowsInVectorArgument) {}

TEST_P(MatrixConstructorTest, ColumnConstructor_Error_TooManyRowsInVectorArgument) {}

TEST_P(MatrixConstructorTest, ZeroValue_Success) {}

TEST_P(MatrixConstructorTest, WithColumns_Success) {}

TEST_P(MatrixConstructorTest, WithElements_Success) {}

TEST_P(MatrixConstructorTest, ElementTypeAlias_Error) {}

TEST_P(MatrixConstructorTest, ElementTypeAlias_Success) {}

TEST_F(ResolverValueConstructorValidationTest, MatrixConstructor_ArgumentTypeAlias_Error) {}

TEST_P(MatrixConstructorTest, ArgumentTypeAlias_Success) {}

TEST_P(MatrixConstructorTest, ArgumentElementTypeAlias_Error) {}

TEST_P(MatrixConstructorTest, ArgumentElementTypeAlias_Success) {}

TEST_P(MatrixConstructorTest, InferElementTypeFromVectors) {}

TEST_P(MatrixConstructorTest, InferElementTypeFromScalars) {}

TEST_P(MatrixConstructorTest, CannotInferElementTypeFromVectors_Mismatch) {}

TEST_P(MatrixConstructorTest, CannotInferElementTypeFromScalars_Mismatch) {}

INSTANTIATE_TEST_SUITE_P();
}  // namespace MatrixConstructor

namespace StructConstructor {
CreatePtrs;
CreatePtrsFor;

constexpr CreatePtrs all_types[] =;

auto number_of_members =;

StructConstructorInputsTest;  // number of struct members
TEST_P(StructConstructorInputsTest, TooFew) {}

TEST_P(StructConstructorInputsTest, TooMany) {}

INSTANTIATE_TEST_SUITE_P();
StructConstructorTypeTest;  // number of struct members
TEST_P(StructConstructorTypeTest, AllTypes) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(ResolverValueConstructorValidationTest, Struct_Nested) {}

TEST_F(ResolverValueConstructorValidationTest, Struct) {}

TEST_F(ResolverValueConstructorValidationTest, Struct_Empty) {}
}  // namespace StructConstructor

TEST_F(ResolverValueConstructorValidationTest, NonConstructibleType_Atomic) {}

TEST_F(ResolverValueConstructorValidationTest, NonConstructibleType_AtomicArray) {}

TEST_F(ResolverValueConstructorValidationTest, NonConstructibleType_AtomicStructMember) {}

TEST_F(ResolverValueConstructorValidationTest, NonConstructibleType_Sampler) {}

TEST_F(ResolverValueConstructorValidationTest, BuilinTypeConstructorAsStatement) {}

TEST_F(ResolverValueConstructorValidationTest, StructConstructorAsStatement) {}

TEST_F(ResolverValueConstructorValidationTest, AliasConstructorAsStatement) {}

TEST_F(ResolverValueConstructorValidationTest, BuilinTypeConversionAsStatement) {}

TEST_F(ResolverValueConstructorValidationTest, AliasConversionAsStatement) {}

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