Fixed error reporting on invalid SkSL assignments
Change-Id: I9859081a14b110731f943e09fdd94dc10e0c9dfc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/353580
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/tests/SkSLDSLTest.cpp b/tests/SkSLDSLTest.cpp
index d4b0057..4fdd9b6 100644
--- a/tests/SkSLDSLTest.cpp
+++ b/tests/SkSLDSLTest.cpp
@@ -345,10 +345,7 @@
}
{
- // This isn't an ideal error message - it should be about 1.0 not being assignable - but
- // currently determine_binary_type is kicking out $floatLiteral += float, and it gets
- // reported like this.
- ExpectError error(r, "error: type mismatch: '+=' cannot operate on 'float', 'float'\n");
+ ExpectError error(r, "error: cannot assign to this expression\n");
(1.0 += a).release();
}
}
@@ -377,6 +374,11 @@
ExpectError error(r, "error: type mismatch: '-=' cannot operate on 'int', 'bool2'\n");
(a -= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1.0 -= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLMultiply, r, ctxInfo) {
@@ -403,6 +405,11 @@
ExpectError error(r, "error: type mismatch: '*=' cannot operate on 'float', 'bool2'\n");
(a *= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1.0 *= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLDivide, r, ctxInfo) {
@@ -432,6 +439,11 @@
ExpectError error(r, "error: type mismatch: '/=' cannot operate on 'float', 'bool2'\n");
(a /= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1.0 /= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLMod, r, ctxInfo) {
@@ -458,6 +470,11 @@
ExpectError error(r, "error: type mismatch: '%=' cannot operate on 'int', 'bool2'\n");
(a %= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1 %= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLShl, r, ctxInfo) {
@@ -484,6 +501,11 @@
ExpectError error(r, "error: type mismatch: '<<=' cannot operate on 'int', 'bool2'\n");
(a <<= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1 <<= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLShr, r, ctxInfo) {
@@ -510,6 +532,11 @@
ExpectError error(r, "error: type mismatch: '>>=' cannot operate on 'int', 'bool2'\n");
(a >>= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1 >>= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLBitwiseAnd, r, ctxInfo) {
@@ -536,6 +563,11 @@
ExpectError error(r, "error: type mismatch: '&=' cannot operate on 'int', 'bool2'\n");
(a &= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1 &= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLBitwiseOr, r, ctxInfo) {
@@ -562,6 +594,11 @@
ExpectError error(r, "error: type mismatch: '|=' cannot operate on 'int', 'bool2'\n");
(a |= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1 |= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLBitwiseXor, r, ctxInfo) {
@@ -588,6 +625,11 @@
ExpectError error(r, "error: type mismatch: '^=' cannot operate on 'int', 'bool2'\n");
(a ^= Bool2(true)).release();
}
+
+ {
+ ExpectError error(r, "error: cannot assign to this expression\n");
+ (1 ^= a).release();
+ }
}
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLLogicalAnd, r, ctxInfo) {