// Copyright 2023 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/fluent_types.h"
#include "src/tint/lang/core/type/array.h"
#include "src/tint/lang/core/type/matrix.h"
#include "src/tint/lang/msl/writer/printer/helper_test.h"
#include "src/tint/utils/text/string.h"

using namespace tint::core::number_suffixes;  // NOLINT
using namespace tint::core::fluent_types;     // NOLINT

namespace tint::msl::writer {
namespace {

TEST_F(MslPrinterTest, Constant_Bool_True) {
    auto* c = b.Constant(true);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  bool const a = true;
}
)");
}

TEST_F(MslPrinterTest, Constant_Bool_False) {
    auto* c = b.Constant(false);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  bool const a = false;
}
)");
}

TEST_F(MslPrinterTest, Constant_i32) {
    auto* c = b.Constant(-12345_i);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  int const a = -12345;
}
)");
}

TEST_F(MslPrinterTest, Constant_u32) {
    auto* c = b.Constant(12345_u);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  uint const a = 12345u;
}
)");
}

TEST_F(MslPrinterTest, Constant_F32) {
    auto* c = b.Constant(f32((1 << 30) - 4));
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float const a = 1073741824.0f;
}
)");
}

TEST_F(MslPrinterTest, Constant_F16) {
    auto* c = b.Constant(f16((1 << 15) - 8));
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  half const a = 32752.0h;
}
)");
}

TEST_F(MslPrinterTest, Constant_Vector_Splat) {
    auto* c = b.Splat<vec3<f32>>(1.5_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float3 const a = float3(1.5f);
}
)");
}

TEST_F(MslPrinterTest, Constant_Vector_Composite) {
    auto* c = b.Composite<vec3<f32>>(1.5_f, 1.0_f, 1.5_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float3 const a = float3(1.5f, 1.0f, 1.5f);
}
)");
}

TEST_F(MslPrinterTest, Constant_Vector_Composite_AnyZero) {
    auto* c = b.Composite<vec3<f32>>(1.0_f, 0.0_f, 1.5_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float3 const a = float3(1.0f, 0.0f, 1.5f);
}
)");
}

TEST_F(MslPrinterTest, Constant_Vector_Composite_AllZero) {
    auto* c = b.Composite<vec3<f32>>(0.0_f, 0.0_f, 0.0_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float3 const a = float3(0.0f);
}
)");
}

TEST_F(MslPrinterTest, Constant_Matrix_Splat) {
    auto* c = b.Splat<mat3x2<f32>>(1.5_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float3x2 const a = float3x2(1.5f, 1.5f, 1.5f);
}
)");
}

TEST_F(MslPrinterTest, Constant_Matrix_Composite) {
    auto* c = b.Composite<mat3x2<f32>>(        //
        b.Composite<vec2<f32>>(1.5_f, 1.0_f),  //
        b.Composite<vec2<f32>>(1.5_f, 2.0_f),  //
        b.Composite<vec2<f32>>(2.5_f, 3.5_f));
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float3x2 const a = float3x2(float2(1.5f, 1.0f), float2(1.5f, 2.0f), float2(2.5f, 3.5f));
}
)");
}

TEST_F(MslPrinterTest, Constant_Matrix_Composite_AnyZero) {
    auto* c = b.Composite<mat2x2<f32>>(        //
        b.Composite<vec2<f32>>(1.0_f, 0.0_f),  //
        b.Composite<vec2<f32>>(1.5_f, 2.5_f));
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float2x2 const a = float2x2(float2(1.0f, 0.0f), float2(1.5f, 2.5f));
}
)");
}

TEST_F(MslPrinterTest, Constant_Matrix_Composite_AllZero) {
    auto* c = b.Composite<mat3x2<f32>>(        //
        b.Composite<vec2<f32>>(0.0_f, 0.0_f),  //
        b.Composite<vec2<f32>>(0.0_f, 0.0_f),  //
        b.Composite<vec2<f32>>(0.0_f, 0.0_f));
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(
void foo() {
  float3x2 const a = float3x2(float2(0.0f), float2(0.0f), float2(0.0f));
}
)");
}

TEST_F(MslPrinterTest, Constant_Array_Splat) {
    auto* c = b.Splat<array<f32, 3>>(1.5_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + MetalArray() + R"(
void foo() {
  tint_array<float, 3> const a = tint_array<float, 3>{1.5f, 1.5f, 1.5f};
}
)");
}

TEST_F(MslPrinterTest, Constant_Array_Composite) {
    auto* c = b.Composite<array<f32, 3>>(1.5_f, 1.0_f, 2.0_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + MetalArray() + R"(
void foo() {
  tint_array<float, 3> const a = tint_array<float, 3>{1.5f, 1.0f, 2.0f};
}
)");
}

TEST_F(MslPrinterTest, Constant_Array_Composite_AnyZero) {
    auto* c = b.Composite<array<f32, 2>>(1.0_f, 0.0_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + MetalArray() + R"(
void foo() {
  tint_array<float, 2> const a = tint_array<float, 2>{1.0f, 0.0f};
}
)");
}

TEST_F(MslPrinterTest, Constant_Array_Composite_AllZero) {
    auto* c = b.Composite<array<f32, 3>>(0.0_f, 0.0_f, 0.0_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + MetalArray() + R"(
void foo() {
  tint_array<float, 3> const a = tint_array<float, 3>{};
}
)");
}

TEST_F(MslPrinterTest, Constant_Struct_Splat) {
    auto* s = ty.Struct(mod.symbols.New("S"), {
                                                  {mod.symbols.Register("a"), ty.f32()},
                                                  {mod.symbols.Register("b"), ty.f32()},
                                              });
    auto* c = b.Splat(s, 1.5_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(struct S {
  float a;
  float b;
};

void foo() {
  S const a = S{.a=1.5f, .b=1.5f};
}
)");
}

TEST_F(MslPrinterTest, Constant_Struct_Composite) {
    auto* s = ty.Struct(mod.symbols.New("S"), {
                                                  {mod.symbols.Register("a"), ty.f32()},
                                                  {mod.symbols.Register("b"), ty.f32()},
                                              });
    auto* c = b.Composite(s, 1.5_f, 1.0_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(struct S {
  float a;
  float b;
};

void foo() {
  S const a = S{.a=1.5f, .b=1.0f};
}
)");
}

TEST_F(MslPrinterTest, Constant_Struct_Composite_AnyZero) {
    auto* s = ty.Struct(mod.symbols.New("S"), {
                                                  {mod.symbols.Register("a"), ty.f32()},
                                                  {mod.symbols.Register("b"), ty.f32()},
                                              });
    auto* c = b.Composite(s, 1.0_f, 0.0_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(struct S {
  float a;
  float b;
};

void foo() {
  S const a = S{.a=1.0f, .b=0.0f};
}
)");
}

TEST_F(MslPrinterTest, Constant_Struct_Composite_AllZero) {
    auto* s = ty.Struct(mod.symbols.New("S"), {
                                                  {mod.symbols.Register("a"), ty.f32()},
                                                  {mod.symbols.Register("b"), ty.f32()},
                                              });
    auto* c = b.Composite(s, 0.0_f, 0.0_f);
    auto* func = b.Function("foo", ty.void_());
    b.Append(func->Block(), [&] {
        b.Let("a", c);
        b.Return(func);
    });

    ASSERT_TRUE(Generate()) << err_ << output_;
    EXPECT_EQ(output_, MetalHeader() + R"(struct S {
  float a;
  float b;
};

void foo() {
  S const a = S{};
}
)");
}

}  // namespace
}  // namespace tint::msl::writer
