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

Make Clojure API Generator Tests Less Brittle #15579

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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