ability to run code and check output in tests
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,6 +2,7 @@ build/
|
|||||||
*.*~ATTIC
|
*.*~ATTIC
|
||||||
\#*
|
\#*
|
||||||
*~
|
*~
|
||||||
|
*.swp
|
||||||
*.log
|
*.log
|
||||||
*.agda
|
*.agda
|
||||||
*.agdai
|
*.agdai
|
||||||
@@ -9,3 +10,4 @@ build/
|
|||||||
input.txt
|
input.txt
|
||||||
node_modules
|
node_modules
|
||||||
mkday.py
|
mkday.py
|
||||||
|
tmp
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -16,6 +16,9 @@ build/exec/newt.min.js: ${SRCS}
|
|||||||
test: build/exec/newt
|
test: build/exec/newt
|
||||||
scripts/test
|
scripts/test
|
||||||
|
|
||||||
|
aoctest: build/exec/newt
|
||||||
|
scripts/aoc
|
||||||
|
|
||||||
vscode:
|
vscode:
|
||||||
cd newt-vscode && vsce package && code --install-extension *.vsix
|
cd newt-vscode && vsce package && code --install-extension *.vsix
|
||||||
|
|
||||||
|
|||||||
6
aoc2024/Day1.newt.golden
Normal file
6
aoc2024/Day1.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day1/eg.txt
|
||||||
|
part1 11
|
||||||
|
part2 31
|
||||||
|
aoc2024/day1/input.txt
|
||||||
|
part1 1197984
|
||||||
|
part2 23387399
|
||||||
18
aoc2024/Day10.newt.golden
Normal file
18
aoc2024/Day10.newt.golden
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
aoc2024/day10/eg.txt
|
||||||
|
part1 1
|
||||||
|
part2 16
|
||||||
|
aoc2024/day10/eg2.txt
|
||||||
|
part1 2
|
||||||
|
part2 2
|
||||||
|
aoc2024/day10/eg3.txt
|
||||||
|
part1 4
|
||||||
|
part2 13
|
||||||
|
aoc2024/day10/eg4.txt
|
||||||
|
part1 3
|
||||||
|
part2 3
|
||||||
|
aoc2024/day10/eg5.txt
|
||||||
|
part1 36
|
||||||
|
part2 81
|
||||||
|
aoc2024/day10/input.txt
|
||||||
|
part1 510
|
||||||
|
part2 1058
|
||||||
6
aoc2024/Day11.newt.golden
Normal file
6
aoc2024/Day11.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day11/eg.txt
|
||||||
|
part1 55312
|
||||||
|
part2 65601038650482
|
||||||
|
aoc2024/day11/input.txt
|
||||||
|
part1 186175
|
||||||
|
part2 220566831337810
|
||||||
6
aoc2024/Day11b.newt.golden
Normal file
6
aoc2024/Day11b.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day11/eg.txt
|
||||||
|
part1 55312
|
||||||
|
part2 65601038650482
|
||||||
|
aoc2024/day11/input.txt
|
||||||
|
part1 186175
|
||||||
|
part2 220566831337810
|
||||||
9
aoc2024/Day12.newt.golden
Normal file
9
aoc2024/Day12.newt.golden
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
aoc2024/day12/eg.txt
|
||||||
|
part1 140
|
||||||
|
part2 80
|
||||||
|
aoc2024/day12/eg2.txt
|
||||||
|
part1 772
|
||||||
|
part2 436
|
||||||
|
aoc2024/day12/input.txt
|
||||||
|
part1 1450816
|
||||||
|
part2 865662
|
||||||
6
aoc2024/Day13.newt.golden
Normal file
6
aoc2024/Day13.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day13/eg.txt
|
||||||
|
part1 480
|
||||||
|
part2 875318608908
|
||||||
|
aoc2024/day13/input.txt
|
||||||
|
part1 28059
|
||||||
|
part2 102255878088512
|
||||||
109
aoc2024/Day14.newt.golden
Normal file
109
aoc2024/Day14.newt.golden
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
aoc2024/day14/input.txt
|
||||||
|
(121, 119, 119, 132)
|
||||||
|
part1 226179492
|
||||||
|
500
|
||||||
|
7502
|
||||||
|
..................................*.*................................................................
|
||||||
|
.....................................................................................................
|
||||||
|
...................................*..........................*......................................
|
||||||
|
...............*..............................................*..................................*...
|
||||||
|
.....*.......................*..............................*........................................
|
||||||
|
.....................................................................................................
|
||||||
|
.....................................................................................................
|
||||||
|
.....................................................................................................
|
||||||
|
.............*.........................*.............................................................
|
||||||
|
........................................................*............................................
|
||||||
|
.....................................................................................................
|
||||||
|
.....................................................................................................
|
||||||
|
......................................................................................*..............
|
||||||
|
........................................................*.*..........................................
|
||||||
|
....................................*................................................................
|
||||||
|
.....................................................................................................
|
||||||
|
....................................................................*................................
|
||||||
|
.................*...................................................................................
|
||||||
|
....................................*...............*******************************..................
|
||||||
|
..................*..................*............*.*.............................*..................
|
||||||
|
.......*............................................*.............................*..**..............
|
||||||
|
....................................................*.............................*..................
|
||||||
|
.......*........................*...................*.............................*..................
|
||||||
|
....................................................*..............*..............*..............*...
|
||||||
|
.................*..................................*.............***.............*..................
|
||||||
|
........*...........................................*............*****............*...*..............
|
||||||
|
....................................................*...........*******...........*..................
|
||||||
|
....................................................*..........*********..........*...*..............
|
||||||
|
....................................................*............*****............*..................
|
||||||
|
....................................................*...........*******...........*.......*..........
|
||||||
|
.....................*..............................*..........*********..........*.................*
|
||||||
|
....................................................*.........***********.........*..................
|
||||||
|
......*.............................................*........*************........*..................
|
||||||
|
............................................*.......*..........*********..........*..................
|
||||||
|
....................................................*.........***********.........*..................
|
||||||
|
....................................................*........*************........*..................
|
||||||
|
....................................................*.......***************.......*..................
|
||||||
|
....................................................*......*****************......*..................
|
||||||
|
....................................................*........*************........*..................
|
||||||
|
....................................................*.......***************.......*..................
|
||||||
|
....................................................*......*****************......*..................
|
||||||
|
...........*..........................*.............*.....*******************.....*..................
|
||||||
|
.......*...*........................................*....*********************....*..................
|
||||||
|
....................................................*.............***.............*..................
|
||||||
|
.........*......................................*...*.............***.............*..................
|
||||||
|
...................................*................*.............***.............*..................
|
||||||
|
....................................................*.............................*.......*..........
|
||||||
|
......*...*.........................................*.............................*..................
|
||||||
|
.....................*..............................*.............................*..................
|
||||||
|
.............................*......................*.............................*..................
|
||||||
|
.................................*.........*........*******************************..................
|
||||||
|
............*....................................*..........................................*....*...
|
||||||
|
.........*........*...........................................*......................*...............
|
||||||
|
...................................................*.*..............*................................
|
||||||
|
.....................................................................................................
|
||||||
|
....*..............................................*..........................*......................
|
||||||
|
....................................*..............................*.................................
|
||||||
|
..................*..................................................................................
|
||||||
|
....*...............................................*..............*.................*...............
|
||||||
|
..*.*....................................*................*..........................................
|
||||||
|
................*..............*...............................*.....................................
|
||||||
|
......*..........*..............*.......................................*............................
|
||||||
|
......................................................*..............................................
|
||||||
|
.................*............................................................*......................
|
||||||
|
.....................................................................................................
|
||||||
|
..................................................................................*...*..............
|
||||||
|
.....................................................................................................
|
||||||
|
....................*................................................................*...............
|
||||||
|
.....................................................................................................
|
||||||
|
.....................................................................................................
|
||||||
|
............*...........................................................................*............
|
||||||
|
.....................................................................................................
|
||||||
|
.......*...*.......................................................................*.................
|
||||||
|
........................................*.......................................................*....
|
||||||
|
...........*........*............*..................................................................*
|
||||||
|
................................................................................................*....
|
||||||
|
...............*...............................*.....................................................
|
||||||
|
..*......................................................*..................*.......................*
|
||||||
|
.........*...........................................................................................
|
||||||
|
*.....................*.........................................................................*....
|
||||||
|
...............................................................................*.....................
|
||||||
|
.....................................................................................................
|
||||||
|
........................................................*..........................*.................
|
||||||
|
.......................................*.............................................................
|
||||||
|
.....................................................................................................
|
||||||
|
*..................................*.................................................................
|
||||||
|
.......................................................*.............................................
|
||||||
|
.......................................*.....................*.......................................
|
||||||
|
..............*.*.....................................*......................................*.......
|
||||||
|
.....................................................................................................
|
||||||
|
.....................................................................................................
|
||||||
|
................................*....................................................................
|
||||||
|
......*..............................................................................................
|
||||||
|
.......................*....*........................................................................
|
||||||
|
..........................*...................................................*...........*..........
|
||||||
|
.......*...................................................*...................*.*...................
|
||||||
|
.......................*.............................................................................
|
||||||
|
..........*...........................................*..............................................
|
||||||
|
...................................................................*.................................
|
||||||
|
......................................*............................*.................................
|
||||||
|
..........................................*............*....................*........................
|
||||||
|
.....................................................................................................
|
||||||
|
...*.................................................................................................
|
||||||
|
|
||||||
6
aoc2024/Day15.newt.golden
Normal file
6
aoc2024/Day15.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day15/eg.txt
|
||||||
|
part1 10092
|
||||||
|
part2 9021
|
||||||
|
aoc2024/day15/input.txt
|
||||||
|
part1 1406628
|
||||||
|
part2 1432781
|
||||||
9
aoc2024/Day16.newt.golden
Normal file
9
aoc2024/Day16.newt.golden
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
aoc2024/day16/eg.txt
|
||||||
|
part1 7036
|
||||||
|
part2 45
|
||||||
|
aoc2024/day16/eg2.txt
|
||||||
|
part1 11048
|
||||||
|
part2 64
|
||||||
|
aoc2024/day16/input.txt
|
||||||
|
part1 90460
|
||||||
|
part2 575
|
||||||
11
aoc2024/Day17.newt.golden
Normal file
11
aoc2024/Day17.newt.golden
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
aoc2024/day17/eg.txt
|
||||||
|
part1 4,6,3,5,6,3,5,2,1,0
|
||||||
|
fail
|
||||||
|
aoc2024/day17/eg2.txt
|
||||||
|
part1 5,7,3,0
|
||||||
|
part2 117440
|
||||||
|
|
||||||
|
aoc2024/day17/input.txt
|
||||||
|
part1 5,0,3,5,7,6,1,5,4
|
||||||
|
part2 164516454365621
|
||||||
|
|
||||||
10
aoc2024/Day18.newt.golden
Normal file
10
aoc2024/Day18.newt.golden
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
aoc2024/day18/eg.txt
|
||||||
|
12
|
||||||
|
part1 22
|
||||||
|
best 20
|
||||||
|
part2 6,1
|
||||||
|
aoc2024/day18/input.txt
|
||||||
|
1024
|
||||||
|
part1 260
|
||||||
|
best 2881
|
||||||
|
part2 24,48
|
||||||
6
aoc2024/Day19.newt.golden
Normal file
6
aoc2024/Day19.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day19/eg.txt
|
||||||
|
part1 6
|
||||||
|
part2 16
|
||||||
|
aoc2024/day19/input.txt
|
||||||
|
part1 371
|
||||||
|
part2 650354687260341
|
||||||
6
aoc2024/Day2.newt.golden
Normal file
6
aoc2024/Day2.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day2/eg.txt
|
||||||
|
part1 2
|
||||||
|
part2 4
|
||||||
|
aoc2024/day2/input.txt
|
||||||
|
part1 524
|
||||||
|
part2 569
|
||||||
8
aoc2024/Day20.newt.golden
Normal file
8
aoc2024/Day20.newt.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aoc2024/day20/eg.txt
|
||||||
|
base 84
|
||||||
|
part1 1
|
||||||
|
part2 285
|
||||||
|
aoc2024/day20/input.txt
|
||||||
|
base 9440
|
||||||
|
part1 1332
|
||||||
|
part2 987695
|
||||||
8
aoc2024/Day20b.newt.golden
Normal file
8
aoc2024/Day20b.newt.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aoc2024/day20/eg.txt
|
||||||
|
base 84
|
||||||
|
part1 1
|
||||||
|
part2 285
|
||||||
|
aoc2024/day20/input.txt
|
||||||
|
base 9440
|
||||||
|
part1 1332
|
||||||
|
part2 987695
|
||||||
8
aoc2024/Day21.newt.golden
Normal file
8
aoc2024/Day21.newt.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aoc2024/day21/eg.txt
|
||||||
|
[("0", 3, 1), ("1", 2, 0), ("2", 2, 1), ("3", 2, 2), ("4", 1, 0), ("5", 1, 1), ("6", 1, 2), ("7", 0, 0), ("8", 0, 1), ("9", 0, 2), ("A", 3, 2)]
|
||||||
|
part1 126384
|
||||||
|
part2 154115708116294
|
||||||
|
aoc2024/day21/input.txt
|
||||||
|
[("0", 3, 1), ("1", 2, 0), ("2", 2, 1), ("3", 2, 2), ("4", 1, 0), ("5", 1, 1), ("6", 1, 2), ("7", 0, 0), ("8", 0, 1), ("9", 0, 2), ("A", 3, 2)]
|
||||||
|
part1 248108
|
||||||
|
part2 303836969158972
|
||||||
8
aoc2024/Day21monad.newt.golden
Normal file
8
aoc2024/Day21monad.newt.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aoc2024/day21/eg.txt
|
||||||
|
[("0", 3, 1), ("1", 2, 0), ("2", 2, 1), ("3", 2, 2), ("4", 1, 0), ("5", 1, 1), ("6", 1, 2), ("7", 0, 0), ("8", 0, 1), ("9", 0, 2), ("A", 3, 2)]
|
||||||
|
part1 126384
|
||||||
|
part2 154115708116294
|
||||||
|
aoc2024/day21/input.txt
|
||||||
|
[("0", 3, 1), ("1", 2, 0), ("2", 2, 1), ("3", 2, 2), ("4", 1, 0), ("5", 1, 1), ("6", 1, 2), ("7", 0, 0), ("8", 0, 1), ("9", 0, 2), ("A", 3, 2)]
|
||||||
|
part1 248108
|
||||||
|
part2 303836969158972
|
||||||
6
aoc2024/Day22.newt.golden
Normal file
6
aoc2024/Day22.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day22/eg2.txt
|
||||||
|
part1 37990510
|
||||||
|
part2 23
|
||||||
|
aoc2024/day22/input.txt
|
||||||
|
part1 13429191512
|
||||||
|
part2 1582
|
||||||
6
aoc2024/Day22b.newt.golden
Normal file
6
aoc2024/Day22b.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day22/eg2.txt
|
||||||
|
part1 37990510
|
||||||
|
part2 23
|
||||||
|
aoc2024/day22/input.txt
|
||||||
|
part1 13429191512
|
||||||
|
part2 1582
|
||||||
10
aoc2024/Day23.newt.golden
Normal file
10
aoc2024/Day23.newt.golden
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
aoc2024/day23/eg.txt
|
||||||
|
32 pairs
|
||||||
|
64 dpairs
|
||||||
|
part1 7
|
||||||
|
part2 co,de,ka,ta
|
||||||
|
aoc2024/day23/input.txt
|
||||||
|
3380 pairs
|
||||||
|
6760 dpairs
|
||||||
|
part1 1170
|
||||||
|
part2 bo,dd,eq,ik,lo,lu,ph,ro,rr,rw,uo,wx,yg
|
||||||
@@ -177,7 +177,6 @@ run : String -> IO Unit
|
|||||||
run fn = do
|
run fn = do
|
||||||
putStrLn fn
|
putStrLn fn
|
||||||
text <- readFile fn
|
text <- readFile fn
|
||||||
putStrLn text
|
|
||||||
let (Right (wires, gates)) = parseFile text | Left msg => putStrLn $ "fail: " ++ msg
|
let (Right (wires, gates)) = parseFile text | Left msg => putStrLn $ "fail: " ++ msg
|
||||||
let state = foldMap const EmptyMap wires
|
let state = foldMap const EmptyMap wires
|
||||||
let gateMap = foldMap const EmptyMap $ map (\ gate => (out gate, gate)) gates
|
let gateMap = foldMap const EmptyMap $ map (\ gate => (out gate, gate)) gates
|
||||||
|
|||||||
8
aoc2024/Day24.newt.golden
Normal file
8
aoc2024/Day24.newt.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aoc2024/day24/input.txt
|
||||||
|
part1 51745744348272
|
||||||
|
SWAP z18 and hmt
|
||||||
|
SWAP bfq and z27
|
||||||
|
SWAP z31 and hkh
|
||||||
|
SWAP fjp and bng
|
||||||
|
part2 bfq,bng,fjp,hkh,hmt,z18,z27,z31
|
||||||
|
|
||||||
@@ -55,7 +55,6 @@ run : String -> IO Unit
|
|||||||
run fn = do
|
run fn = do
|
||||||
putStrLn fn
|
putStrLn fn
|
||||||
text <- readFile fn
|
text <- readFile fn
|
||||||
putStrLn text
|
|
||||||
let chunks = parseFile text
|
let chunks = parseFile text
|
||||||
let (locks,keys) = splitKeys chunks Nil Nil
|
let (locks,keys) = splitKeys chunks Nil Nil
|
||||||
debugLog (length locks, length keys)
|
debugLog (length locks, length keys)
|
||||||
|
|||||||
6
aoc2024/Day25.newt.golden
Normal file
6
aoc2024/Day25.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day25/eg.txt
|
||||||
|
(2, 3)
|
||||||
|
part1 3
|
||||||
|
aoc2024/day25/input.txt
|
||||||
|
(250, 250)
|
||||||
|
part1 3397
|
||||||
6
aoc2024/Day3.newt.golden
Normal file
6
aoc2024/Day3.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day3/eg.txt
|
||||||
|
part1 161
|
||||||
|
part2 161
|
||||||
|
aoc2024/day3/input.txt
|
||||||
|
part1 164730528
|
||||||
|
part2 70478672
|
||||||
6
aoc2024/Day4.newt.golden
Normal file
6
aoc2024/Day4.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day4/eg.txt
|
||||||
|
part1 18
|
||||||
|
part2 9
|
||||||
|
aoc2024/day4/input.txt
|
||||||
|
part1 2591
|
||||||
|
part2 1880
|
||||||
8
aoc2024/Day5.newt.golden
Normal file
8
aoc2024/Day5.newt.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aoc2024/day5/eg.txt
|
||||||
|
part1 143
|
||||||
|
3
|
||||||
|
part2 123
|
||||||
|
aoc2024/day5/input.txt
|
||||||
|
part1 5268
|
||||||
|
107
|
||||||
|
part2 5799
|
||||||
8
aoc2024/Day6.newt.golden
Normal file
8
aoc2024/Day6.newt.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aoc2024/day6/eg.txt
|
||||||
|
part1 41
|
||||||
|
part2 6
|
||||||
|
100
|
||||||
|
aoc2024/day6/input.txt
|
||||||
|
part1 5331
|
||||||
|
part2 1812
|
||||||
|
16900
|
||||||
6
aoc2024/Day7.newt.golden
Normal file
6
aoc2024/Day7.newt.golden
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
aoc2024/day7/eg.txt
|
||||||
|
part1 3749
|
||||||
|
part2 11387
|
||||||
|
aoc2024/day7/input.txt
|
||||||
|
part1 21572148763543
|
||||||
|
part2 581941094529163
|
||||||
10
aoc2024/Day8.newt.golden
Normal file
10
aoc2024/Day8.newt.golden
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
aoc2024/day8/eg.txt
|
||||||
|
maxrow 11
|
||||||
|
maxcol 11
|
||||||
|
part1 14
|
||||||
|
part2 34
|
||||||
|
aoc2024/day8/input.txt
|
||||||
|
maxrow 49
|
||||||
|
maxcol 49
|
||||||
|
part1 364
|
||||||
|
part2 1231
|
||||||
8
aoc2024/Day9.newt.golden
Normal file
8
aoc2024/Day9.newt.golden
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
aoc2024/day9/eg.txt
|
||||||
|
10 files
|
||||||
|
part1 1928
|
||||||
|
part2 2858
|
||||||
|
aoc2024/day9/input.txt
|
||||||
|
10000 files
|
||||||
|
part1 6283404590840
|
||||||
|
part2 6304576012713
|
||||||
34
scripts/aoc
Executable file
34
scripts/aoc
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
mkdir -p tmp
|
||||||
|
echo "Test AoC 2024 solutions"
|
||||||
|
total=0
|
||||||
|
failed=0
|
||||||
|
for fn in aoc2024/Day*.newt; do
|
||||||
|
total=$((total + 1))
|
||||||
|
echo Test $fn
|
||||||
|
bn=$(basename $fn)
|
||||||
|
./build/exec/newt $fn -o out.js > tmp/${bn}.compile
|
||||||
|
if [ $? != "0" ]; then
|
||||||
|
echo Compile failed for $fn
|
||||||
|
failed=$((failed + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# if there is a golden file, run the code and compare output
|
||||||
|
if [ -f ${fn}.golden ]; then
|
||||||
|
bun run out.js > tmp/${bn}.out
|
||||||
|
if [ $? != "0" ]; then
|
||||||
|
echo Run failed for $fn
|
||||||
|
failed=$((failed + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! diff -q tmp/${bn}.out ${fn}.golden; then
|
||||||
|
echo "Output mismatch for $fn"
|
||||||
|
failed=$((failed + 1))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Total tests: $total"
|
||||||
|
echo "Failed tests: $failed"
|
||||||
|
|
||||||
|
|
||||||
30
scripts/test
30
scripts/test
@@ -1,11 +1,31 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
SAMPLES=$(find playground/samples -name "*.newt")
|
SAMPLES=$(find playground/samples -name "*.newt")
|
||||||
for i in tests/black/*.newt $SAMPLES aoc2024/*.newt; do
|
total=0
|
||||||
./build/exec/newt $i
|
failed=0
|
||||||
|
for fn in tests/*.newt ; do
|
||||||
|
total=$((total + 1))
|
||||||
|
echo Test $fn
|
||||||
|
bn=$(basename $fn)
|
||||||
|
./build/exec/newt $fn -o out.js > tmp/${bn}.compile
|
||||||
if [ $? != "0" ]; then
|
if [ $? != "0" ]; then
|
||||||
echo FAIL $i
|
echo Compile failed for $fn
|
||||||
exit -1
|
failed=$((failed + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# if there is a golden file, run the code and compare output
|
||||||
|
if [ -f ${fn}.golden ]; then
|
||||||
|
bun run out.js > tmp/${bn}.out
|
||||||
|
if [ $? != "0" ]; then
|
||||||
|
echo Run failed for $fn
|
||||||
|
failed=$((failed + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! diff -q tmp/${bn}.out ${fn}.golden; then
|
||||||
|
echo "Output mismatch for $fn"
|
||||||
|
failed=$((failed + 1))
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo $?
|
|
||||||
done
|
done
|
||||||
|
echo "Total tests: $total"
|
||||||
|
echo "Failed tests: $failed"
|
||||||
|
|
||||||
|
|||||||
1
tests/Prelude.newt
Symbolic link
1
tests/Prelude.newt
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../newt/Prelude.newt
|
||||||
1
tests/SortedMap.newt
Symbolic link
1
tests/SortedMap.newt
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../newt/SortedMap.newt
|
||||||
21
tests/TestMap.newt
Normal file
21
tests/TestMap.newt
Normal 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
44
tests/TestMap.newt.golden
Normal 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]
|
||||||
|
|
||||||
@@ -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
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user