-
-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathglsl.spec.js
57 lines (43 loc) · 2.01 KB
/
glsl.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import * as MathBox from "../../src";
const { GLSL } = MathBox.Util;
describe("util.glsl", function () {
it("swizzles vec4", function () {
let code = GLSL.swizzleVec4([4, 3, 2, 1]);
expect(code).toContain("vec4(xyzw.w, xyzw.z, xyzw.y, xyzw.x)");
code = GLSL.swizzleVec4([4, 0, 2, 1]);
expect(code).toContain("vec4(xyzw.w, 0.0, xyzw.y, xyzw.x)");
code = GLSL.swizzleVec4([2, 4, 3], 4);
expect(code).toContain("vec4(xyzw.y, xyzw.w, xyzw.z, 0.0)");
code = GLSL.swizzleVec4([2, 4, 3]);
expect(code).toContain("vec3(xyzw.y, xyzw.w, xyzw.z)");
code = GLSL.swizzleVec4("yxwz");
expect(code).toContain("vec4(xyzw.y, xyzw.x, xyzw.w, xyzw.z)");
code = GLSL.swizzleVec4("y0wz");
expect(code).toContain("vec4(xyzw.y, 0.0, xyzw.w, xyzw.z)");
code = GLSL.swizzleVec4("ywz", 4);
expect(code).toContain("vec4(xyzw.y, xyzw.w, xyzw.z, 0.0)");
code = GLSL.swizzleVec4("ywz");
return expect(code).toContain("vec3(xyzw.y, xyzw.w, xyzw.z)");
});
return it("invert swizzles vec4", function () {
let code = GLSL.invertSwizzleVec4([2, 3, 4, 1]);
expect(code).toContain("vec4(xyzw.w, xyzw.x, xyzw.y, xyzw.z)");
code = GLSL.invertSwizzleVec4([2, 3, 4, 0]);
expect(code).toContain("vec4(0.0, xyzw.x, xyzw.y, xyzw.z)");
code = GLSL.invertSwizzleVec4([2, 3, 4], 4);
expect(code).toContain("vec4(0.0, xyzw.x, xyzw.y, xyzw.z)");
code = GLSL.invertSwizzleVec4("yzwx");
expect(code).toContain("vec4(xyzw.w, xyzw.x, xyzw.y, xyzw.z)");
code = GLSL.invertSwizzleVec4("yzw0");
expect(code).toContain("vec4(0.0, xyzw.x, xyzw.y, xyzw.z)");
code = GLSL.invertSwizzleVec4("yzw");
return expect(code).toContain("vec4(0.0, xyzw.x, xyzw.y, xyzw.z)");
});
});