Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/compiler_tests/PruneEmptyDeclarations_test.cpp
1693 views
1
//
2
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
// PruneEmptyDeclarations_test.cpp:
7
// Tests for pruning empty declarations.
8
//
9
10
#include "GLSLANG/ShaderLang.h"
11
#include "angle_gl.h"
12
#include "gtest/gtest.h"
13
#include "tests/test_utils/compiler_test.h"
14
15
using namespace sh;
16
17
namespace
18
{
19
20
class PruneEmptyDeclarationsTest : public MatchOutputCodeTest
21
{
22
public:
23
PruneEmptyDeclarationsTest()
24
: MatchOutputCodeTest(GL_VERTEX_SHADER, 0, SH_GLSL_COMPATIBILITY_OUTPUT)
25
{}
26
};
27
28
TEST_F(PruneEmptyDeclarationsTest, EmptyDeclarationStartsDeclaratorList)
29
{
30
const std::string shaderString =
31
"precision mediump float;\n"
32
"uniform float u;\n"
33
"void main()\n"
34
"{\n"
35
" float, f;\n"
36
" gl_Position = vec4(u * f);\n"
37
"}\n";
38
compile(shaderString);
39
ASSERT_TRUE(foundInCode("float _uf"));
40
ASSERT_TRUE(notFoundInCode("float, _uf"));
41
ASSERT_TRUE(notFoundInCode("float, f"));
42
ASSERT_TRUE(notFoundInCode("float _u, _uf"));
43
}
44
45
TEST_F(PruneEmptyDeclarationsTest, EmptyStructDeclarationWithQualifiers)
46
{
47
const std::string shaderString =
48
"precision mediump float;\n"
49
"const struct S { float f; };\n"
50
"uniform S s;"
51
"void main()\n"
52
"{\n"
53
" gl_Position = vec4(s.f);\n"
54
"}\n";
55
compile(shaderString);
56
ASSERT_TRUE(foundInCode("struct _uS"));
57
ASSERT_TRUE(foundInCode("uniform _uS"));
58
ASSERT_TRUE(notFoundInCode("const struct _uS"));
59
}
60
61
} // namespace
62
63