meta: Replace equality assertion with assert_eq

Emits a more useful assertion message.
This commit is contained in:
David Mak 2023-12-06 11:05:42 +08:00
parent fd9f66b8d9
commit 4dc5dbb856
4 changed files with 8 additions and 9 deletions

View File

@ -44,7 +44,7 @@ fn main() {
let regex_filter = Regex::new(r"(?ms:^define.*?\}$)|(?m:^declare.*?$)").unwrap();
for f in regex_filter.captures_iter(&output) {
assert!(f.len() == 1);
assert_eq!(f.len(), 1);
filtered_output.push_str(&f[0]);
filtered_output.push('\n');
}

View File

@ -1165,7 +1165,7 @@ pub fn gen_binop_expr<'ctx, 'a, G: CodeGenerator>(
Ok(Some(ctx.gen_float_ops(op, left_val, right_val).into()))
} else if ty1 == ctx.primitives.float && ty2 == ctx.primitives.int32 {
// Pow is the only operator that would pass typecheck between float and int
assert!(*op == Operator::Pow);
assert_eq!(*op, Operator::Pow);
let i32_t = ctx.ctx.i32_type();
let pow_intr = ctx.module.get_function("llvm.powi.f64.i32").unwrap_or_else(|| {
let f64_t = ctx.ctx.f64_type();

View File

@ -102,12 +102,11 @@ impl TopLevelComposer {
if *func_name != simple_name.to_string() {
continue
}
builtin_ty.insert(name, *signature);
builtin_id.insert(name, DefinitionId(id));
} else if let TopLevelDef::Class { name, constructor, object_id, .. } = &*def
{
assert!(id == object_id.0);
assert_eq!(id, object_id.0);
if let Some(constructor) = constructor {
builtin_ty.insert(*name, *constructor);
}

View File

@ -139,7 +139,7 @@ impl TestEnvironment {
match &typ[..end] {
"tuple" => {
let mut s = &typ[end..];
assert!(&s[0..1] == "[");
assert_eq!(&s[0..1], "[");
let mut ty = Vec::new();
while &s[0..1] != "]" {
let result = self.internal_parse(&s[1..], mapping);
@ -149,14 +149,14 @@ impl TestEnvironment {
(self.unifier.add_ty(TypeEnum::TTuple { ty }), &s[1..])
}
"list" => {
assert!(&typ[end..end + 1] == "[");
assert_eq!(&typ[end..end + 1], "[");
let (ty, s) = self.internal_parse(&typ[end + 1..], mapping);
assert!(&s[0..1] == "]");
assert_eq!(&s[0..1], "]");
(self.unifier.add_ty(TypeEnum::TList { ty }), &s[1..])
}
"Record" => {
let mut s = &typ[end..];
assert!(&s[0..1] == "[");
assert_eq!(&s[0..1], "[");
let mut fields = HashMap::new();
while &s[0..1] != "]" {
let eq = s.find('=').unwrap();
@ -176,7 +176,7 @@ impl TestEnvironment {
let te = self.unifier.get_ty(ty);
if let TypeEnum::TObj { params, .. } = &*te.as_ref() {
if !params.is_empty() {
assert!(&s[0..1] == "[");
assert_eq!(&s[0..1], "[");
let mut p = Vec::new();
while &s[0..1] != "]" {
let result = self.internal_parse(&s[1..], mapping);