Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
bcpeinhardt committed Aug 31, 2024
1 parent ace04ca commit 023bc30
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 42 deletions.
File renamed without changes.
43 changes: 4 additions & 39 deletions squared_away_lang/birdie_snapshots/basic_label_usage.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
])
A1:
B1: 4
B2: 4
24 changes: 21 additions & 3 deletions squared_away_lang/test/squared_away_lang_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 = {
Expand All @@ -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")
}

0 comments on commit 023bc30

Please sign in to comment.