diff --git a/squared_away/README.md b/README.md similarity index 100% rename from squared_away/README.md rename to README.md diff --git a/squared_away_lang/birdie_snapshots/basic_label_usage.accepted b/squared_away_lang/birdie_snapshots/basic_label_usage.accepted index 1231053..cd5a193 100644 --- a/squared_away_lang/birdie_snapshots/basic_label_usage.accepted +++ b/squared_away_lang/birdie_snapshots/basic_label_usage.accepted @@ -2,43 +2,8 @@ version: 1.2.1 title: Basic Label Usage file: ./test/squared_away_lang_test.gleam -test_name: hello_world_test +test_name: basic_label_usage_test --- -dict.from_list([ - #("A1", Ok(Empty)), - #("A2", Ok(Integer(4))), - #("A3", Ok(Empty)), - #("A4", Ok(Empty)), - #("A5", Ok(Empty)), - #("A6", Ok(Empty)), - #("B1", Ok(Empty)), - #("B2", Ok(Empty)), - #("B3", Ok(Empty)), - #("B4", Ok(Empty)), - #("B5", Ok(Empty)), - #("B6", Ok(Empty)), - #("C1", Ok(Empty)), - #("C2", Ok(Empty)), - #("C3", Ok(Empty)), - #("C4", Ok(Empty)), - #("C5", Ok(Empty)), - #("C6", Ok(Empty)), - #("D1", Ok(Empty)), - #("D2", Ok(Empty)), - #("D3", Ok(Empty)), - #("D4", Ok(Empty)), - #("D5", Ok(Empty)), - #("D6", Ok(Empty)), - #("E1", Ok(Empty)), - #("E2", Ok(Empty)), - #("E3", Ok(Empty)), - #("E4", Ok(Empty)), - #("E5", Ok(Empty)), - #("E6", Ok(Empty)), - #("F1", Ok(Empty)), - #("F2", Ok(Empty)), - #("F3", Ok(Empty)), - #("F4", Ok(Empty)), - #("F5", Ok(Empty)), - #("F6", Ok(Empty)), -]) \ No newline at end of file +A1: +B1: 4 +B2: 4 diff --git a/squared_away_lang/test/squared_away_lang_test.gleam b/squared_away_lang/test/squared_away_lang_test.gleam index 1c331fb..fecaa41 100644 --- a/squared_away_lang/test/squared_away_lang_test.gleam +++ b/squared_away_lang/test/squared_away_lang_test.gleam @@ -6,6 +6,8 @@ import gleam/string import gleeunit import pprint import squared_away_lang as lang +import squared_away_lang/error +import squared_away_lang/interpreter/value pub fn main() { gleeunit.main() @@ -24,12 +26,27 @@ fn empty_grid() -> dict.Dict(String, String) { }) } +fn print_grid_values( + grid: dict.Dict(String, Result(value.Value, error.CompileError)), + keys: List(String), +) -> String { + use acc, key, val <- dict.fold(grid, "") + case list.contains(keys, key) { + False -> acc + True -> + case val { + Ok(v) -> acc <> key <> ": " <> value.value_to_string(v) <> "\n" + Error(e) -> acc <> key <> ": " <> string.inspect(e) + } + } +} + // gleeunit test functions end in `_test` -pub fn hello_world_test() { +pub fn basic_label_usage_test() { let grid = empty_grid() |> dict.insert("A1", "X") - |> dict.insert("A2", "=4") + |> dict.insert("B1", "=4") |> dict.insert("B2", "=X") let res = { @@ -39,5 +56,6 @@ pub fn hello_world_test() { lang.interpret_grid(typechecked) } - pprint.format(res) |> birdie.snap(title: "Basic Label Usage") + print_grid_values(res, ["A1", "B1", "B2"]) + |> birdie.snap(title: "Basic Label Usage") }