Skip to content

Files

84 lines (70 loc) · 2.13 KB

core.org

File metadata and controls

84 lines (70 loc) · 2.13 KB

thi.ng.glsl.test.core

(def dummy-minified
  "
<<dummy-minified>>")

(deftest test-dep-graph
  (let [a (glsl-spec nil "(a)")
        b (glsl-spec [a] "(b)")
        c (glsl-spec [a] "(c)")
        d1 (glsl-spec [b] "(d1)")
        d2 (glsl-spec [b c] "(d2)")]
    (is (= "(a)(b)(d1)(x)" (glsl/assemble (glsl-spec [d1] "(x)"))))
    (is (= "(a)(c)(b)(d2)(x)" (glsl/assemble (glsl-spec [d2] "(x)"))))))

(deftest test-file-spec
  (let [spec (glsl-file-spec '[a] "dev-resources/test/dummy.glsl")]
    (is (= {:deps '[a] :src dummy-minified} spec))))

(defn- make-test-spec
  [src] (->> src (glsl/minify) (glsl/glsl-spec-plain nil) (glsl/assemble)))

(deftest test-spec-plain
  (let [src "void main() {}"]
    (is (= "void main(){}" (make-test-spec src)))))

Namespace declaration

(ns thi.ng.glsl.test.core
  (:require
   [thi.ng.glsl.core :as glsl :refer-macros [glsl-spec glsl-file-spec]]
   [thi.ng.glsl.buffers]
   [thi.ng.glsl.color]
   [thi.ng.glsl.distancefields]
   [thi.ng.glsl.fog]
   [thi.ng.glsl.grid]
   [thi.ng.glsl.lighting]
   [thi.ng.glsl.matrix]
   [thi.ng.glsl.noise]
   [thi.ng.glsl.vertex]
   [cemerick.cljs.test :refer-macros [is deftest with-test testing]]))

<<tests>>

Test resources

// dummy test shader
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp int;
precision highp float;
#else
precision mediump int;
precision mediump float;
#endif
void main() {
  #ifdef FOO
  gl_FragColor = vec4(1.0, 2.0 ,  3.0  ,4.0  );
  #endif
}

// end shader

Dummy shader (minified)

#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp int;precision highp float;
#else
precision mediump int;precision mediump float;
#endif
void main(){
#ifdef FOO
gl_FragColor=vec4(1.0,2.0,3.0,4.0);
#endif
}