ability to run code and check output in tests

This commit is contained in:
2024-12-28 13:19:15 -08:00
parent 95f90c8698
commit a6e68ac2a2
62 changed files with 459 additions and 31 deletions

1
tests/Prelude.newt Symbolic link
View File

@@ -0,0 +1 @@
../newt/Prelude.newt

1
tests/SortedMap.newt Symbolic link
View File

@@ -0,0 +1 @@
../newt/SortedMap.newt

21
tests/TestMap.newt Normal file
View File

@@ -0,0 +1,21 @@
module TestMap
import SortedMap
main : IO Unit
main = do
let m = updateMap 2 0 EmptyMap
debugLog $ toList m
debugLog $ toList $ deleteMap 2 m
debugLog $ toList $ updateMap 2 3 m
debugLog $ toList $ updateMap 1 3 m
let x = 4 :: 1 :: 5 :: 7 :: 2 :: 9 :: 3 :: 10 :: 6 :: 0 :: 11 :: 12 :: 13 :: 20 :: 14 :: 16 :: 17 :: 8 :: Nil
let m = foldl (\ m x => updateMap x MkUnit m) EmptyMap x
debugLog $ toList m
debugLog $ leftMost m
debugLog $ rightMost m
_ <- for x $ \ n => do
putStrLn $ "ohne " ++ show n
-- debugLog $ m
debugLog $ map fst $ toList $ deleteMap n m
putStrLn ""

44
tests/TestMap.newt.golden Normal file
View File

@@ -0,0 +1,44 @@
[(2, 0)]
[]
[(2, 3)]
[(1, 3), (2, 0)]
[(0, (MkUnit)), (1, (MkUnit)), (2, (MkUnit)), (3, (MkUnit)), (4, (MkUnit)), (5, (MkUnit)), (6, (MkUnit)), (7, (MkUnit)), (8, (MkUnit)), (9, (MkUnit)), (10, (MkUnit)), (11, (MkUnit)), (12, (MkUnit)), (13, (MkUnit)), (14, (MkUnit)), (16, (MkUnit)), (17, (MkUnit)), (20, (MkUnit))]
(Just _ (0, (MkUnit)))
(Just _ (20, (MkUnit)))
ohne 4
[0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 1
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 5
[0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 7
[0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 2
[0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 9
[0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 3
[0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 10
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 20]
ohne 6
[0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 0
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20]
ohne 11
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 16, 17, 20]
ohne 12
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 16, 17, 20]
ohne 13
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 17, 20]
ohne 20
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17]
ohne 14
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16, 17, 20]
ohne 16
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 20]
ohne 17
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 20]
ohne 8
[0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 16, 17, 20]

View File

@@ -1,24 +0,0 @@
module Prelude
data Nat : U where
Z : Nat
S : Nat -> Nat
data Maybe : U -> U where
Just : {a : U} -> a -> Maybe a
Nothing : {a : U} -> Maybe a
data Either : U -> U -> U where
Left : {a b : U} -> a -> Either a b
Right : {a b : U} -> b -> Either a b
data List : U -> U where
Nil : {a : U} -> List a
Cons : {a : U} -> a -> List a -> List a
-- Currently if I say _::_ = Cons, it gets curried
infixr 7 _::_
_::_ : {a : U} -> a -> List a -> List a
_::_ x xs = Cons x xs