Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoorkin authored Mar 12, 2024
2 parents 8aa1eec + a022428 commit ff36deb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions assertion/assertion.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ fn debug_string[T : Debug](t : T) -> String {
buf.to_string()
}

pub fn assert_eq[T : Debug + Eq](a : T, b : T) -> Result[Unit, String] {
pub fn assert_eq[T : Debug + Eq](
a : T,
b : T,
~loc : SourceLoc = _
) -> Result[Unit, String] {
if a == b {
Ok(())
} else {
let a = debug_string(a)
let b = debug_string(b)
Err("assertion failed for `\(a) == \(b)`")
Err("FAILED:\(loc) `\(a) == \(b)`")
}
}

Expand All @@ -42,13 +46,17 @@ test "assert_eq.ne" {
}
}

pub fn assert_ne[T : Debug + Eq](a : T, b : T) -> Result[Unit, String] {
pub fn assert_ne[T : Debug + Eq](
a : T,
b : T,
~loc : SourceLoc = _
) -> Result[Unit, String] {
if a != b {
Ok(())
} else {
let a = debug_string(a)
let b = debug_string(b)
Err("assertion failed for `\(a) != \(b)`")
Err("FAILED:\(loc) `\(a) != \(b)`")
}
}

Expand Down

0 comments on commit ff36deb

Please sign in to comment.