xref: /aosp_15_r20/external/skia/resources/sksl/runtime/SwitchWithLoops.rts (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorGreen, colorRed;
2
3bool switch_with_break_in_loop(int x) {
4    int val = 0;
5    switch (x) {
6        case 1:  for (int i=0; i<10; ++i) { ++val; break; ++val; }
7        default: ++val;
8    }
9    return val == 2;
10}
11
12bool switch_with_continue_in_loop(int x) {
13    int val = 0;
14    switch (x) {
15        case 1:  for (int i=0; i<10; ++i) { ++val; continue; ++val; }
16        default: ++val;
17    }
18    return val == 11;
19}
20
21bool loop_with_break_in_switch(int x) {
22    int val = 0;
23    for (int i=0; i<10; ++i) {
24        switch (x) {
25            case 1:  ++val; break;
26            default: return false;
27        }
28        ++val;
29    }
30    return val == 20;
31}
32
33half4 main(float2 coords) {
34    int x = int(colorGreen.g);
35    return (switch_with_break_in_loop(x) &&
36            switch_with_continue_in_loop(x) &&
37            loop_with_break_in_switch(x)) ? colorGreen : colorRed;
38}
39