skia2/resources/sksl/shared/ForLoopMultipleInit.sksl
John Stiles c5d860877e Add unit test for for-loop with multiple variables.
We lacked test coverage for this case, and this was broken when compound
VarDeclarations were split from one Statement into several.

Change-Id: I561b4d8acc0bfa01161d873a0c022ec58e316903
Bug: skia:11860
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396817
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-04-14 20:23:35 +00:00

25 lines
570 B
Plaintext

half4 main() {
half4 result = half4(0);
// Two variables, both used
for (half a = 0, b = 0; a < 10 && b < 10; ++a, ++b) {
result.r += a;
result.g += b;
}
// Two variables, one dead
for (int c = 0, d = 0; c < 10; ++c) {
result.b += 1;
}
// Three variables, all used, some array-typed
for (float d[2] = float[2](0, 10), e[4] = float[4](1,2,3,4), f = 9; d[0] < d[1]; ++d[0]) {
result.a = half(e[0] * f);
}
// Four variables, all dead
for (half4 x, y, z, w;; ) break;
return result;
}