expand func call tests
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
d640c815a8
commit
82854a58f8
2 changed files with 118 additions and 21 deletions
15
src/sym.rs
15
src/sym.rs
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue