// 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/writer/glsl/test_helper.h"

namespace tint {
namespace writer {
namespace glsl {
namespace {

using GlslGeneratorImplTest = TestHelper;

TEST_F(GlslGeneratorImplTest, Generate) {
  Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{},
       ast::DecorationList{});

  GeneratorImpl& gen = Build();

  ASSERT_TRUE(gen.Generate()) << gen.error();
  EXPECT_EQ(gen.result(), R"(#version 310 es
precision mediump float;

void my_func() {
}

)");
}

struct GlslBuiltinData {
  ast::Builtin builtin;
  const char* attribute_name;
};
inline std::ostream& operator<<(std::ostream& out, GlslBuiltinData data) {
  out << data.builtin;
  return out;
}
using GlslBuiltinConversionTest = TestParamHelper<GlslBuiltinData>;
TEST_P(GlslBuiltinConversionTest, Emit) {
  auto params = GetParam();
  GeneratorImpl& gen = Build();

  EXPECT_EQ(gen.builtin_to_string(params.builtin, ast::PipelineStage::kVertex),
            std::string(params.attribute_name));
}
INSTANTIATE_TEST_SUITE_P(
    GlslGeneratorImplTest,
    GlslBuiltinConversionTest,
    testing::Values(
        GlslBuiltinData{ast::Builtin::kPosition, "gl_Position"},
        GlslBuiltinData{ast::Builtin::kVertexIndex, "gl_VertexID"},
        GlslBuiltinData{ast::Builtin::kInstanceIndex, "gl_InstanceID"},
        GlslBuiltinData{ast::Builtin::kFrontFacing, "gl_FrontFacing"},
        GlslBuiltinData{ast::Builtin::kFragDepth, "gl_FragDepth"},
        GlslBuiltinData{ast::Builtin::kLocalInvocationId,
                        "gl_LocalInvocationID"},
        GlslBuiltinData{ast::Builtin::kLocalInvocationIndex,
                        "gl_LocalInvocationIndex"},
        GlslBuiltinData{ast::Builtin::kGlobalInvocationId,
                        "gl_GlobalInvocationID"},
        GlslBuiltinData{ast::Builtin::kWorkgroupId, "gl_WorkGroupID"},
        GlslBuiltinData{ast::Builtin::kSampleIndex, "gl_SampleID"},
        GlslBuiltinData{ast::Builtin::kSampleMask, "gl_SampleMask"}));

}  // namespace
}  // namespace glsl
}  // namespace writer
}  // namespace tint
