Skip to content

Commit

Permalink
Merge 6c7abd2 into d1e2434
Browse files Browse the repository at this point in the history
  • Loading branch information
f-f committed Nov 9, 2018
2 parents d1e2434 + 6c7abd2 commit 520b72b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 44 deletions.
2 changes: 1 addition & 1 deletion dhall-lang
Submodule dhall-lang updated 688 files
33 changes: 18 additions & 15 deletions test/dhall_clj/beta_normalize_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@

;; Haskell implementation test suite

(def test-folder "dhall-haskell/tests/normalization")
(def test-folder "dhall-lang/tests/normalization/success")

(def problematic
"Here we list all the tests that blow up, so we categorize and exclude them.
Note: they are vectors because the path creation is platform-sensitive."
[
;; Waiting on issue #23
["dhall-lang" "tests" "normalization" "success" "haskell-tutorial" "access" "1"]
;; Waiting for single quote strings to be standardized
["dhall-haskell" "tests" "normalization" "remoteSystems"]])
["dhall-lang" "tests" "normalization" "success" "remoteSystems"]])


(defn valid-testcases []
Expand All @@ -72,16 +74,17 @@
(apply dissoc all))))

(deftest normalization-suite
(doseq [[testcase {:keys [actual expected]}] (valid-testcases)]
(let [parent (fs/parent testcase)
f #(fs/with-mutable-cwd
(fs/chdir parent)
(-> %
parse
expr
(resolve-imports (s/new))
beta-normalize))]
(println "TESTCASE" testcase)
(testing testcase
(is (= (f actual)
(f expected)))))))
(let [import-cache (s/new)]
(doseq [[testcase {:keys [actual expected]}] (valid-testcases)]
(let [parent (fs/parent testcase)
f #(fs/with-mutable-cwd
(fs/chdir parent)
(-> %
parse
expr
(resolve-imports import-cache)
beta-normalize))]
(println "TESTCASE" testcase)
(testing testcase
(is (= (f actual)
(f expected))))))))
76 changes: 48 additions & 28 deletions test/dhall_clj/typecheck_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[dhall-clj.typecheck :refer [typecheck]]
[dhall-clj.state :as s]
[dhall-clj.test-utils :refer :all]
[me.raynes.fs :as fs]))
[me.raynes.fs :as fs]
[clojure.java.io :as io]))


;; Simple regression tests
Expand All @@ -29,34 +30,53 @@

;; Haskell implementation test suite

(def test-folder "dhall-haskell/tests/typecheck")
(def test-folder "dhall-lang/tests/typecheck")

(def problematic
"Here we list all the tests that blow up, so we categorize and exclude them.
Note: they are vectors because the path creation is platform-sensitive."
[
;; Waiting on issue #23
["dhall-lang" "tests" "typecheck" "success" "simple" "access" "1"]
;; Waiting on issue #17
["dhall-lang" "tests" "typecheck" "success" "simple" "kindParameter"]
["dhall-lang" "tests" "typecheck" "success" "simple" "fieldsAreTypes"]])


(defn valid-testcases []
(let [all (success-testcases test-folder)]
(->> problematic
(map #(->> % (apply io/file) str))
(apply dissoc all))))

(deftest typecheck-success-suite
(doseq [[testcase {:keys [actual expected]}] (success-testcases test-folder)]
(let [parent (fs/parent testcase)
run (fn []
(fs/with-mutable-cwd
(fs/chdir parent)
(-> (->Annot
(-> actual parse expr)
(-> expected parse expr))
(resolve-imports (s/new))
(typecheck {})))
nil)]
(println "TESTCASE" testcase)
(testing testcase
(is (= nil (run)))))))
(let [import-cache (s/new)]
(doseq [[testcase {:keys [actual expected]}] (valid-testcases)]
(let [parent (fs/parent testcase)
run (fn []
(fs/with-mutable-cwd
(fs/chdir parent)
(-> (->Annot
(-> actual parse expr)
(-> expected parse expr))
(resolve-imports import-cache)
(typecheck {})))
nil)]
(println "TESTCASE" testcase)
(testing testcase
(is (= nil (run))))))))

(deftest typecheck-failure-suite
(doseq [[testcase dhall] (failure-testcases test-folder)]
(let [parent (fs/parent testcase)
run (fn []
(fs/with-mutable-cwd
(fs/chdir parent)
(-> dhall
parse
expr
(resolve-imports (s/new))
(typecheck {}))))]
(is (thrown-with-msg? clojure.lang.ExceptionInfo #"Typecheck error:"
(run))))))
(let [import-cache (s/new)]
(doseq [[testcase dhall] (failure-testcases test-folder)]
(let [parent (fs/parent testcase)
run (fn []
(fs/with-mutable-cwd
(fs/chdir parent)
(-> dhall
parse
expr
(resolve-imports import-cache)
(typecheck {}))))]
(is (thrown-with-msg? clojure.lang.ExceptionInfo #"Typecheck error:"
(run)))))))

0 comments on commit 520b72b

Please sign in to comment.