skia2/resources/sksl/folding/FloatFolding.sksl
John Stiles bfc9be0f77 Migrate SkSL test inputs to the resources/ directory.
This will allow us to load these inputs for unit testing in `dm`.

Change-Id: Id256ba7c30d3ec94b98048e47af44cf9efe580d5
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357282
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-22 18:57:29 +00:00

77 lines
1.9 KiB
Plaintext

bool test() {
bool ok = true;
half x = 32.0 + 2.0;
ok = ok && (x == 34);
x = 32.0 - 2.0;
ok = ok && (x == 30);
x = 32.0 * 2.0;
ok = ok && (x == 64);
x = 32.0 / 2.0;
ok = ok && (x == 16);
x = (12 > 2.0) ? (10 * 2 / 5 + 18 - 3) : 0;
ok = ok && (x == 19);
x = 0.0 == 0.0 ? 1 : -1;
ok = ok && (x == 1);
x = 0.0 == 1.0 ? 2 : -2;
ok = ok && (x == -2);
x = 0.0 != 1.0 ? 3 : -3;
ok = ok && (x == 3);
x = 0.0 != 0.0 ? 4 : -4;
ok = ok && (x == -4);
x = 6.0 > 5.0 ? 5 : -5;
ok = ok && (x == 5);
x = 6.0 > 6.0 ? 6 : -6;
ok = ok && (x == -6);
x = 6.0 >= 6.0 ? 7 : -7;
ok = ok && (x == 7);
x = 6.0 >= 7.0 ? 8 : -8;
ok = ok && (x == -8);
x = 5.0 < 6.0 ? 9 : -9;
ok = ok && (x == 9);
x = 6.0 < 6.0 ? 10 : -10;
ok = ok && (x == -10);
x = 6.0 <= 6.0 ? 11 : -11;
ok = ok && (x == 11);
x = 6.0 <= 5.0 ? 12 : -12;
ok = ok && (x == -12);
x = half(sqrt(1) + 0);
ok = ok && (x == sqrt(1));
x = half(0 + sqrt(2));
ok = ok && (x == sqrt(2));
x = half(sqrt(3) - 0);
ok = ok && (x == sqrt(3));
x = half(sqrt(4) * 0);
ok = ok && (x == 0);
x = half(sqrt(5) * 1);
ok = ok && (x == sqrt(5));
x = half(1 * sqrt(6));
ok = ok && (x == sqrt(6));
x = half(0 * sqrt(7));
ok = ok && (x == 0);
x = half(sqrt(8) / 1);
ok = ok && (x == sqrt(8));
x = half(0 / sqrt(9));
ok = ok && (x == 0);
x += 1; // TODO(skia:11192): constant propagation for `+=` style operators
ok = ok && (x == 1);
x += 0;
ok = ok && (x == 1);
x -= 2;
ok = ok && (x == -1);
x -= 0;
ok = ok && (x == -1);
x *= 1;
ok = ok && (x == -1);
x *= 2;
ok = ok && (x == -2);
x /= 1;
ok = ok && (x == -2);
x /= 2;
ok = ok && (x == -1);
return ok;
}
half4 main() {
return test() ? half4(0,1,0,1) : half4(1,0,0,1);
}