Skip to content

Commit

Permalink
element types: adjust tests, use 'found' instead of 'got'
Browse files Browse the repository at this point in the history
  • Loading branch information
PgBiel committed Jan 13, 2025
1 parent 2b470bd commit 6fdf9f7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/types/base.typ
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}
}

"expected element " + name + ", got " + got
"expected element " + name + ", found " + got
}
)

Expand All @@ -103,7 +103,7 @@
}
}

"expected native element " + repr(func) + ", got " + got
"expected native element " + repr(func) + ", found " + got
}
)
}
Expand Down
16 changes: 10 additions & 6 deletions test/unit/types/elements/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@
prefix: ""
)

#assert.eq(cast([a *abc*], wock), (false, "expected element wock, got sequence"))
#assert.eq(cast([abc], wock), (false, "expected element wock, got text"))
#assert.eq(cast([a *abc*], wock), (false, "expected element wock, found sequence"))
#assert.eq(cast([abc], wock), (false, "expected element wock, found text"))
#assert.eq(cast(wock(), wock), (true, wock()))
#assert.eq(cast(wock(color: black), wock), (true, wock(color: black)))
#assert.eq(cast(dock(), wock), (false, "expected element wock, got dock"))
#assert.eq(cast(wock(), dock), (false, "expected element dock, got wock"))
#assert.eq(cast(dock(), wock), (false, "expected element wock, found dock"))
#assert.eq(cast(wock(), dock), (false, "expected element dock, found wock"))

#assert.eq(cast(wock(), types.union(wock, dock)), (true, wock()))
#assert.eq(cast(dock(), types.union(wock, dock)), (true, dock()))
#assert.eq(cast([abc], types.union(wock, dock)), (false, "all typechecks for union failed\n hint (element 'wock'): expected element wock, got text\n hint (element 'dock'): expected element dock, got text"))
#assert.eq(cast(stock(), types.union(wock, dock)), (false, "all typechecks for union failed\n hint (element 'wock'): expected element wock, got stock\n hint (element 'dock'): expected element dock, got stock"))
#assert.eq(cast([abc], types.union(wock, dock)), (false, "all typechecks for union failed\n hint (element 'wock'): expected element wock, found text\n hint (element 'dock'): expected element dock, found text"))
#assert.eq(cast(stock(), types.union(wock, dock)), (false, "all typechecks for union failed\n hint (element 'wock'): expected element wock, found stock\n hint (element 'dock'): expected element dock, found stock"))

#assert.eq(cast(wock(), types.literal(wock())), (true, wock()))
#assert.eq(cast(wock(), types.literal(wock(color: black))), (false, "given value wasn't equal to literal 'wock(color: luma(0%))'"))
#assert.eq(cast(wock(color: black), types.literal(wock(color: black))), (true, wock(color: black)))
16 changes: 8 additions & 8 deletions test/unit/types/native/elements/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
)

#assert.eq(cast([abc], native-elem(text)), (true, [abc]))
#assert.eq(cast([abc *abc*], native-elem(text)), (false, "expected native element text, got sequence"))
#assert.eq(cast([abc *abc*], native-elem(text)), (false, "expected native element text, found sequence"))

#assert.eq(cast([a *abc*], native-elem(sequence)), (true, [a *abc*]))
#assert.eq(cast([abc], native-elem(sequence)), (false, "expected native element sequence, got text"))
#assert.eq(cast(wock(), native-elem(sequence)), (false, "expected native element sequence, got wock"))
#assert.eq(cast(wock(color: black), native-elem(sequence)), (false, "expected native element sequence, got wock"))
#assert.eq(cast([abc], native-elem(sequence)), (false, "expected native element sequence, found text"))
#assert.eq(cast(wock(), native-elem(sequence)), (false, "expected native element sequence, found wock"))
#assert.eq(cast(wock(color: black), native-elem(sequence)), (false, "expected native element sequence, found wock"))

#assert.eq(cast([= efg], native-elem(heading)), (true, [= efg]))
#assert.eq(cast([efg], native-elem(heading)), (false, "expected native element heading, got text"))
#assert.eq(cast(wock(), native-elem(heading)), (false, "expected native element heading, got wock"))
#assert.eq(cast([efg], native-elem(heading)), (false, "expected native element heading, found text"))
#assert.eq(cast(wock(), native-elem(heading)), (false, "expected native element heading, found wock"))

#assert.eq(cast([abc], types.union(native-elem(sequence), native-elem(heading))), (true, [abc]))
#assert.eq(cast([abc *abc*], types.union(native-elem(sequence), native-elem(heading))), (true, [abc *abc*]))
#assert.eq(cast([= efg], types.union(native-elem(sequence), native-elem(heading))), (true, [= efg]))
#assert.eq(cast(wock(), types.union(native-elem(sequence), native-elem(heading))), (false, "all typechecks for union failed\n hint (native element 'sequence'): expected native element sequence, got text\n hint (native element 'heading'): expected native element heading, got text"))
#assert.eq(cast(wock(), types.union(native-elem(sequence), native-elem(heading))), (false, "all typechecks for union failed\n hint (native element 'sequence'): expected native element sequence, found wock\n hint (native element 'heading'): expected native element heading, found wock"))

0 comments on commit 6fdf9f7

Please sign in to comment.