// Copyright 2021 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/resolver/resolver.h" #include "gmock/gmock.h" #include "src/ast/call_statement.h" #include "src/resolver/resolver_test_helper.h" namespace tint { namespace resolver { namespace { // Helpers and typedefs template using DataType = builder::DataType; template using vec = builder::vec; template using vec2 = builder::vec2; template using vec3 = builder::vec3; template using vec4 = builder::vec4; template using mat = builder::mat; template using mat2x2 = builder::mat2x2; template using mat2x3 = builder::mat2x3; template using mat3x2 = builder::mat3x2; template using mat3x3 = builder::mat3x3; template using mat4x4 = builder::mat4x4; template using alias = builder::alias; template using alias1 = builder::alias1; template using alias2 = builder::alias2; template using alias3 = builder::alias3; using f32 = builder::f32; using i32 = builder::i32; using u32 = builder::u32; using ResolverCallTest = ResolverTest; struct Params { builder::ast_expr_func_ptr create_value; builder::ast_type_func_ptr create_type; }; template constexpr Params ParamsFor() { return Params{DataType::Expr, DataType::AST}; } static constexpr Params all_param_types[] = { ParamsFor(), // ParamsFor(), // ParamsFor(), // ParamsFor(), // ParamsFor>(), // ParamsFor>(), // ParamsFor>(), // ParamsFor>(), // ParamsFor>(), // ParamsFor>(), // ParamsFor>() // }; TEST_F(ResolverCallTest, Valid) { ast::VariableList params; ast::ExpressionList args; for (auto& p : all_param_types) { params.push_back(Param(Sym(), p.create_type(*this))); args.push_back(p.create_value(*this, 0)); } Func("foo", std::move(params), ty.f32(), {Return(1.23f)}); auto* call = Call("foo", std::move(args)); WrapInFunction(call); EXPECT_TRUE(r()->Resolve()) << r()->error(); } } // namespace } // namespace resolver } // namespace tint