
import PRODUCTION/utility.lm;

(assert-eq( 'tests/unit/utility.lm True True ));

(assert-eq( 'tests/unit/utility.lm (parse-type Nil) Nil ));
(assert-eq( 'tests/unit/utility.lm (parse-type Nil) Nil ));
(assert-eq( 'tests/unit/utility.lm (parse-type Atom) Atom ));
(assert-eq( 'tests/unit/utility.lm (parse-type List<Atom>) (List Atom) ));
(assert-eq( 'tests/unit/utility.lm (parse-type List<List<Atom>>) (List (List Atom)) ));
(assert-eq( 'tests/unit/utility.lm (parse-type '[Atom,Nil]) ('[] (Atom Nil)) ));
(assert-eq( 'tests/unit/utility.lm (parse-type '[Atom,Nil,Cons]) ('[] (('[] (Atom Nil)) Cons)) ));

(assert-eq( 'tests/unit/utility.lm (parse-type '[Atom,List<[Cons,Nil]>]) ('[] (Atom (List ('[] (Cons Nil))))) ));

(assert-typeof( 'tests/unit/utility.lm () Nil ));
(assert-not-typeof( 'tests/unit/utility.lm 1 Nil ));
(assert-not-typeof( 'tests/unit/utility.lm (1 2) Nil ));

(assert-typeof( 'tests/unit/utility.lm 1 Atom ));
(assert-not-typeof( 'tests/unit/utility.lm () Atom ));
(assert-not-typeof( 'tests/unit/utility.lm (1 2) Atom ));

(assert-typeof( 'tests/unit/utility.lm (1 2) Cons ));
(assert-not-typeof( 'tests/unit/utility.lm 1 Cons ));
(assert-not-typeof( 'tests/unit/utility.lm () Cons ));

(assert-typeof( 'tests/unit/utility.lm (StrictExpr ()) StrictExpr ));
(assert-not-typeof( 'tests/unit/utility.lm (StrictExpr ()) Expr ));
(assert-not-typeof( 'tests/unit/utility.lm (StrictExpr ()) Nil ));
(assert-not-typeof( 'tests/unit/utility.lm (StrictExpr ()) Atom ));

(assert-typeof( 'tests/unit/utility.lm () List<Atom> ));
(assert-typeof( 'tests/unit/utility.lm ((() 1) 2) List<Atom> ));
(assert-not-typeof( 'tests/unit/utility.lm ((() 1) 2) List<Cons> ));
(assert-not-typeof( 'tests/unit/utility.lm ((() 1) 2) List<Nil> ));

(assert-typeof( 'tests/unit/utility.lm () List<[Atom,Nil]> ));
(assert-typeof( 'tests/unit/utility.lm ((() (1 ()) ) (2 ()) ) List<[Atom,Nil]> ));
(assert-not-typeof( 'tests/unit/utility.lm ((() (1 ()) ) (2 ()) ) List<[Nil,Nil]> ));
(assert-not-typeof( 'tests/unit/utility.lm ((() (1 ()) ) (2 ()) ) List<[Atom,Atom]> ));

(assert-typeof( 'tests/unit/utility.lm () List<List<Atom>> ));
(assert-typeof( 'tests/unit/utility.lm ( () (() '1) ) List<List<Atom>> ));
(assert-not-typeof( 'tests/unit/utility.lm ( () (() '1) ) List<List<Nil>> ));
(assert-not-typeof( 'tests/unit/utility.lm ( () (() '1) ) List<Atom> ));

(assert-typeof( 'tests/unit/utility.lm ( (1 2) () ) '[Atom,Atom,Nil] ));
(assert-not-typeof( 'tests/unit/utility.lm ( (1 2) () ) '[Atom,Nil,Nil] ));

(assert-typeof( 'tests/unit/utility.lm 1 Or<[Atom,Nil]> ));
(assert-typeof( 'tests/unit/utility.lm () Or<[Atom,Nil]> ));
(assert-not-typeof( 'tests/unit/utility.lm (1 2) Or<[Atom,Nil]> ));
