Add unit test for control statements in do-while loop.

Change-Id: I8309940f8e40d0e84847ae272830896d010c39de
Bug: skia:11219
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359138
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>
This commit is contained in:
John Stiles 2021-01-26 10:37:41 -05:00
parent 04a1b4b971
commit 798021ada3
5 changed files with 32 additions and 0 deletions

View File

@ -302,6 +302,7 @@ sksl_shared_tests = [
"/sksl/shared/DependentInitializers.sksl",
"/sksl/shared/DerivativesUnused.sksl",
"/sksl/shared/Discard.sksl",
"/sksl/shared/DoWhileControlFlow.sksl",
"/sksl/shared/Enum.sksl",
"/sksl/shared/FragCoordsFlipY.sksl",
"/sksl/shared/FragCoordsNew.sksl",

View File

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

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 7: break statement must be inside a loop or switch
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 7: break statement must be inside a loop or switch
1 error

View File

@ -0,0 +1,4 @@
### Compilation failed:
error: 7: break statement must be inside a loop or switch
1 error