aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2018-07-04 21:32:36 -0400
committerEduardo Julian2018-07-04 21:32:36 -0400
commit7585d987ad3898859ce817ad9857dccb6e788c6b (patch)
tree48090b237f8c96d4ab4fb180d671354e980118a4
parent7179bb2ea733a99c326642abbf48638d540ff651 (diff)
- Deleted useless old LuxC tests.
-rw-r--r--luxc/test/test/lux/lexer.clj271
-rw-r--r--luxc/test/test/lux/parser.clj269
-rw-r--r--luxc/test/test/lux/reader.clj48
-rw-r--r--luxc/test/test/lux/type.clj468
4 files changed, 0 insertions, 1056 deletions
diff --git a/luxc/test/test/lux/lexer.clj b/luxc/test/test/lux/lexer.clj
deleted file mode 100644
index 1c8d02f27..000000000
--- a/luxc/test/test/lux/lexer.clj
+++ /dev/null
@@ -1,271 +0,0 @@
-(ns test.lux.lexer
- (:use clojure.test)
- (:require (lux [base :as & :refer [|do return* return fail fail* |let |case]]
- [reader :as &reader]
- [lexer :as &lexer])
- [lux.analyser.module :as &a-module]
- :reload-all
- ))
-
-;; [Utils]
-(def ^:private module-name "test")
-
-(defn ^:private make-state [source-code]
- (&/set$ &/$source (&reader/from module-name source-code)
- (&/init-state nil)))
-
-;; [Tests]
-(deftest lex-white-space
- (let [input " \t"]
- (|case (&/run-state &lexer/lex (make-state input))
- (&/$Right state [cursor (&lexer/$White_Space output)])
- (is (= input output))
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest lex-comment
- ;; Should be capable of recognizing both single-line & multi-line comments.
- (let [input1 " YOLO"
- input2 "\nLOL\n"
- input3 " NYAN\n#(\nCAT )#\n"]
- (|case (&/run-state (|do [[_ single-line] &lexer/lex
- [_ multi-line] &lexer/lex
- [_ multi-line-embedded] &lexer/lex]
- (return (&/T [single-line multi-line multi-line-embedded])))
- (make-state (str "##" input1 "\n" "#(" input2 ")#" "\n" "#(" input3 ")#")))
- (&/$Right state [(&lexer/$Comment output1)
- (&lexer/$Comment output2)
- (&lexer/$Comment output3)])
- (are [input output] (= input output)
- input1 output1
- input2 output2
- input3 output3)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest lex-bool
- (let [input1 "true"
- input2 "false"]
- (|case (&/run-state (|do [[_ output1] &lexer/lex
- [_ output2] &lexer/lex]
- (return (&/T [output1 output2])))
- (make-state (str input1 "\n" input2)))
- (&/$Right state [(&lexer/$Bool output1)
- (&lexer/$Bool output2)])
- (are [input output] (= input output)
- input1 output1
- input2 output2)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest lex-int
- (let [input1 "0"
- input2 "12"
- input3 "-123"]
- (|case (&/run-state (|do [[_ output1] &lexer/lex
- [_ output2] &lexer/lex
- [_ output3] &lexer/lex]
- (return (&/T [output1 output2 output3])))
- (make-state (str input1 "\n" input2 "\n" input3)))
- (&/$Right state [(&lexer/$Int output1)
- (&lexer/$Int output2)
- (&lexer/$Int output3)])
- (are [input output] (= input output)
- input1 output1
- input2 output2
- input3 output3)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest lex-real
- (let [input1 "0.00123"
- input2 "12.01020300"
- input3 "-12.3"]
- (|case (&/run-state (|do [[_ output1] &lexer/lex
- [_ output2] &lexer/lex
- [_ output3] &lexer/lex]
- (return (&/T [output1 output2 output3])))
- (make-state (str input1 "\n" input2 "\n" input3)))
- (&/$Right state [(&lexer/$Real output1)
- (&lexer/$Real output2)
- (&lexer/$Real output3)])
- (are [input output] (= input output)
- input1 output1
- input2 output2
- input3 output3)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest lex-char
- (let [input1 "a"
- input2 "\\n"
- input3 " "
- input4 "\\t"
- input5 "\\b"
- input6 "\\r"
- input7 "\\f"
- input8 "\\\""
- input9 "\\\\"]
- (|case (&/run-state (|do [[_ output1] &lexer/lex
- [_ output2] &lexer/lex
- [_ output3] &lexer/lex
- [_ output4] &lexer/lex
- [_ output5] &lexer/lex
- [_ output6] &lexer/lex
- [_ output7] &lexer/lex
- [_ output8] &lexer/lex
- [_ output9] &lexer/lex]
- (return (&/T [output1 output2 output3 output4 output5 output6 output7 output8 output9])))
- (make-state (str "#\"" input1 "\"" "\n" "#\"" input2 "\"" "\n" "#\"" input3 "\""
- "\n" "#\"" input4 "\"" "\n" "#\"" input5 "\"" "\n" "#\"" input6 "\""
- "\n" "#\"" input7 "\"" "\n" "#\"" input8 "\"" "\n" "#\"" input9 "\"")))
- (&/$Right state [(&lexer/$Char output1)
- (&lexer/$Char output2)
- (&lexer/$Char output3)
- (&lexer/$Char output4)
- (&lexer/$Char output5)
- (&lexer/$Char output6)
- (&lexer/$Char output7)
- (&lexer/$Char output8)
- (&lexer/$Char output9)])
- (are [input output] (= input output)
- input1 output1
- "\n" output2
- input3 output3
- "\t" output4
- "\b" output5
- "\r" output6
- "\f" output7
- "\"" output8
- "\\" output9)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest lex-text
- (let [input1 ""
- input2 "abc"
- input3 "yolo\\nlol\\tmeme"
- input4 "This is a test\\nof multi-line text.\\n\\nI just wanna make sure it works alright..."]
- (|case (&/run-state (|do [[_ output1] &lexer/lex
- [_ output2] &lexer/lex
- [_ output3] &lexer/lex
- [_ output4] &lexer/lex]
- (return (&/T [output1 output2 output3 output4])))
- (make-state (str "\"" input1 "\"" "\n" "\"" input2 "\"" "\n" "\"" input3 "\"" "\n" "\"" input4 "\"")))
- (&/$Right state [(&lexer/$Text output1)
- (&lexer/$Text output2)
- (&lexer/$Text output3)
- (&lexer/$Text output4)])
- (are [input output] (= input output)
- input1 output1
- input2 output2
- "yolo\nlol\tmeme" output3
- "This is a test\nof multi-line text.\n\nI just wanna make sure it works alright..." output4)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest lex-symbol
- (let [input1 "foo"
- input2 "test;bar0123456789"
- input3 ";b1a2z3"
- input4 ";;quux"
- input5 "!_@$%^&*-+=.<>?/|\\~`':"]
- (|case (&/run-state (|do [_ (&a-module/enter-module module-name)
- [_ output1] &lexer/lex
- [_ output2] &lexer/lex
- [_ output3] &lexer/lex
- [_ output4] &lexer/lex
- [_ output5] &lexer/lex]
- (return (&/T [output1 output2 output3 output4 output5])))
- (make-state (str input1 "\n" input2 "\n" input3 "\n" input4 "\n" input5 " ")))
- (&/$Right state [(&lexer/$Symbol output1)
- (&lexer/$Symbol output2)
- (&lexer/$Symbol output3)
- (&lexer/$Symbol output4)
- (&lexer/$Symbol output5)])
- (are [input output] (&/ident= input output)
- (&/T ["" "foo"]) output1
- (&/T ["test" "bar0123456789"]) output2
- (&/T ["lux" "b1a2z3"]) output3
- (&/T ["test" "quux"]) output4
- (&/T ["" "!_@$%^&*-+=.<>?/|\\~`':"]) output5)
-
- _
- (is false "Couldn't read")
- )))
-
-(deftest lex-tag
- (let [input1 "foo"
- input2 "test;bar0123456789"
- input3 ";b1a2z3"
- input4 ";;quux"
- input5 "!_@$%^&*-+=.<>?/|\\~`':"]
- (|case (&/run-state (|do [_ (&a-module/enter-module module-name)
- [_ output1] &lexer/lex
- [_ output2] &lexer/lex
- [_ output3] &lexer/lex
- [_ output4] &lexer/lex
- [_ output5] &lexer/lex]
- (return (&/T [output1 output2 output3 output4 output5])))
- (make-state (str "#" input1 "\n" "#" input2 "\n" "#" input3 "\n" "#" input4 "\n" "#" input5 " ")))
- (&/$Right state [(&lexer/$Tag output1)
- (&lexer/$Tag output2)
- (&lexer/$Tag output3)
- (&lexer/$Tag output4)
- (&lexer/$Tag output5)])
- (are [input output] (&/ident= input output)
- (&/T ["" "foo"]) output1
- (&/T ["test" "bar0123456789"]) output2
- (&/T ["lux" "b1a2z3"]) output3
- (&/T ["test" "quux"]) output4
- (&/T ["" "!_@$%^&*-+=.<>?/|\\~`':"]) output5)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest lex-delimiter
- (let [input1 "("
- input2 ")"
- input3 "["
- input4 "]"
- input5 "{"
- input6 "}"]
- (|case (&/run-state (|do [_ (&a-module/enter-module module-name)
- [_ output1] &lexer/lex
- [_ output2] &lexer/lex
- [_ output3] &lexer/lex
- [_ output4] &lexer/lex
- [_ output5] &lexer/lex
- [_ output6] &lexer/lex]
- (return (&/T [output1 output2 output3 output4 output5 output6])))
- (make-state (str input1 "\n" input2 "\n" input3 "\n" input4 "\n" input5 "\n" input6)))
- (&/$Right state [(&lexer/$Open_Paren)
- (&lexer/$Close_Paren)
- (&lexer/$Open_Bracket)
- (&lexer/$Close_Bracket)
- (&lexer/$Open_Brace)
- (&lexer/$Close_Brace)])
- (is true)
-
- _
- (is false "Couldn't read.")
- )))
-
-(comment
- (run-all-tests)
- )
diff --git a/luxc/test/test/lux/parser.clj b/luxc/test/test/lux/parser.clj
deleted file mode 100644
index 2cf76def7..000000000
--- a/luxc/test/test/lux/parser.clj
+++ /dev/null
@@ -1,269 +0,0 @@
-(ns test.lux.parser
- (:use (clojure test
- template))
- (:require (lux [base :as & :refer [|do return* return fail fail* |let |case]]
- [reader :as &reader]
- [parser :as &parser])
- [lux.analyser.module :as &a-module]
- :reload-all))
-
-;; [Utils]
-(def ^:private module-name "test")
-
-(defn ^:private make-state [source-code]
- (&/set$ &/$source (&reader/from module-name source-code)
- (&/init-state nil)))
-
-;; [Tests]
-(deftest parse-white-space
- (let [input " \t"]
- (|case (&/run-state &parser/parse (make-state input))
- (&/$Right state (&/$Nil))
- (is true)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest parse-comment
- (let [input1 " YOLO"
- input2 "\nLOL\n"
- input3 " NYAN\n#(\nCAT )#\n"]
- (|case (&/run-state &parser/parse (make-state (str "##" input1 "\n" "#(" input2 ")#" "\n" "#(" input3 ")#")))
- (&/$Right state (&/$Nil))
- (is true)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest parse-bool
- (let [input1 "true"
- input2 "false"]
- (|case (&/run-state (|do [output1 &parser/parse
- output2 &parser/parse]
- (return (&/|++ output1 output2)))
- (make-state (str input1 "\n" input2)))
- (&/$Right state (&/$Cons [_ (&/$Bool output1)] (&/$Cons [_ (&/$Bool output2)] (&/$Nil))))
- (are [input output] (= input output)
- true output1
- false output2)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest parse-int
- (let [input1 "0"
- input2 "12"
- input3 "-123"]
- (|case (&/run-state (|do [output1 &parser/parse
- output2 &parser/parse
- output3 &parser/parse]
- (return (&/|++ output1 (&/|++ output2 output3))))
- (make-state (str input1 "\n" input2 "\n" input3)))
- (&/$Right state (&/$Cons [_ (&/$Int output1)] (&/$Cons [_ (&/$Int output2)] (&/$Cons [_ (&/$Int output3)] (&/$Nil)))))
- (are [input output] (= input output)
- 0 output1
- 12 output2
- -123 output3)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest parse-real
- (let [input1 "0.00123"
- input2 "12.01020300"
- input3 "-12.3"]
- (|case (&/run-state (|do [output1 &parser/parse
- output2 &parser/parse
- output3 &parser/parse]
- (return (&/|++ output1 (&/|++ output2 output3))))
- (make-state (str input1 "\n" input2 "\n" input3)))
- (&/$Right state (&/$Cons [_ (&/$Real output1)] (&/$Cons [_ (&/$Real output2)] (&/$Cons [_ (&/$Real output3)] (&/$Nil)))))
- (are [input output] (= input output)
- 0.00123 output1
- 12.010203 output2
- -12.3 output3)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest parse-char
- (let [input1 "a"
- input2 "\\n"
- input3 " "
- input4 "\\t"
- input5 "\\b"
- input6 "\\r"
- input7 "\\f"
- input8 "\\\""
- input9 "\\\\"]
- (|case (&/run-state (|do [output1 &parser/parse
- output2 &parser/parse
- output3 &parser/parse
- output4 &parser/parse
- output5 &parser/parse
- output6 &parser/parse
- output7 &parser/parse
- output8 &parser/parse
- output9 &parser/parse]
- (return (&/|++ output1 (&/|++ output2 (&/|++ output3 (&/|++ output4 (&/|++ output5 (&/|++ output6 (&/|++ output7 (&/|++ output8 output9))))))))))
- (make-state (str "#\"" input1 "\"" "\n" "#\"" input2 "\"" "\n" "#\"" input3 "\""
- "\n" "#\"" input4 "\"" "\n" "#\"" input5 "\"" "\n" "#\"" input6 "\""
- "\n" "#\"" input7 "\"" "\n" "#\"" input8 "\"" "\n" "#\"" input9 "\"")))
- (&/$Right state (&/$Cons [_ (&/$Char output1)]
- (&/$Cons [_ (&/$Char output2)]
- (&/$Cons [_ (&/$Char output3)]
- (&/$Cons [_ (&/$Char output4)]
- (&/$Cons [_ (&/$Char output5)]
- (&/$Cons [_ (&/$Char output6)]
- (&/$Cons [_ (&/$Char output7)]
- (&/$Cons [_ (&/$Char output8)]
- (&/$Cons [_ (&/$Char output9)]
- (&/$Nil)))))))))))
- (are [input output] (= input output)
- \a output1
- \newline output2
- \space output3
- \tab output4
- \backspace output5
- \return output6
- \formfeed output7
- \" output8
- \\ output9)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest parse-text
- (let [input1 ""
- input2 "abc"
- input3 "yolo\\nlol\\tmeme"
- input4 "This is a test\\nof multi-line text.\\n\\nI just wanna make sure it works alright..."]
- (|case (&/run-state (|do [output1 &parser/parse
- output2 &parser/parse
- output3 &parser/parse
- output4 &parser/parse]
- (return (&/|++ output1 (&/|++ output2 (&/|++ output3 output4)))))
- (make-state (str "\"" input1 "\"" "\n" "\"" input2 "\"" "\n" "\"" input3 "\"" "\n" "\"" input4 "\"")))
- (&/$Right state (&/$Cons [_ (&/$Text output1)] (&/$Cons [_ (&/$Text output2)] (&/$Cons [_ (&/$Text output3)] (&/$Cons [_ (&/$Text output4)] (&/$Nil))))))
- (are [input output] (= input output)
- input1 output1
- input2 output2
- "yolo\nlol\tmeme" output3
- "This is a test\nof multi-line text.\n\nI just wanna make sure it works alright..." output4)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest parse-symbol
- (let [input1 "foo"
- input2 "test;bar0123456789"
- input3 ";b1a2z3"
- input4 ";;quux"
- input5 "!_@$%^&*-+=.<>?/|\\~`':"]
- (|case (&/run-state (|do [_ (&a-module/enter-module module-name)
- output1 &parser/parse
- output2 &parser/parse
- output3 &parser/parse
- output4 &parser/parse
- output5 &parser/parse]
- (return (&/|++ output1 (&/|++ output2 (&/|++ output3 (&/|++ output4 output5))))))
- (make-state (str input1 "\n" input2 "\n" input3 "\n" input4 "\n" input5 " ")))
- (&/$Right state (&/$Cons [_ (&/$Symbol output1)]
- (&/$Cons [_ (&/$Symbol output2)]
- (&/$Cons [_ (&/$Symbol output3)]
- (&/$Cons [_ (&/$Symbol output4)]
- (&/$Cons [_ (&/$Symbol output5)]
- (&/$Nil)))))))
- (are [input output] (&/ident= input output)
- (&/T ["" "foo"]) output1
- (&/T ["test" "bar0123456789"]) output2
- (&/T ["lux" "b1a2z3"]) output3
- (&/T ["test" "quux"]) output4
- (&/T ["" "!_@$%^&*-+=.<>?/|\\~`':"]) output5)
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest parse-tag
- (let [input1 "foo"
- input2 "test;bar0123456789"
- input3 ";b1a2z3"
- input4 ";;quux"
- input5 "!_@$%^&*-+=.<>?/|\\~`':"]
- (|case (&/run-state (|do [_ (&a-module/enter-module module-name)
- output1 &parser/parse
- output2 &parser/parse
- output3 &parser/parse
- output4 &parser/parse
- output5 &parser/parse]
- (return (&/|++ output1 (&/|++ output2 (&/|++ output3 (&/|++ output4 output5))))))
- (make-state (str "#" input1 "\n" "#" input2 "\n" "#" input3 "\n" "#" input4 "\n" "#" input5 " ")))
- (&/$Right state (&/$Cons [_ (&/$Tag output1)]
- (&/$Cons [_ (&/$Tag output2)]
- (&/$Cons [_ (&/$Tag output3)]
- (&/$Cons [_ (&/$Tag output4)]
- (&/$Cons [_ (&/$Tag output5)]
- (&/$Nil)))))))
- (are [input output] (&/ident= input output)
- (&/T ["" "foo"]) output1
- (&/T ["test" "bar0123456789"]) output2
- (&/T ["lux" "b1a2z3"]) output3
- (&/T ["test" "quux"]) output4
- (&/T ["" "!_@$%^&*-+=.<>?/|\\~`':"]) output5)
-
- _
- (is false "Couldn't read.")
- )))
-
-(do-template [<name> <tag> <open> <close>]
- (deftest <name>
- (let [input1 "yolo 123 \"lol\" #meme"]
- (|case (&/run-state &parser/parse
- (make-state (str <open> input1 <close>)))
- (&/$Right state (&/$Cons [_ (<tag> (&/$Cons [_ (&/$Symbol symv)]
- (&/$Cons [_ (&/$Int intv)]
- (&/$Cons [_ (&/$Text textv)]
- (&/$Cons [_ (&/$Tag tagv)]
- (&/$Nil))))))]
- (&/$Nil)))
- (do (is (&/ident= (&/T ["" "yolo"]) symv))
- (is (= 123 intv))
- (is (= "lol" textv))
- (is (&/ident= (&/T ["" "meme"]) tagv)))
-
- _
- (is false "Couldn't read.")
- )))
-
- parse-form &/$Form "(" ")"
- parse-tuple &/$Tuple "[" "]"
- )
-
-(deftest parse-record
- (let [input1 "yolo 123 \"lol\" #meme"]
- (|case (&/run-state &parser/parse
- (make-state (str "{" input1 "}")))
- (&/$Right state (&/$Cons [_ (&/$Record (&/$Cons [[_ (&/$Symbol symv)] [_ (&/$Int intv)]]
- (&/$Cons [[_ (&/$Text textv)] [_ (&/$Tag tagv)]]
- (&/$Nil))))]
- (&/$Nil)))
- (do (is (&/ident= (&/T ["" "yolo"]) symv))
- (is (= 123 intv))
- (is (= "lol" textv))
- (is (&/ident= (&/T ["" "meme"]) tagv)))
-
- _
- (is false "Couldn't read.")
- )))
-
-(comment
- (run-all-tests)
- )
diff --git a/luxc/test/test/lux/reader.clj b/luxc/test/test/lux/reader.clj
deleted file mode 100644
index 87e1971ac..000000000
--- a/luxc/test/test/lux/reader.clj
+++ /dev/null
@@ -1,48 +0,0 @@
-(ns test.lux.reader
- (:use clojure.test)
- (:require (lux [base :as & :refer [|do return* return fail fail* |let |case]]
- [reader :as &reader])
- :reload-all))
-
-;; [Utils]
-(def source (&reader/from "test" "lol\nmeme\nnyan cat\n\nlolcat"))
-(def init-state (&/set$ &/$source source (&/init-state nil)))
-
-;; [Tests]
-(deftest test-source-code-reading
- (is (= 5 (&/|length source))))
-
-(deftest test-text-reading
- ;; Should be capable of recognizing literal texts.
- (let [input "lo"]
- (|case (&/run-state (&reader/read-text input) init-state)
- (&/$Right state [cursor end-line? output])
- (is (= input output))
-
- _
- (is false "Couldn't read.")
- )))
-
-(deftest test-regex-reading
- ;; Should be capable of matching simple, grouping regex-patterns.
- (|case (&/run-state (&reader/read-regex #"l(.)l") init-state)
- (&/$Right state [cursor end-line? output])
- (is (= "lol" output))
-
- _
- (is false "Couldn't read.")
- ))
-
-(deftest test-regex+-reading
- ;; Should be capable of matching multi-line regex-patterns.
- (|case (&/run-state (&reader/read-regex+ #"(?is)^((?!cat).)*") init-state)
- (&/$Right state [cursor output])
- (is (= "\nlol\nmeme\nnyan " output))
-
- _
- (is false "Couldn't read.")
- ))
-
-(comment
- (run-all-tests)
- )
diff --git a/luxc/test/test/lux/type.clj b/luxc/test/test/lux/type.clj
deleted file mode 100644
index 5a9a7ff1b..000000000
--- a/luxc/test/test/lux/type.clj
+++ /dev/null
@@ -1,468 +0,0 @@
-(ns test.lux.type
- (:use clojure.test)
- (:require (lux [base :as & :refer [|do return* return fail fail* |let |case]]
- [type :as &type])
- :reload-all
- ))
-
-;; [Tests]
-(deftest check-base-types
- (|case (&/run-state (|do [_ (&type/check &/$Unit &/$Unit)
-
- _ (&type/check &/$Void &/$Void)]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-simple-host-types
- (|case (&/run-state (|do [_ (&type/check (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))
-
- _ (&type/check (&/$Host "java.lang.Object" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-complex-host-types
- (|case (&/run-state (|do [_ (&type/check (&/$Host "java.util.List" (&/|list (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Host "java.util.List" (&/|list (&/$Host "java.lang.Boolean" &/$Nil))))
-
- _ (&type/check (&/$Host "java.util.List" (&/|list (&/$Host "java.lang.Object" &/$Nil)))
- (&/$Host "java.util.List" (&/|list (&/$Host "java.lang.Boolean" &/$Nil))))
-
- _ (&type/check (&/$Host "java.util.List" (&/|list (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Host "java.util.ArrayList" (&/|list (&/$Host "java.lang.Boolean" &/$Nil))))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-named-types
- (|case (&/run-state (|do [_ (&type/check (&/$Named (&/T ["lux" "Bool"]) (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Host "java.lang.Boolean" &/$Nil))
-
- _ (&type/check (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Named (&/T ["lux" "Bool"]) (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Named (&/T ["lux" "Bool"]) (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Named (&/T ["lux" "Bool"]) (&/$Host "java.lang.Boolean" &/$Nil)))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-sum-types
- (|case (&/run-state (|do [_ (&type/check (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Sum (&/$Host "java.lang.Object" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Sum (&/$Host "java.lang.Object" &/$Nil)
- (&/$Host "java.lang.Object" &/$Nil))
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))
-
- _ (&type/check (&/$Sum (&/$Host "java.lang.Object" &/$Nil)
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))
-
- _ (&type/check (&/$Sum (&/$Host "java.lang.Object" &/$Nil)
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Object" &/$Nil)))
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Sum (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-prod-types
- (|case (&/run-state (|do [_ (&type/check (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Product (&/$Host "java.lang.Object" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Product (&/$Host "java.lang.Object" &/$Nil)
- (&/$Host "java.lang.Object" &/$Nil))
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))
-
- _ (&type/check (&/$Product (&/$Host "java.lang.Object" &/$Nil)
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))
-
- _ (&type/check (&/$Product (&/$Host "java.lang.Object" &/$Nil)
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Object" &/$Nil)))
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Product (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-lambda-types
- (|case (&/run-state (|do [_ (&type/check (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Lambda (&/$Host "java.lang.Object" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Object" &/$Nil))
- (&/$Lambda (&/$Host "java.lang.Object" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))
-
- _ (&type/check (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Lambda (&/$Host "java.lang.Object" &/$Nil)
- (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))
-
- _ (&type/check (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Object" &/$Nil)))
- (&/$Lambda (&/$Host "java.lang.Object" &/$Nil)
- (&/$Lambda (&/$Host "java.lang.Boolean" &/$Nil)
- (&/$Host "java.lang.Boolean" &/$Nil))))
- ]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-ex-types
- (|case (&/run-state (|do [_ (&type/check (&/$Ex 0) (&/$Ex 0))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-univ-quantification
- (|case (&/run-state (|do [_ (&type/check (&/$UnivQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- (&/$UnivQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1))))
-
- _ (&type/check (&/$UnivQ (&/|list)
- (&/$Sum
- ;; lux;None
- &/$Unit
- ;; lux;Some
- (&/$Bound 1)))
- (&/$UnivQ (&/|list)
- (&/$Sum
- ;; lux;None
- &/$Unit
- ;; lux;Some
- (&/$Bound 1))))
-
- _ (&type/check (&/$UnivQ (&/|list)
- (&/$Sum
- ;; lux;Nil
- &/$Unit
- ;; lux;Cons
- (&/$Product (&/$Bound 1)
- (&/$App (&/$Bound 0)
- (&/$Bound 1)))))
- (&/$UnivQ (&/|list)
- (&/$Sum
- ;; lux;Nil
- &/$Unit
- ;; lux;Cons
- (&/$Product (&/$Bound 1)
- (&/$App (&/$Bound 0)
- (&/$Bound 1))))))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-ex-quantification
- (|case (&/run-state (|do [_ (&type/check (&/$ExQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- (&/$ExQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1))))
-
- _ (&type/check (&/$ExQ (&/|list)
- (&/$Sum
- ;; lux;None
- &/$Unit
- ;; lux;Some
- (&/$Bound 1)))
- (&/$ExQ (&/|list)
- (&/$Sum
- ;; lux;None
- &/$Unit
- ;; lux;Some
- (&/$Bound 1))))
-
- _ (&type/check (&/$ExQ (&/|list)
- (&/$Sum
- ;; lux;Nil
- &/$Unit
- ;; lux;Cons
- (&/$Product (&/$Bound 1)
- (&/$App (&/$Bound 0)
- (&/$Bound 1)))))
- (&/$ExQ (&/|list)
- (&/$Sum
- ;; lux;Nil
- &/$Unit
- ;; lux;Cons
- (&/$Product (&/$Bound 1)
- (&/$App (&/$Bound 0)
- (&/$Bound 1))))))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-app-type
- (|case (&/run-state (|do [_ (&type/check (&/$App (&/$UnivQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$App (&/$UnivQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$App (&/$UnivQ (&/|list)
- (&/$Sum
- ;; lux;None
- &/$Unit
- ;; lux;Some
- (&/$Bound 1)))
- (&/$Host "java.lang.Object" &/$Nil))
- (&/$App (&/$UnivQ (&/|list)
- (&/$Sum
- ;; lux;None
- &/$Unit
- ;; lux;Some
- (&/$Bound 1)))
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$App (&/$ExQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$App (&/$ExQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- (&/$Host "java.lang.Boolean" &/$Nil)))
-
- _ (&type/check (&/$App (&/$ExQ (&/|list)
- (&/$Sum
- ;; lux;None
- &/$Unit
- ;; lux;Some
- (&/$Bound 1)))
- (&/$Host "java.lang.Object" &/$Nil))
- (&/$App (&/$ExQ (&/|list)
- (&/$Sum
- ;; lux;None
- &/$Unit
- ;; lux;Some
- (&/$Bound 1)))
- (&/$Host "java.lang.Boolean" &/$Nil)))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(deftest check-var-type
- (|case (&/run-state (|do [_ (&type/with-var
- (fn [$var]
- (|do [_ (&type/check $var (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$Host "java.lang.Boolean" (&/$Nil)) (&type/deref+ $var)]
- (return nil))))
-
- _ (&type/with-var
- (fn [$var]
- (|do [_ (&type/check (&/$App (&/$UnivQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- $var)
- (&/$App (&/$UnivQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- (&/$Host "java.lang.Boolean" &/$Nil)))
- (&/$Host "java.lang.Boolean" (&/$Nil)) (&type/deref+ $var)]
- (return nil))))
-
- _ (&type/with-var
- (fn [$var]
- (|do [_ (&type/check (&/$Host "java.lang.Boolean" &/$Nil) $var)
- (&/$Host "java.lang.Boolean" (&/$Nil)) (&type/deref+ $var)]
- (return nil))))
-
- _ (&type/with-var
- (fn [$var]
- (|do [_ (&type/check (&/$App (&/$UnivQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- (&/$Host "java.lang.Boolean" &/$Nil))
- (&/$App (&/$UnivQ (&/|list)
- (&/$Lambda &/$Void (&/$Bound 1)))
- $var))
- (&/$Host "java.lang.Boolean" (&/$Nil)) (&type/deref+ $var)]
- (return nil))))
-
- _ (&type/with-var
- (fn [$var1]
- (&type/with-var
- (fn [$var2]
- (|do [_ (&type/check $var1 $var2)]
- (return nil))))))
-
- _ (&type/with-var
- (fn [$var1]
- (&type/with-var
- (fn [$var2]
- (|do [_ (&type/check $var2 $var1)]
- (return nil))))))
-
- _ (&type/with-var
- (fn [$var1]
- (&type/with-var
- (fn [$var2]
- (|do [_ (&type/check $var1 $var2)
- _ (&type/check $var1 (&/$Host "java.lang.Boolean" (&/|list)))
- =var1 (&type/deref+ $var1)
- _ (&/assert! (&type/type= =var1 $var2) "")
- =var2 (&type/deref+ $var2)
- _ (&/assert! (&type/type= =var2 (&/$Host "java.lang.Boolean" (&/|list))) "")]
- (return nil))))))
-
- _ (&type/with-var
- (fn [$var1]
- (&type/with-var
- (fn [$var2]
- (|do [_ (&type/check $var2 $var1)
- _ (&type/check $var1 (&/$Host "java.lang.Boolean" (&/|list)))
- =var2 (&type/deref+ $var2)
- _ (&/assert! (&type/type= =var2 $var1) "")
- =var1 (&type/deref+ $var1)
- _ (&/assert! (&type/type= =var1 (&/$Host "java.lang.Boolean" (&/|list))) "")]
- (return nil))))))
-
- _ (&type/with-var
- (fn [$var1]
- (&type/with-var
- (fn [$var2]
- (|do [_ (&type/check $var1 $var2)
- _ (&type/check $var2 (&/$Host "java.lang.Boolean" (&/|list)))
- =var1 (&type/deref+ $var1)
- _ (&/assert! (&type/type= =var1 $var2) "")
- =var2 (&type/deref+ $var2)
- _ (&/assert! (&type/type= =var2 (&/$Host "java.lang.Boolean" (&/|list))) "")]
- (return nil))))))
-
- _ (&type/with-var
- (fn [$var1]
- (&type/with-var
- (fn [$var2]
- (|do [_ (&type/check $var2 $var1)
- _ (&type/check $var2 (&/$Host "java.lang.Boolean" (&/|list)))
- =var2 (&type/deref+ $var2)
- _ (&/assert! (&type/type= =var2 $var1) "")
- =var1 (&type/deref+ $var1)
- _ (&/assert! (&type/type= =var1 (&/$Host "java.lang.Boolean" (&/|list))) "")]
- (return nil))))))]
- (return nil))
- (&/init-state nil))
- (&/$Right state nil)
- (is true)
-
- (&/$Left error)
- (is false error)
- ))
-
-(comment
- (run-all-tests)
- )