Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
make clojure api generator tests less brittle (#15579)
Browse files Browse the repository at this point in the history
  • Loading branch information
gigasquid authored and reminisce committed Jul 18, 2019
1 parent 35b5480 commit 9983adb
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions contrib/clojure-package/test/dev/generator_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@

(ns dev.generator-test
(:require [clojure.test :refer :all]
[dev.generator :as gen]))
[dev.generator :as gen]
[clojure.string :as string]))

(defn file-function-name [f]
(->> (string/split (slurp f) #"\n")
(take 33)
last
(string/trim)))

(deftest test-clojure-case
(is (= "foo-bar" (gen/clojure-case "FooBar")))
Expand Down Expand Up @@ -334,20 +341,20 @@
fns (gen/all-symbol-api-functions gen/op-names)
_ (gen/write-to-file [(first fns) (second fns)]
(gen/symbol-api-gen-ns false)
fname)
good-contents (slurp "test/good-test-symbol-api.clj")
contents (slurp fname)]
(is (= good-contents contents))))
fname)]
(is (= "activation"
(file-function-name "test/good-test-symbol-api.clj")
(file-function-name fname)))))

(testing "symbol-random-api"
(let [fname "test/test-symbol-random-api.clj"
fns (gen/all-symbol-random-api-functions gen/op-names)
_ (gen/write-to-file [(first fns) (second fns)]
(gen/symbol-api-gen-ns true)
fname)
good-contents (slurp "test/good-test-symbol-random-api.clj")
contents (slurp fname)]
(is (= good-contents contents))))
fname)]
(is (= "exponential"
(file-function-name "test/good-test-symbol-random-api.clj")
(file-function-name fname)))))


(testing "symbol"
Expand All @@ -364,20 +371,20 @@
fns (gen/all-ndarray-api-functions gen/op-names)
_ (gen/write-to-file [(first fns) (second fns)]
(gen/ndarray-api-gen-ns false)
fname)
good-contents (slurp "test/good-test-ndarray-api.clj")
contents (slurp fname)]
(is (= good-contents contents))))
fname)]
(is (= "activation"
(file-function-name "test/good-test-ndarray-api.clj")
(file-function-name fname)))))

(testing "ndarray-random-api"
(let [fname "test/test-ndarray-random-api.clj"
fns (gen/all-ndarray-random-api-functions gen/op-names)
_ (gen/write-to-file [(first fns) (second fns)]
(gen/ndarray-api-gen-ns true)
fname)
good-contents (slurp "test/good-test-ndarray-random-api.clj")
contents (slurp fname)]
(is (= good-contents contents))))
fname)]
(is (= "exponential"
(file-function-name "test/good-test-ndarray-random-api.clj")
(file-function-name fname)))))

(testing "ndarray"
(let [fname "test/test-ndarray.clj"
Expand Down

0 comments on commit 9983adb

Please sign in to comment.