Update int/float mismatch test to include uints.
Change-Id: I47d02ca63ce64d9cfb3de0888d84b2b8a822f2b5 Bug: skia:11164 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/353710 Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
4ea46b71ac
commit
ff4f76352d
@ -103,7 +103,6 @@ sksl_error_tests = [
|
||||
"$_tests/sksl/errors/ForTypeMismatch.sksl",
|
||||
"$_tests/sksl/errors/GenericArgumentMismatch.sksl",
|
||||
"$_tests/sksl/errors/IfTypeMismatch.sksl",
|
||||
"$_tests/sksl/errors/IntFloatMismatch.sksl",
|
||||
"$_tests/sksl/errors/InVarWithInitializerExpression.sksl",
|
||||
"$_tests/sksl/errors/InterfaceBlockScope.sksl",
|
||||
"$_tests/sksl/errors/InterfaceBlockStorageModifiers.sksl",
|
||||
@ -112,6 +111,7 @@ sksl_error_tests = [
|
||||
"$_tests/sksl/errors/InvalidOutParams.sksl",
|
||||
"$_tests/sksl/errors/InvalidToken.sksl",
|
||||
"$_tests/sksl/errors/InvalidUnary.sksl",
|
||||
"$_tests/sksl/errors/MismatchedNumbers.sksl",
|
||||
"$_tests/sksl/errors/ModifiersInStruct.sksl",
|
||||
"$_tests/sksl/errors/OpaqueTypeAssignment.sksl",
|
||||
"$_tests/sksl/errors/OpaqueTypeConstruction.sksl",
|
||||
|
@ -1,34 +0,0 @@
|
||||
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 int literals, type mixing requires a cast.
|
||||
void i_eq_float_literal_disallowed() { i = 1.0; }
|
||||
void i_eq_f_disallowed() { i = f; }
|
||||
float 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; }
|
75
tests/sksl/errors/MismatchedNumbers.sksl
Normal file
75
tests/sksl/errors/MismatchedNumbers.sksl
Normal file
@ -0,0 +1,75 @@
|
||||
int i = 1;
|
||||
uint u = 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; }
|
||||
|
||||
// SkSL also allows `uint op <int literal>` and `<int literal> op uint` without the `u` suffix.
|
||||
void u_eq_int_literal_ok() { u = 1; }
|
||||
void u_plus_int_literal_ok() { u + 1; }
|
||||
void u_minus_int_literal_ok() { u - 1; }
|
||||
void u_mul_int_literal_ok() { u * 1; }
|
||||
void u_div_int_literal_ok() { u / 1; }
|
||||
void int_literal_plus_u_ok() { 1 + u; }
|
||||
void int_literal_minus_u_ok() { 1 - u; }
|
||||
void int_literal_mul_u_ok() { 1 * u; }
|
||||
void int_literal_div_u_ok() { 1 / u; }
|
||||
|
||||
// Other than that, mixing scalar types without a cast is disallowed.
|
||||
void i_eq_float_literal_disallowed() { i = 1.0; }
|
||||
void u_eq_float_literal_disallowed() { u = 1.0; }
|
||||
void i_eq_u_disallowed() { i = u; }
|
||||
void i_eq_f_disallowed() { i = f; }
|
||||
float f_eq_i_disallowed() { f = i; }
|
||||
float f_eq_i_disallowed() { f = u; }
|
||||
void u_eq_i_disallowed() { u = i; }
|
||||
void u_eq_f_disallowed() { u = f; }
|
||||
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 u_plus_float_literal_disallowed() { u + 1.0; }
|
||||
void u_minus_float_literal_disallowed() { u - 1.0; }
|
||||
void u_mul_float_literal_disallowed() { u * 1.0; }
|
||||
void u_div_float_literal_disallowed() { u / 1.0; }
|
||||
void float_literal_plus_u_disallowed() { 1.0 + u; }
|
||||
void float_literal_minus_u_disallowed() { 1.0 - u; }
|
||||
void float_literal_mul_u_disallowed() { 1.0 * u; }
|
||||
void float_literal_div_u_disallowed() { 1.0 / u; }
|
||||
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 u_plus_f_disallowed() { u + f; }
|
||||
void u_minus_f_disallowed() { u - f; }
|
||||
void u_mul_f_disallowed() { u * f; }
|
||||
void u_div_f_disallowed() { u / f; }
|
||||
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; }
|
||||
void u_plus_i_disallowed() { u + i; }
|
||||
void u_minus_i_disallowed() { u - i; }
|
||||
void u_mul_i_disallowed() { u * i; }
|
||||
void u_div_i_disallowed() { u / i; }
|
@ -1,22 +0,0 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 16: type mismatch: '=' cannot operate on 'int', 'float'
|
||||
error: 17: type mismatch: '=' cannot operate on 'int', 'float'
|
||||
error: 18: type mismatch: '=' cannot operate on 'float', 'int'
|
||||
error: 19: type mismatch: '+' cannot operate on 'int', 'float'
|
||||
error: 20: type mismatch: '-' cannot operate on 'int', 'float'
|
||||
error: 21: type mismatch: '*' cannot operate on 'int', 'float'
|
||||
error: 22: type mismatch: '/' cannot operate on 'int', 'float'
|
||||
error: 23: type mismatch: '+' cannot operate on 'float', 'int'
|
||||
error: 24: type mismatch: '-' cannot operate on 'float', 'int'
|
||||
error: 25: type mismatch: '*' cannot operate on 'float', 'int'
|
||||
error: 26: type mismatch: '/' cannot operate on 'float', 'int'
|
||||
error: 27: type mismatch: '+' cannot operate on 'int', 'float'
|
||||
error: 28: type mismatch: '-' cannot operate on 'int', 'float'
|
||||
error: 29: type mismatch: '*' cannot operate on 'int', 'float'
|
||||
error: 30: type mismatch: '/' cannot operate on 'int', 'float'
|
||||
error: 31: type mismatch: '+' cannot operate on 'float', 'int'
|
||||
error: 32: type mismatch: '-' cannot operate on 'float', 'int'
|
||||
error: 33: type mismatch: '*' cannot operate on 'float', 'int'
|
||||
error: 34: type mismatch: '/' cannot operate on 'float', 'int'
|
||||
19 errors
|
42
tests/sksl/errors/golden/MismatchedNumbers.glsl
Normal file
42
tests/sksl/errors/golden/MismatchedNumbers.glsl
Normal file
@ -0,0 +1,42 @@
|
||||
### Compilation failed:
|
||||
|
||||
error: 28: type mismatch: '=' cannot operate on 'int', 'float'
|
||||
error: 29: type mismatch: '=' cannot operate on 'uint', 'float'
|
||||
error: 31: type mismatch: '=' cannot operate on 'int', 'float'
|
||||
error: 32: type mismatch: '=' cannot operate on 'float', 'int'
|
||||
error: 33: type mismatch: '=' cannot operate on 'float', 'uint'
|
||||
error: 34: type mismatch: '=' cannot operate on 'uint', 'int'
|
||||
error: 35: type mismatch: '=' cannot operate on 'uint', 'float'
|
||||
error: 36: type mismatch: '+' cannot operate on 'int', 'float'
|
||||
error: 37: type mismatch: '-' cannot operate on 'int', 'float'
|
||||
error: 38: type mismatch: '*' cannot operate on 'int', 'float'
|
||||
error: 39: type mismatch: '/' cannot operate on 'int', 'float'
|
||||
error: 40: type mismatch: '+' cannot operate on 'float', 'int'
|
||||
error: 41: type mismatch: '-' cannot operate on 'float', 'int'
|
||||
error: 42: type mismatch: '*' cannot operate on 'float', 'int'
|
||||
error: 43: type mismatch: '/' cannot operate on 'float', 'int'
|
||||
error: 44: type mismatch: '+' cannot operate on 'uint', 'float'
|
||||
error: 45: type mismatch: '-' cannot operate on 'uint', 'float'
|
||||
error: 46: type mismatch: '*' cannot operate on 'uint', 'float'
|
||||
error: 47: type mismatch: '/' cannot operate on 'uint', 'float'
|
||||
error: 48: type mismatch: '+' cannot operate on 'float', 'uint'
|
||||
error: 49: type mismatch: '-' cannot operate on 'float', 'uint'
|
||||
error: 50: type mismatch: '*' cannot operate on 'float', 'uint'
|
||||
error: 51: type mismatch: '/' cannot operate on 'float', 'uint'
|
||||
error: 52: type mismatch: '+' cannot operate on 'int', 'float'
|
||||
error: 53: type mismatch: '-' cannot operate on 'int', 'float'
|
||||
error: 54: type mismatch: '*' cannot operate on 'int', 'float'
|
||||
error: 55: type mismatch: '/' cannot operate on 'int', 'float'
|
||||
error: 56: type mismatch: '+' cannot operate on 'float', 'int'
|
||||
error: 57: type mismatch: '-' cannot operate on 'float', 'int'
|
||||
error: 58: type mismatch: '*' cannot operate on 'float', 'int'
|
||||
error: 59: type mismatch: '/' cannot operate on 'float', 'int'
|
||||
error: 60: type mismatch: '+' cannot operate on 'uint', 'float'
|
||||
error: 61: type mismatch: '-' cannot operate on 'uint', 'float'
|
||||
error: 62: type mismatch: '*' cannot operate on 'uint', 'float'
|
||||
error: 63: type mismatch: '/' cannot operate on 'uint', 'float'
|
||||
error: 64: type mismatch: '+' cannot operate on 'float', 'uint'
|
||||
error: 65: type mismatch: '-' cannot operate on 'float', 'uint'
|
||||
error: 66: type mismatch: '*' cannot operate on 'float', 'uint'
|
||||
error: 67: type mismatch: '/' cannot operate on 'float', 'uint'
|
||||
39 errors
|
Loading…
Reference in New Issue
Block a user