fix(test): expect_eq on strings compares their text and prints both on a failure
It lowered to an i32 compare of two pointers, which the IR refused. Two strings with the same text are equal now, a null only to a null, and a failure says expect_eq failed (got "camp", want "lake"). examples/library/testing_strings.ludic (two tests fail on purpose, and the output is checked); ludic.base's actions_test uses it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
55c1de8734
commit
2fdefa6040
9 changed files with 22471 additions and 21866 deletions
17
examples/library/testing_strings.ludic
Normal file
17
examples/library/testing_strings.ludic
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# testing_strings.ludic - expect_eq on strings compares their text, not where they are kept, and a
|
||||
# failure prints both (two of these fail on purpose: the runner reports them and exits 1)
|
||||
program TestingStrings {
|
||||
function joined(a: string, b: string) -> string { return a + b }
|
||||
test "equal text built two ways" {
|
||||
expect_eq(joined("ca", "mp"), "camp")
|
||||
let none: string = null
|
||||
expect_eq(none, null)
|
||||
}
|
||||
test "different text fails, and says both" {
|
||||
expect_eq(joined("ca", "mp"), "lake")
|
||||
}
|
||||
test "a null is not a string" {
|
||||
let none: string = null
|
||||
expect_eq(none, "camp")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue