skia2/resources/sksl/errors/BadConstInitializers.rts
John Stiles 0d226afee9 Rename ES2 error tests starting with 'B' to .rts.
A few tests received minor tweaks to make them Runtime Effect-friendly.

Change-Id: Icbcedb84b7882e42f21425b2d40d7819705c359e
Bug: skia:13042
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/522918
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-03-21 16:49:17 +00:00

33 lines
1.4 KiB
Plaintext

uniform float u;
const float c = 1;
float f = 1;
struct S { float f; } s;
// Valid constant-expression initializers. Should not produce errors:
void from_literal() { const float x = 0; }
void from_const_global() { const float x = c; }
void from_const_local() { const float x = 0; const float y = x; }
void from_const_constructor() { const int i = int(c); }
void from_expression() { const float x = 2 * c; }
// Invalid constant-expression initializers. Should all produce errors:
void from_uniform() { const float x = u; }
void from_parameter(float p) { const float x = p; }
void from_const_parameter(const float p) { const float x = p; }
void from_non_const_local() { float x = u; const float y = x; }
void from_non_const_expression() { const float x = u + u; }
void from_mixed_expression() { const float x = c + u; }
void from_non_const_struct_field() { const float x = s.f; }
/*%%*
'const' variable initializer must be a constant expression
'const' variable initializer must be a constant expression
'const' variable initializer must be a constant expression
'const' variable initializer must be a constant expression
'const' variable initializer must be a constant expression
'const' variable initializer must be a constant expression
'const' variable initializer must be a constant expression
*%%*/