From 3ba4485fb8bd65e2f7feef9714ecd19c76f0a781 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 22 Jun 2023 11:12:18 -0500 Subject: [PATCH] updated: broken test cases --- tests/aoc-2020/day1.onyx | 2 +- tests/aoc-2020/day10.onyx | 2 +- tests/aoc-2020/day11.onyx | 2 +- tests/aoc-2020/day12.onyx | 2 +- tests/aoc-2020/day13.onyx | 2 +- tests/aoc-2020/day14.onyx | 2 +- tests/aoc-2020/day16.onyx | 2 +- tests/aoc-2020/day17.onyx | 2 +- tests/aoc-2020/day18.onyx | 2 +- tests/aoc-2020/day19.onyx | 2 +- tests/aoc-2020/day2.onyx | 2 +- tests/aoc-2020/day20.onyx | 2 +- tests/aoc-2020/day21.onyx | 2 +- tests/aoc-2020/day22.onyx | 2 +- tests/aoc-2020/day24.onyx | 2 +- tests/aoc-2020/day25.onyx | 2 +- tests/aoc-2020/day3.onyx | 2 +- tests/aoc-2020/day4.onyx | 2 +- tests/aoc-2020/day5.onyx | 2 +- tests/aoc-2020/day6.onyx | 2 +- tests/aoc-2020/day7.onyx | 2 +- tests/aoc-2020/day8.onyx | 2 +- tests/aoc-2020/day9.onyx | 2 +- tests/code_block_captures | 3 +++ tests/code_block_captures.onyx | 34 ++++++++++++++++++++++++++++++++++ 25 files changed, 60 insertions(+), 23 deletions(-) create mode 100644 tests/code_block_captures create mode 100644 tests/code_block_captures.onyx diff --git a/tests/aoc-2020/day1.onyx b/tests/aoc-2020/day1.onyx index 370afa65..54784b7b 100644 --- a/tests/aoc-2020/day1.onyx +++ b/tests/aoc-2020/day1.onyx @@ -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); diff --git a/tests/aoc-2020/day10.onyx b/tests/aoc-2020/day10.onyx index 026f6e69..0cf43692 100644 --- a/tests/aoc-2020/day10.onyx +++ b/tests/aoc-2020/day10.onyx @@ -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; diff --git a/tests/aoc-2020/day11.onyx b/tests/aoc-2020/day11.onyx index 0602689d..6210c986 100644 --- a/tests/aoc-2020/day11.onyx +++ b/tests/aoc-2020/day11.onyx @@ -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; diff --git a/tests/aoc-2020/day12.onyx b/tests/aoc-2020/day12.onyx index 1ba62948..81b9eea0 100644 --- a/tests/aoc-2020/day12.onyx +++ b/tests/aoc-2020/day12.onyx @@ -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; diff --git a/tests/aoc-2020/day13.onyx b/tests/aoc-2020/day13.onyx index 17fb7d55..b8d408a4 100644 --- a/tests/aoc-2020/day13.onyx +++ b/tests/aoc-2020/day13.onyx @@ -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; diff --git a/tests/aoc-2020/day14.onyx b/tests/aoc-2020/day14.onyx index 935d5221..7f7095a0 100644 --- a/tests/aoc-2020/day14.onyx +++ b/tests/aoc-2020/day14.onyx @@ -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; diff --git a/tests/aoc-2020/day16.onyx b/tests/aoc-2020/day16.onyx index feba6fbf..6ad35350 100644 --- a/tests/aoc-2020/day16.onyx +++ b/tests/aoc-2020/day16.onyx @@ -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; diff --git a/tests/aoc-2020/day17.onyx b/tests/aoc-2020/day17.onyx index 0b0efab3..370c0a0c 100644 --- a/tests/aoc-2020/day17.onyx +++ b/tests/aoc-2020/day17.onyx @@ -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; diff --git a/tests/aoc-2020/day18.onyx b/tests/aoc-2020/day18.onyx index b22f1441..4e2bff12 100644 --- a/tests/aoc-2020/day18.onyx +++ b/tests/aoc-2020/day18.onyx @@ -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; diff --git a/tests/aoc-2020/day19.onyx b/tests/aoc-2020/day19.onyx index 4aace287..be0ad640 100644 --- a/tests/aoc-2020/day19.onyx +++ b/tests/aoc-2020/day19.onyx @@ -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; diff --git a/tests/aoc-2020/day2.onyx b/tests/aoc-2020/day2.onyx index 9349d7f4..32a150fd 100644 --- a/tests/aoc-2020/day2.onyx +++ b/tests/aoc-2020/day2.onyx @@ -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); diff --git a/tests/aoc-2020/day20.onyx b/tests/aoc-2020/day20.onyx index de23bf83..80c9b5b3 100644 --- a/tests/aoc-2020/day20.onyx +++ b/tests/aoc-2020/day20.onyx @@ -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; diff --git a/tests/aoc-2020/day21.onyx b/tests/aoc-2020/day21.onyx index db9471e7..995c530c 100644 --- a/tests/aoc-2020/day21.onyx +++ b/tests/aoc-2020/day21.onyx @@ -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; diff --git a/tests/aoc-2020/day22.onyx b/tests/aoc-2020/day22.onyx index 8e646495..f5bd8ec8 100644 --- a/tests/aoc-2020/day22.onyx +++ b/tests/aoc-2020/day22.onyx @@ -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; diff --git a/tests/aoc-2020/day24.onyx b/tests/aoc-2020/day24.onyx index 9d183c7c..089b85ca 100644 --- a/tests/aoc-2020/day24.onyx +++ b/tests/aoc-2020/day24.onyx @@ -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); diff --git a/tests/aoc-2020/day25.onyx b/tests/aoc-2020/day25.onyx index 2f1dbe2f..207b4a30 100644 --- a/tests/aoc-2020/day25.onyx +++ b/tests/aoc-2020/day25.onyx @@ -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; diff --git a/tests/aoc-2020/day3.onyx b/tests/aoc-2020/day3.onyx index 177ad995..074241a0 100644 --- a/tests/aoc-2020/day3.onyx +++ b/tests/aoc-2020/day3.onyx @@ -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); diff --git a/tests/aoc-2020/day4.onyx b/tests/aoc-2020/day4.onyx index 06d1a0f5..5bcd8b3d 100644 --- a/tests/aoc-2020/day4.onyx +++ b/tests/aoc-2020/day4.onyx @@ -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 { diff --git a/tests/aoc-2020/day5.onyx b/tests/aoc-2020/day5.onyx index 1a5f1f18..80fa256b 100644 --- a/tests/aoc-2020/day5.onyx +++ b/tests/aoc-2020/day5.onyx @@ -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); diff --git a/tests/aoc-2020/day6.onyx b/tests/aoc-2020/day6.onyx index 45852969..ba4848ac 100644 --- a/tests/aoc-2020/day6.onyx +++ b/tests/aoc-2020/day6.onyx @@ -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 { diff --git a/tests/aoc-2020/day7.onyx b/tests/aoc-2020/day7.onyx index 1e50115c..ec14a31e 100644 --- a/tests/aoc-2020/day7.onyx +++ b/tests/aoc-2020/day7.onyx @@ -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; diff --git a/tests/aoc-2020/day8.onyx b/tests/aoc-2020/day8.onyx index cb0b4ff1..24d54f3c 100644 --- a/tests/aoc-2020/day8.onyx +++ b/tests/aoc-2020/day8.onyx @@ -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; diff --git a/tests/aoc-2020/day9.onyx b/tests/aoc-2020/day9.onyx index efb942de..0c73e274 100644 --- a/tests/aoc-2020/day9.onyx +++ b/tests/aoc-2020/day9.onyx @@ -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 index 00000000..f1a3f84c --- /dev/null +++ b/tests/code_block_captures @@ -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 index 00000000..3a317b5b --- /dev/null +++ b/tests/code_block_captures.onyx @@ -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); + } + } +} + + + + + -- 2.25.1