updated: broken test cases
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 22 Jun 2023 16:12:18 +0000 (11:12 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 22 Jun 2023 16:12:18 +0000 (11:12 -0500)
25 files changed:
tests/aoc-2020/day1.onyx
tests/aoc-2020/day10.onyx
tests/aoc-2020/day11.onyx
tests/aoc-2020/day12.onyx
tests/aoc-2020/day13.onyx
tests/aoc-2020/day14.onyx
tests/aoc-2020/day16.onyx
tests/aoc-2020/day17.onyx
tests/aoc-2020/day18.onyx
tests/aoc-2020/day19.onyx
tests/aoc-2020/day2.onyx
tests/aoc-2020/day20.onyx
tests/aoc-2020/day21.onyx
tests/aoc-2020/day22.onyx
tests/aoc-2020/day24.onyx
tests/aoc-2020/day25.onyx
tests/aoc-2020/day3.onyx
tests/aoc-2020/day4.onyx
tests/aoc-2020/day5.onyx
tests/aoc-2020/day6.onyx
tests/aoc-2020/day7.onyx
tests/aoc-2020/day8.onyx
tests/aoc-2020/day9.onyx
tests/code_block_captures [new file with mode: 0644]
tests/code_block_captures.onyx [new file with mode: 0644]

index 370afa65c4462e9edc61d2089f9d60181d0d60a7..54784b7b931f6a44fdd7a259583c4c385f73f330 100644 (file)
@@ -6,7 +6,7 @@ use core.array
 use core {printf}
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day1.txt";
+    contents := #file_contents "./input/day1.txt";
     reader, stream := io.reader_from_string(contents);
     defer cfree(stream);
 
index 026f6e69bb5aaf03a66957203f10a2589c4ea386..0cf43692f4f3faaac80b16fa8ff456f138db2bbf 100644 (file)
@@ -23,7 +23,7 @@ count_ending_paths :: (nums: [..] u32) -> u64 {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day10.txt";
+    contents := #file_contents "./input/day10.txt";
 
     file := contents;
 
index 0602689d7601ad956f93b51b3dc6d66cba82e95b..6210c986082089f6fe7dcde2788b802ac703c32e 100644 (file)
@@ -63,7 +63,7 @@ gos_iter :: (use gos: &GameOfSeats) -> bool {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day11.txt";
+    contents := #file_contents "./input/day11.txt";
 
     file := contents;
 
index 1ba6294807e3537c0d39a8c9555c0afca176f3e6..81b9eea004ae9721f6c0d7930b7ab13dc22d9334 100644 (file)
@@ -32,7 +32,7 @@ turn_around :: (ship: &Ship) {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day12.txt";
+    contents := #file_contents "./input/day12.txt";
 
     file := contents;
 
index 17fb7d55d1a9ccb1ce6f7673707abb91e9d01113..b8d408a4257e491669fe0a5933bfde90873c829f 100644 (file)
@@ -36,7 +36,7 @@ chinese_remainder_theorem :: (mods: [..] i64, rems: [..] i64) -> i64 {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day13.txt";
+    contents := #file_contents "./input/day13.txt";
 
     file := contents;
 
index 935d5221c8b4eda567a785da4390290b921eae17..7f7095a05c58281c557f8b224583c9347097138d 100644 (file)
@@ -73,7 +73,7 @@ bitmask_p2 :: (mask: Bitmask, val: u64) -> Iterator(u64) {
 }
 
 main :: (args: [] cstr) {
-       contents := #file_contents "./tests/aoc-2020/input/day14.txt";
+       contents := #file_contents "./input/day14.txt";
 
        file := contents;
 
index feba6fbf43cbe9dd17ef90cd9b8826d9b29a2ae9..6ad35350bca36e55fbd7c42e7d59594118bc80f0 100644 (file)
@@ -44,7 +44,7 @@ read_ticket_and_validate :: (file: &str, fields: [..] Field, ticket_store: [&] u
 }
 
 main :: (args: [] cstr) {
-       contents := #file_contents "./tests/aoc-2020/input/day16.txt";
+       contents := #file_contents "./input/day16.txt";
 
        file := contents;
 
index 0b0efab31ab58f5940faae02dabfe379118c6d17..370c0a0c288fa20918ad4dfd3db0ede37b7ef525 100644 (file)
@@ -51,7 +51,7 @@ get_neighbor_count :: (cubes: &Map(CubePos, CubeState), pos: CubePos) -> u32 {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day17.txt";
+    contents := #file_contents "./input/day17.txt";
 
     file := contents;
 
index b22f14419060220205cd8645e1c9fed6b8bd6644..4e2bff1255505ff078ad67978f76b27c42e69537 100644 (file)
@@ -66,7 +66,7 @@ parse_expression_mul :: (file: &str) -> u64 {
 }
 
 main :: (args: [] cstr) {
-       contents := #file_contents "./tests/aoc-2020/input/day18.txt";
+       contents := #file_contents "./input/day18.txt";
     file := contents;
 
        total: u64 = 0;
index 4aace287c480bdd1d5198e56e5beb6e676c1ef9c..be0ad640f9582c8d3b4270de52004bbb7442e37c 100644 (file)
@@ -105,7 +105,7 @@ cyk_algorithm :: (use grammar: &Grammar, input: str) -> bool {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day19.txt";
+    contents := #file_contents "./input/day19.txt";
 
     file := contents;
 
index 9349d7f4a2a2ab8a995d04b14f2b1c5785db2184..32a150fdd711d37378d0b300b84697b42d9db699 100644 (file)
@@ -5,7 +5,7 @@ package main
 use core {*}
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day2.txt";
+    contents := #file_contents "./input/day2.txt";
     reader, stream := io.reader_from_string(contents);
     defer cfree(stream);
 
index de23bf83e8ddc9c3ae3c108722601cb465e51391..80c9b5b3d7a29e61c4f0637aaf3380a709aa130d 100644 (file)
@@ -238,7 +238,7 @@ scan_for_monsters :: (forest: [&] u8, ori: TO, width: u32, height: u32) -> bool
 }
 
 main :: (args: [] cstr) {
-       contents := #file_contents "./tests/aoc-2020/input/day20.txt";
+       contents := #file_contents "./input/day20.txt";
 
        file := contents;       
 
index db9471e7e9f6180873c0cfdf071defabc186aecb..995c530c463ea9c9c96a8d9cefea386bd04d5319 100644 (file)
@@ -31,7 +31,7 @@ ingredient_map : map.Map(str, Ingredient);
 allergen_map   : map.Map(str, Allergen);
 
 main :: (args: [] cstr) {
-       contents := #file_contents "./tests/aoc-2020/input/day21.txt";
+       contents := #file_contents "./input/day21.txt";
 
        file := contents;
 
index 8e64649506282c027f1f0ba32d313378070ec5a4..f5bd8ec86a256cb20afae578653619b4a50a0fed 100644 (file)
@@ -100,7 +100,7 @@ recursive_combat :: (player1: &[..] u32, player2: &[..] u32) -> u32 {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day22.txt";
+    contents := #file_contents "./input/day22.txt";
 
     file := contents;
 
index 9d183c7c6340343329de972916fd8b8fcea39bc2..089b85ca7acc2720091078e78d5dc24f3373b099 100644 (file)
@@ -26,7 +26,7 @@ Cell :: struct {
 }
 
 main :: (args: [] cstr) {
-       contents := #file_contents "./tests/aoc-2020/input/day24.txt";
+       contents := #file_contents "./input/day24.txt";
 
     file_stream := io.buffer_stream_make(contents);
        file := io.reader_make(&file_stream);
index 2f1dbe2f80d26c545805c964e70e139b1c028cb8..207b4a3018df0ea49bd52601144052c9253053c7 100644 (file)
@@ -52,7 +52,7 @@ transform_subject :: (subject: u32, loop_size: u32) -> u32 {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day25.txt";
+    contents := #file_contents "./input/day25.txt";
 
     file := contents;
 
index 177ad995ee8f7135ee050f2afc66f0de01a62683..074241a04083894f64d18db0ce8685f4f75e7760 100644 (file)
@@ -16,7 +16,7 @@ line_interp_at :: (use li: LineInterp, t: i32) -> Point {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day3.txt";
+    contents := #file_contents "./input/day3.txt";
 
     forest := array.make(u8, 1024);
     defer array.free(&forest);
index 06d1a0f56e7ca06e4566029f8f8fdc29cc31764f..5bcd8b3db6e077711d72c17fc806005a84efe419 100644 (file)
@@ -30,7 +30,7 @@ process_passport :: (contents: &str) -> u32 {
 // This does not include part 2 because it is gross and
 // not worth the effort to implement it.
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day4.txt";
+    contents := #file_contents "./input/day4.txt";
 
     valid_passports := 0;
     while true {
index 1a5f1f185f71f3cdc8bfa414803582105fd385dc..80fa256bcdc72966d8c7e3b086a2b2efa68755e1 100644 (file)
@@ -3,7 +3,7 @@
 use core {*}
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day5.txt";
+    contents := #file_contents "./input/day5.txt";
 
     vals := array.make(u32);
     defer array.free(&vals);
index 458529694465ebfaa907911c481483b361844541..ba4848acb822a48945962b0ea26e6a72b9c3b4c8 100644 (file)
@@ -42,7 +42,7 @@ part_2 :: (contents: &str) -> u32 {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day6.txt";
+    contents := #file_contents "./input/day6.txt";
 
     unique_sum := 0;
     while true {
index 1e50115ca9c795fa468ea4127ce2a23ae35c7dad..ec14a31e59d272718d00cc4879a5218335a1d62e 100644 (file)
@@ -50,7 +50,7 @@ bg_get_node :: (use graph: &BagGraph, name: str) -> &BagNode {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day7.txt";
+    contents := #file_contents "./input/day7.txt";
 
     file := contents;
 
index cb0b4ff13252a3d4f8dea081faf120da42c3647b..24d54f3c9b3b8ba19ce5228ec63075c6922b4c00 100644 (file)
@@ -43,7 +43,7 @@ get_acc_value :: (instrs: [..] Instruction, ret_acc: &i32) -> bool {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day8.txt";
+    contents := #file_contents "./input/day8.txt";
 
     file := contents;
 
index efb942de5cda0a3a9e0c2bffa9f2f25d7b878c73..0c73e274aa3da1ffa7f49e084e26c479e8039f3d 100644 (file)
@@ -25,7 +25,7 @@ find_contiguous_subarray_with_sum :: (nums: [..] u64, sum: u64) -> (i32, i32) {
 }
 
 main :: (args: [] cstr) {
-    contents := #file_contents "./tests/aoc-2020/input/day9.txt";
+    contents := #file_contents "./input/day9.txt";
 
     file := contents;
 
diff --git a/tests/code_block_captures b/tests/code_block_captures
new file mode 100644 (file)
index 0000000..f1a3f84
--- /dev/null
@@ -0,0 +1,3 @@
+7
+foo => 123
+leet => 1337
diff --git a/tests/code_block_captures.onyx b/tests/code_block_captures.onyx
new file mode 100644 (file)
index 0000000..3a317b5
--- /dev/null
@@ -0,0 +1,34 @@
+use core {*}
+
+main :: () {
+    arr := .[2, 3, 5, 7, 11];
+
+    x := 5;
+
+    val := slice.find_opt(arr, [n](n > x));
+    val->with([captured_name] {
+        println(captured_name);
+    });
+
+    m := Map.literal(str, i32, .[
+        .{ "foo", 123 },
+        .{ "leet", 1337 }
+    ]);
+
+    Map.each(m, [k, v] {
+        printf("{} => {}\n", k, v);
+    });
+}
+
+#inject Map {
+    each :: macro (m: $M, body: Code) {
+        for& m.entries {
+            #unquote body(it.key, it.value);
+        }
+    }
+}
+
+
+
+
+