// 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/helpers/append_vector.h" #include "src/tint/lang/wgsl/ast/helper_test.h" #include "src/tint/lang/wgsl/program/program_builder.h" #include "src/tint/lang/wgsl/resolver/resolver.h" #include "src/tint/lang/wgsl/sem/value_constructor.h" #include "gmock/gmock.h" namespace tint::wgsl { namespace { usingnamespacetint::core::fluent_types; // NOLINT usingnamespacetint::core::number_suffixes; // NOLINT class AppendVectorTest : public ::testing::Test, public ProgramBuilder { … }; // AppendVector(vec2<i32>(1, 2), 3) -> vec3<i32>(1, 2, 3) TEST_F(AppendVectorTest, Vec2i32_i32) { … } // AppendVector(vec2<i32>(1, 2), 3u) -> vec3<i32>(1, 2, i32(3u)) TEST_F(AppendVectorTest, Vec2i32_u32) { … } // AppendVector(vec2<i32>(vec2<u32>(1u, 2u)), 3u) -> // vec3<i32>(vec2<i32>(vec2<u32>(1u, 2u)), i32(3u)) TEST_F(AppendVectorTest, Vec2i32FromVec2u32_u32) { … } // AppendVector(vec2<i32>(1, 2), 3.0f) -> vec3<i32>(1, 2, i32(3.0f)) TEST_F(AppendVectorTest, Vec2i32_f32) { … } // AppendVector(vec3<i32>(1, 2, 3), 4) -> vec4<i32>(1, 2, 3, 4) TEST_F(AppendVectorTest, Vec3i32_i32) { … } // AppendVector(vec_12, 3) -> vec3<i32>(vec_12, 3) TEST_F(AppendVectorTest, Vec2i32Var_i32) { … } // AppendVector(1, 2, scalar_3) -> vec3<i32>(1, 2, scalar_3) TEST_F(AppendVectorTest, Vec2i32_i32Var) { … } // AppendVector(vec_12, scalar_3) -> vec3<i32>(vec_12, scalar_3) TEST_F(AppendVectorTest, Vec2i32Var_i32Var) { … } // AppendVector(vec_12, scalar_3) -> vec3<i32>(vec_12, i32(scalar_3)) TEST_F(AppendVectorTest, Vec2i32Var_f32Var) { … } // AppendVector(vec_12, scalar_3) -> vec3<bool>(vec_12, scalar_3) TEST_F(AppendVectorTest, Vec2boolVar_boolVar) { … } // AppendVector(vec3<i32>(), 4) -> vec3<bool>(0, 0, 0, 4) TEST_F(AppendVectorTest, ZeroVec3i32_i32) { … } } // namespace } // namespace tint::wgsl