expand func call tests

Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-02-24 16:05:10 -08:00
parent d640c815a8
commit 82854a58f8
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
2 changed files with 118 additions and 21 deletions

View file

@ -149,6 +149,7 @@ impl Args {
Args::Strict(ref arg_types) => {
let mut idx: usize = 0;
let mut mismatch = false;
let passes = args.circuit(&mut |c: &Ctr| -> bool {
if idx >= arg_types.len() {
return false;
@ -160,6 +161,7 @@ impl Args {
idx += 1;
return true;
}
mismatch = true;
false
});
@ -171,16 +173,15 @@ impl Args {
}
if !passes {
if idx < (arg_types.len() - 1) {
return Err(format!(
"argument {} is of wrong type (expected {})",
idx + 1,
arg_types[idx]
));
if mismatch {
return Err(format!("arg {} expected to be {}", idx+1, arg_types[idx]));
}
if idx == (arg_types.len() - 1) {
if idx > (arg_types.len() - 1) {
return Err("too many arguments".to_string());
}
if idx < (arg_types.len() - 1) {
return Err("too few arguments".to_string());
}
}
}
}