skia2/resources/sksl/shared/WhileLoopControlFlow.sksl
John Stiles 7add07f88d Add unit test for control statements in while loops.
Change-Id: I924ac75b5f8a397f7af7a06925ef0c9deba5c509
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359141
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-01-26 17:07:36 +00:00

20 lines
402 B
Plaintext

half4 main() {
half4 x = half4(1, 1, 1, 1);
// Verify that break is allowed in a while loop.
while (x.a == 1) {
x.r -= 0.25;
if (x.r <= 0) break;
}
// Verify that continue is allowed in a while loop.
while (x.b > 0) {
x.b -= 0.25;
if (x.a == 1) continue; // should always happen
x.g = 0;
}
// x contains green.
return x;
}