skia2/resources/sksl/errors/MismatchedNumbers.rts
John Stiles c5e6515e4a Rename ES2 error tests from 'H' through 'M' to .rts.
In a few cases, this involved splitting a test into two (an ES2-
compatible portion and a ES3+ portion).

Change-Id: Ie6f18f787cf7c10696a2841ff538bbe2b95bf50d
Bug: skia:13042
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/523187
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Commit-Queue: Arman Uguray <armansito@google.com>
2022-03-22 16:54:32 +00:00

65 lines
3.1 KiB
Plaintext

int i = 1;
float f = 1.0;
// SkSL allows `float op <int literal>` and `<int literal> op float`, unlike GLSL.
void f_eq_int_literal_ok() { f = 1; }
void f_plus_int_literal_ok() { f + 1; }
void f_minus_int_literal_ok() { f - 1; }
void f_mul_int_literal_ok() { f * 1; }
void f_div_int_literal_ok() { f / 1; }
void int_literal_plus_f_ok() { 1 + f; }
void int_literal_minus_f_ok() { 1 - f; }
void int_literal_mul_f_ok() { 1 * f; }
void int_literal_div_f_ok() { 1 / f; }
// Other than that, mixing scalar types without a cast is disallowed.
void i_eq_float_literal_disallowed() { i = 1.0; }
void i_eq_f_disallowed() { i = f; }
void f_eq_i_disallowed() { f = i; }
void i_plus_float_literal_disallowed() { i + 1.0; }
void i_minus_float_literal_disallowed() { i - 1.0; }
void i_mul_float_literal_disallowed() { i * 1.0; }
void i_div_float_literal_disallowed() { i / 1.0; }
void float_literal_plus_i_disallowed() { 1.0 + i; }
void float_literal_minus_i_disallowed() { 1.0 - i; }
void float_literal_mul_i_disallowed() { 1.0 * i; }
void float_literal_div_i_disallowed() { 1.0 / i; }
void i_plus_f_disallowed() { i + f; }
void i_minus_f_disallowed() { i - f; }
void i_mul_f_disallowed() { i * f; }
void i_div_f_disallowed() { i / f; }
void f_plus_i_disallowed() { f + i; }
void f_minus_i_disallowed() { f - i; }
void f_mul_i_disallowed() { f * i; }
void f_div_i_disallowed() { f / i; }
void f_plus_u_disallowed() { f + u; }
void f_minus_u_disallowed() { f - u; }
void f_mul_u_disallowed() { f * u; }
void f_div_u_disallowed() { f / u; }
void i_plus_u_disallowed() { i + u; }
void i_minus_u_disallowed() { i - u; }
void i_mul_u_disallowed() { i * u; }
void i_div_u_disallowed() { i / u; }
/*%%*
type mismatch: '=' cannot operate on 'int', 'float'
type mismatch: '=' cannot operate on 'int', 'float'
type mismatch: '=' cannot operate on 'float', 'int'
type mismatch: '+' cannot operate on 'int', 'float'
type mismatch: '-' cannot operate on 'int', 'float'
type mismatch: '*' cannot operate on 'int', 'float'
type mismatch: '/' cannot operate on 'int', 'float'
type mismatch: '+' cannot operate on 'float', 'int'
type mismatch: '-' cannot operate on 'float', 'int'
type mismatch: '*' cannot operate on 'float', 'int'
type mismatch: '/' cannot operate on 'float', 'int'
type mismatch: '+' cannot operate on 'int', 'float'
type mismatch: '-' cannot operate on 'int', 'float'
type mismatch: '*' cannot operate on 'int', 'float'
type mismatch: '/' cannot operate on 'int', 'float'
type mismatch: '+' cannot operate on 'float', 'int'
type mismatch: '-' cannot operate on 'float', 'int'
type mismatch: '*' cannot operate on 'float', 'int'
type mismatch: '/' cannot operate on 'float', 'int'
*%%*/