diff options
| -rw-r--r-- | gleam/test/ocda_lib_test.gleam | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/gleam/test/ocda_lib_test.gleam b/gleam/test/ocda_lib_test.gleam index 6d4907c..692150a 100644 --- a/gleam/test/ocda_lib_test.gleam +++ b/gleam/test/ocda_lib_test.gleam @@ -1,3 +1,4 @@ +import gleam/dict import gleam/list import gleam/string import gleeunit @@ -26,13 +27,13 @@ const minimal = "% SiSU Document Abstraction v2.0 @body { [1] heading :A the_title - .part: frontmatter - .sha256: DEAD +.part: frontmatter +.sha256: DEAD | An Example [2] para - .part: body - .parent: 1 +.part: body +.parent: 1 | First line | | Third line, after a blank one @@ -102,3 +103,25 @@ pub fn dump_test() { text |> string.contains(contain: "bullet") |> should.be_false } + +/// A property is read, which the fixture above had to be corrected to show: +/// a property line is `.name: value` at the start of the line, and an +/// indented one is a line of no known shape. The fixture indented them, so +/// every property in it was being counted as malformed and the tests around +/// it passed for the wrong reason. +pub fn property_test() { + let doc = load_ssp.parse(minimal) + case model.section(doc, "body") { + [first, second] -> { + first.part |> should.equal("frontmatter") + first.sha256 |> should.equal("DEAD") + second.parent_ocn |> should.equal(1) + } + _ -> should.fail() + } + // and nothing in the fixture is malformed any more + dict_size(doc.unknown.line) |> should.equal(0) +} + +@external(erlang, "maps", "size") +fn dict_size(d: dict.Dict(a, b)) -> Int |
