summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/glsl/preprocessor/comments.html
blob: 0e3dfb3e32e76669b394b913469677f8230b7cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!--
Copyright (c) 2020 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Comments</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<script src="../../../js/js-test-pre.js"></script>
<script src="../../../js/webgl-test-utils.js"></script>
<script src="../../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description();

// Your syntax highlighter may hate this file.
// Because this stuff is tricky, we collect all tests here, including duplicating from other tests.
// That way, this test file is a one-stop-shop for validation testing.

const nonAscii = [
  65533,
  65533,
  65533,
  65533,
  834,
  96,
  65533,
  114,
  65533,
  98,
  65533,
  104,
  65533,
  104,
  65533,
  322,
  834,
  514,
  65533,
  65533,
  322,
  65533,
  65533,
  66,
].map(x => String.fromCodePoint(x)).join('');

GLSLConformanceTester.runTests([{
    vShaderSource: `void main() {}`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'Normal minimal testcase'
  }, {
    vShaderSource: `void main() {}/*`,
    vShaderSuccess: false,
    linkSuccess: false,
    passMsg: 'Missing block-comment-end'
  }, {
    vShaderSource: `void main() {}/**`,
    vShaderSuccess: false,
    linkSuccess: false,
    passMsg: 'Partial block-comment-end'
  }, {
    vShaderSource: `void main() {}/**/`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'Complete block-comment-end'
  }, {
    vShaderSource: `void main() {}/* **/`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'Complete block-comment-end with **/'
  }, {
    vShaderSource: `void main() {}/`,
    vShaderSuccess: false,
    linkSuccess: false,
    passMsg: 'Partial line-comment-begin at EOF'
  }, {
    vShaderSource: `void main() {}//`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'Complete line-comment-begin at EOF'
  }, {
    vShaderSource: `//
void main() {}`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: `Minimal line comment: "//,\\n"`
  }, {
    vShaderSource: `//\

void main() {}`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: `Minimal continued line comment: "//,\\,\\n,\\n"`
  }, {
    vShaderSource: `//\
a
void main() {}`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: `Line-comment continuation with content that must be skipped: "//,\\,\\n,a,\\n"`
  }, {
    vShaderSource: `void main() {} // The quick brown fox jumped\\over the lazy dog`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'Backslash in comment'
  }, {
    vShaderSource: `void main() {} // The quick brown fox jumped\\over the lazy dog
`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'Backslash in comment with newline before EOF'
  }, {
    vShaderSource: `void main() {} // The quick brown fox jumped\\
over the lazy dog`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'Line-comment with backslash-line-continuation'
  }, {
    vShaderSource: `void main() {} // The quick brown fox jumped\\
over the lazy dog
`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'Line-comment with backslash-line-continuation with newline before EOF'
  }, {
    vShaderSource: `void main() {}//${String.fromCodePoint(0x8f)}`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'upper-ascii in line-comment'
  }, {
    vShaderSource: `void main() {}/*${String.fromCodePoint(0x8f)}*/`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'upper-ascii in block-comment'

    // -
    // Like comment_frag.frag from conformance/ogles/GL/build/build_049_to_056.html
  }, {
    vShaderSource: `
void main()
{
    /******  // comment not closed
}`,
    vShaderSuccess: false,
    linkSuccess: false,
    passMsg: 'Unclosed block-comment containing line-comment'


    // -
    // Like conformance/glsl/misc/non-ascii-comments.vert.html
  }, {
    vShaderSource: `void main() {}/*${String.fromCodePoint(0x8f)}`,
    vShaderSuccess: false,
    linkSuccess: false,
    passMsg: 'upper-ascii in unterminated block-comment'
  }, {
    vShaderSource: `void main() {}// ${nonAscii}`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'More non-ascii in line-comment'
  }, {
    vShaderSource: `void main() {}/*
     * ${nonAscii}
     */`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: 'More non-ascii in block-comment'
  }, {
    vShaderSource: `void main() {}/*
     * ${nonAscii}
     *`,
    vShaderSuccess: false,
    linkSuccess: false,
    passMsg: 'More non-ascii in unterminated block-comment'


    // -
    // Like deqp/data/gles2/shaders/preprocessor.html | preprocessor.comments.comment_trick_2_*
  }, {
    vShaderSource: `void main() {
        float out0;
        /**/
        out0 = 1.0;
        /*/
        out0 = 0.0;
        /**/
      }`,
    vShaderSuccess: true,
    linkSuccess: true,
    passMsg: '/**/ /*/ /**/'
}]);
</script>
</body>
</html>