chromium/third_party/dawn/src/tint/lang/wgsl/resolver/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/wgsl/resolver/resolver.h"

#include "gmock/gmock.h"
#include "src/tint/lang/core/builtin_value.h"
#include "src/tint/lang/core/type/sampled_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/wgsl/ast/assignment_statement.h"
#include "src/tint/lang/wgsl/ast/break_statement.h"
#include "src/tint/lang/wgsl/ast/builtin_texture_helper_test.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/continue_statement.h"
#include "src/tint/lang/wgsl/ast/discard_statement.h"
#include "src/tint/lang/wgsl/ast/if_statement.h"
#include "src/tint/lang/wgsl/ast/loop_statement.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/switch_statement.h"
#include "src/tint/lang/wgsl/ast/unary_op_expression.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "src/tint/lang/wgsl/resolver/resolve.h"
#include "src/tint/lang/wgsl/resolver/resolver_helper_test.h"
#include "src/tint/lang/wgsl/sem/call.h"
#include "src/tint/lang/wgsl/sem/function.h"
#include "src/tint/lang/wgsl/sem/member_accessor_expression.h"
#include "src/tint/lang/wgsl/sem/statement.h"
#include "src/tint/lang/wgsl/sem/variable.h"

namespace tint::resolver {
namespace {

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

ResolverValidationTest;
ResolverValidationDeathTest;

class FakeStmt final : public Castable<FakeStmt, ast::Statement> {};

class FakeExpr final : public Castable<FakeExpr, ast::Expression> {};

TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInVertexStage) {}

TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInFragmentStage) {}

TEST_F(ResolverValidationTest, RWStorageBufferUsedInVertexStage) {}

TEST_F(ResolverValidationTest, RWStorageTextureUsedInVertexStage) {}

TEST_F(ResolverValidationDeathTest, UnhandledStmt) {}

TEST_F(ResolverValidationTest, Stmt_If_NonBool) {}

TEST_F(ResolverValidationTest, Stmt_ElseIf_NonBool) {}

TEST_F(ResolverValidationDeathTest, Expr_ErrUnknownExprType) {}

TEST_F(ResolverValidationTest, UsingUndefinedVariable_Fail) {}

TEST_F(ResolverValidationTest, UsingUndefinedVariableInBlockStatement_Fail) {}

TEST_F(ResolverValidationTest, UsingUndefinedVariableGlobalVariable_Pass) {}

TEST_F(ResolverValidationTest, UsingUndefinedVariableInnerScope_Fail) {}

TEST_F(ResolverValidationTest, UsingUndefinedVariableOuterScope_Pass) {}

TEST_F(ResolverValidationTest, UsingUndefinedVariableDifferentScope_Fail) {}

TEST_F(ResolverValidationTest, AddressSpace_FunctionVariableWorkgroupClass) {}

TEST_F(ResolverValidationTest, AddressSpace_FunctionVariableI32) {}

TEST_F(ResolverValidationTest, AddressSpace_SamplerExplicitAddressSpace) {}

TEST_F(ResolverValidationTest, AddressSpace_TextureExplicitAddressSpace) {}

TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadChar) {}

TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_MixedChars) {}

TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadLength) {}

TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadIndex) {}

TEST_F(ResolverValidationTest, Expr_MemberAccessor_BadParent) {}

TEST_F(ResolverValidationTest, Expr_MemberAccessor_FuncGoodParent) {}

TEST_F(ResolverValidationTest, Expr_MemberAccessor_FuncBadParent) {}

TEST_F(ResolverValidationTest,
       Stmt_Loop_ContinueInLoopBodyBeforeDeclAndAfterDecl_UsageInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInContinuing_InBlocks) {}

TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInLoopBodySubscopeBeforeDecl_UsageInContinuing) {}

TEST_F(ResolverValidationTest,
       Stmt_Loop_ContinueInLoopBodySubscopeBeforeDecl_UsageInContinuingSubscope) {}

TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInLoopBodySubscopeBeforeDecl_UsageOutsideBlock) {}

TEST_F(ResolverValidationTest,
       Stmt_Loop_ContinueInLoopBodySubscopeBeforeDecl_UsageInContinuingLoop) {}

TEST_F(ResolverValidationTest,
       Stmt_Loop_ContinueInLoopBodyBeforeDecl_UsageInNestedContinuingInBody) {}

TEST_F(ResolverValidationTest,
       Stmt_Loop_ContinueInLoopBodyBeforeDecl_UsageInNestedContinuingInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInNestedLoopBodyBeforeDecl_UsageInContinuing) {}

TEST_F(ResolverValidationTest,
       Stmt_Loop_ContinueInNestedLoopBodyBeforeDecl_UsageInContinuingSubscope) {}

TEST_F(ResolverValidationTest, Stmt_Loop_ContinueInNestedLoopBodyBeforeDecl_UsageInContinuingLoop) {}

TEST_F(ResolverTest, Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInContinuing) {}

TEST_F(ResolverTest, Stmt_Loop_ReturnInContinuing_Direct) {}

TEST_F(ResolverTest, Stmt_Loop_ReturnInContinuing_Indirect) {}

TEST_F(ResolverTest, Stmt_Loop_DiscardInContinuing_Direct) {}

TEST_F(ResolverTest, Stmt_Loop_ContinueInContinuing_Direct) {}

TEST_F(ResolverTest, Stmt_Loop_ContinueInContinuing_Indirect) {}

TEST_F(ResolverValidationTest, Stmt_Loop_Continuing_BreakIf) {}

TEST_F(ResolverValidationTest, Stmt_Loop_Continuing_BreakIf_Not_Last) {}

TEST_F(ResolverValidationTest, Stmt_Loop_Continuing_BreakIf_Duplicate) {}

TEST_F(ResolverValidationTest, Stmt_Loop_Continuing_BreakIf_NonBool) {}

TEST_F(ResolverTest, Stmt_ForLoop_ReturnInContinuing_Direct) {}

TEST_F(ResolverTest, Stmt_ForLoop_ReturnInContinuing_Indirect) {}

TEST_F(ResolverTest, Stmt_ForLoop_DiscardInContinuing_Direct) {}

TEST_F(ResolverTest, Stmt_ForLoop_ContinueInContinuing_Direct) {}

TEST_F(ResolverTest, Stmt_ForLoop_ContinueInContinuing_Indirect) {}

TEST_F(ResolverTest, Stmt_ForLoop_CondIsBoolRef) {}

TEST_F(ResolverTest, Stmt_ForLoop_CondIsNotBool) {}

TEST_F(ResolverTest, Stmt_While_CondIsBoolRef) {}

TEST_F(ResolverTest, Stmt_While_CondIsNotBool) {}

TEST_F(ResolverValidationTest, Stmt_ContinueInLoop) {}

TEST_F(ResolverValidationTest, Stmt_ContinueNotInLoop) {}

TEST_F(ResolverValidationTest, Stmt_BreakInLoop) {}

TEST_F(ResolverValidationTest, Stmt_BreakInSwitch) {}

TEST_F(ResolverValidationTest, Stmt_BreakInSwitchInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfTrueInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfElseInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfInIfInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfTrueMultipleStmtsInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfElseMultipleStmtsInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfElseIfInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfNonEmptyElseInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfElseNonEmptyTrueInContinuing) {}

TEST_F(ResolverValidationTest, Stmt_BreakInIfInContinuingNotLast) {}

TEST_F(ResolverValidationTest, Stmt_BreakNotInLoopOrSwitch) {}

TEST_F(ResolverValidationTest, StructMemberDuplicateName) {}
TEST_F(ResolverValidationTest, StructMemberDuplicateNameDifferentTypes) {}
TEST_F(ResolverValidationTest, StructMemberDuplicateNamePass) {}

TEST_F(ResolverValidationTest, NegativeStructMemberAlignAttribute) {}

TEST_F(ResolverValidationTest, NonPOTStructMemberAlignAttribute) {}

TEST_F(ResolverValidationTest, ZeroStructMemberAlignAttribute) {}

TEST_F(ResolverValidationTest, ZeroStructMemberSizeAttribute) {}

TEST_F(ResolverValidationTest, OffsetAndSizeAttribute) {}

TEST_F(ResolverValidationTest, OffsetAndAlignAttribute) {}

TEST_F(ResolverValidationTest, OffsetAndAlignAndSizeAttribute) {}

TEST_F(ResolverTest, Expr_Initializer_Cast_Pointer) {}

TEST_F(ResolverTest, I32_Overflow) {}

TEST_F(ResolverTest, I32_Underflow) {}

TEST_F(ResolverTest, U32_Overflow) {}

TEST_F(ResolverValidationTest, ShiftLeft_I32_PartialEval_Valid) {}

TEST_F(ResolverValidationTest, ShiftLeft_I32_PartialEval_Invalid) {}

TEST_F(ResolverValidationTest, ShiftRight_U32_PartialEval_Invalid) {}

TEST_F(ResolverValidationTest, ShiftLeft_VecI32_PartialEval_Valid) {}

TEST_F(ResolverValidationTest, ShiftLeft_VecI32_PartialEval_Invalid) {}

TEST_F(ResolverValidationTest, ShiftLeft_I32_CompoundAssign_Valid) {}

TEST_F(ResolverValidationTest, ShiftLeft_I32_CompoundAssign_Invalid) {}

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

TINT_INSTANTIATE_TYPEINFO();
TINT_INSTANTIATE_TYPEINFO();