xref: /aosp_15_r20/external/skia/resources/sksl/folding/BoolFolding.rts (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorRed, colorGreen;
2
3bool test() {
4    bool a = 1 == 1 || 2 == 8;
5    bool b = 1 > 1  || 2 == 8;
6    bool c = 1 == 1 && 2 <= 8;
7    bool d = 1 == 2 && 2 == 8;
8    bool e = 1 == 1 ^^ 1 != 1;
9    bool f = 1 == 1 ^^ 1 == 1;
10    bool g = true == true;
11    bool h = false == true;
12    bool i = true == !false;
13    bool j = false == !false;
14
15    const bool TRUE = true;
16    const bool FALSE = false;
17    bool k = all(bool4(1 == 1, !false, 123 > 12, TRUE));       // all are true
18    bool l = all(bool3(TRUE, 1 == 2, true));                   // three out of four are true
19    bool m = any(bool4(true, 1 == 2, true, TRUE));             // three out of four are true
20    bool n = any(bool2(0 == 1, FALSE));                        // none are true
21    bool o = any(not(bool2(0 == 1, FALSE)));                   // all true
22    bool p = all(not(bool4(1 == 1, !false, 123 > 12, TRUE)));  // none are true
23
24    bool q = bool4(true) == bool4(true, true, true, true);
25    bool r = bool4(true) == bool4(true, false, true, true);
26    bool s = bool4(true, true, true, true) == bool4(true);
27    bool t = bool4(true, true, true, false) == bool4(true);
28
29    bool u = (!a == !a);
30    bool v = (!a != !a);
31
32    return a && !b && c && !d && e && !f && g && !h && i && !j && k && !l && m && !n && o && !p
33             && q && !r && s && !t && u && !v;
34}
35
36half4 main(float2 coords) {
37    return test() ? colorGreen : colorRed;
38}
39
40