Definition dependency analysis
tricu now allows defining terms in any order and will resolve dependencies to ensure that they're evaluated in the right order. Undefined terms are detected and throw errors during dependency ordering. For now we can't define top-level mutually recursive terms.
This commit is contained in:
		
							
								
								
									
										10
									
								
								test/Spec.hs
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								test/Spec.hs
									
									
									
									
									
								
							| @ -85,7 +85,7 @@ parser = testGroup "Parser Tests" | ||||
|  | ||||
|   , testCase "Parse function definitions" $ do | ||||
|       let input = "x = (\\a b c : a)" | ||||
|           expect = SFunc "x" [] (SLambda ["a"] (SLambda ["b"] (SLambda ["c"] (SVar "a")))) | ||||
|           expect = SDef "x" [] (SLambda ["a"] (SLambda ["b"] (SLambda ["c"] (SVar "a")))) | ||||
|       parseSingle input @?= expect | ||||
|  | ||||
|   , testCase "Parse nested Tree Calculus terms" $ do | ||||
| @ -105,7 +105,7 @@ parser = testGroup "Parser Tests" | ||||
|  | ||||
|   , testCase "Parse function with applications" $ do | ||||
|       let input  = "f = (\\x : t x)" | ||||
|           expect = SFunc "f" [] (SLambda ["x"] (SApp TLeaf (SVar "x"))) | ||||
|           expect = SDef "f" [] (SLambda ["x"] (SApp TLeaf (SVar "x"))) | ||||
|       parseSingle input @?= expect | ||||
|  | ||||
|   , testCase "Parse nested lists" $ do | ||||
| @ -147,7 +147,7 @@ parser = testGroup "Parser Tests" | ||||
|  | ||||
|   , testCase "Parse nested parentheses in function body" $ do | ||||
|       let input  = "f = (\\x : t (t (t t)))" | ||||
|           expect = SFunc "f" [] (SLambda ["x"] (SApp TLeaf (SApp TLeaf (SApp TLeaf TLeaf)))) | ||||
|           expect = SDef "f" [] (SLambda ["x"] (SApp TLeaf (SApp TLeaf (SApp TLeaf TLeaf)))) | ||||
|       parseSingle input @?= expect | ||||
|  | ||||
|   , testCase "Parse lambda abstractions" $ do | ||||
| @ -157,12 +157,12 @@ parser = testGroup "Parser Tests" | ||||
|  | ||||
|   , testCase "Parse multiple arguments to lambda abstractions" $ do | ||||
|       let input  = "x = (\\a b : a)" | ||||
|           expect = SFunc "x" [] (SLambda ["a"] (SLambda ["b"] (SVar "a"))) | ||||
|           expect = SDef "x" [] (SLambda ["a"] (SLambda ["b"] (SVar "a"))) | ||||
|       parseSingle input @?= expect | ||||
|  | ||||
|   , testCase "Grouping T terms with parentheses in function application" $ do | ||||
|       let input  = "x = (\\a : a)\nx (t)" | ||||
|           expect = [SFunc "x" [] (SLambda ["a"] (SVar "a")),SApp (SVar "x") TLeaf] | ||||
|           expect = [SDef "x" [] (SLambda ["a"] (SVar "a")),SApp (SVar "x") TLeaf] | ||||
|       parseTricu input @?= expect | ||||
|  | ||||
|   , testCase "Comments 1" $ do | ||||
|  | ||||
							
								
								
									
										21
									
								
								test/size.tri
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								test/size.tri
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| compose = \f g x : f (g x) | ||||
|  | ||||
| succ = y (\self : | ||||
|   triage | ||||
|     1 | ||||
|     t | ||||
|     (triage | ||||
|       (t (t t)) | ||||
|       (\_ tail : t t (self tail)) | ||||
|       t)) | ||||
|  | ||||
| size = (\x : | ||||
|   (y (\self x : | ||||
|     compose succ | ||||
|       (triage | ||||
|         (\x : x) | ||||
|         self | ||||
|         (\x y : compose (self x) (self y)) | ||||
|         x)) x 0)) | ||||
|  | ||||
| size size | ||||
							
								
								
									
										1
									
								
								test/undefined.tri
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/undefined.tri
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| namedTerm = undefinedForTesting | ||||
		Reference in New Issue
	
	Block a user
	 James Eversole
						James Eversole