test trailing-optional parameters

we'll need proper tests to check that too few and too many
parameters actually trigger errors

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-11-25 10:17:33 +01:00
parent 4b5b75f1d8
commit 0044cdcef4
3 changed files with 16 additions and 1 deletions

View File

@ -70,6 +70,11 @@ mod export {
_ => bail!("invalid"),
})
}
#[export]
fn test_trailing_optional(first: u32, second: Option<u32>) {
println!("{:?}, {:?}", first, second);
}
}
#[perlmod::package(name = "RSPM::EnvVarLibrary", lib = "x-${CARGO_PKG_NAME}-y")]

View File

@ -105,7 +105,13 @@ test_unsafe_clone(Storable::dclone($magic));
print("Testing unsafe clone\n");
test_unsafe_clone(Clone::clone($magic));
undef $magic;
print("Testing enum deserialization\n");
my $ra = RSPM::Foo142::test_enums("something");
die "unexpected result from test_enums: $ra\n" if $ra ne 'result-a';
print("Testing optional parameters\n");
RSPM::Foo142::test_trailing_optional(1, 99);
RSPM::Foo142::test_trailing_optional(2, undef);
RSPM::Foo142::test_trailing_optional(3);

View File

@ -37,5 +37,9 @@ Testing unsafe dclone
unsafe dclone dropped
Testing unsafe clone
unsafe dclone dropped
Testing enum deserialization
Dropping blessed magic with content "magic test"
Testing enum deserialization
Testing optional parameters
1, Some(99)
2, None
3, None