mirror of
https://git.proxmox.com/git/perlmod
synced 2025-10-04 11:58:18 +00:00
update tests
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
f5adbcf1aa
commit
476bd7af6b
@ -21,6 +21,13 @@ enum AnEnum {
|
||||
ResultB,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
enum TaggedEnum {
|
||||
Something(String),
|
||||
Another(i32, i32),
|
||||
}
|
||||
|
||||
#[perlmod::package(
|
||||
name = "RSPM::Foo142",
|
||||
lib = "perlmod_test",
|
||||
@ -33,6 +40,7 @@ mod export {
|
||||
use perlmod::Value;
|
||||
|
||||
use super::AnEnum;
|
||||
use super::TaggedEnum;
|
||||
|
||||
fn loaded() {
|
||||
println!("<loaded>");
|
||||
@ -80,6 +88,14 @@ mod export {
|
||||
})
|
||||
}
|
||||
|
||||
#[export]
|
||||
fn test_enums2(data: TaggedEnum) -> TaggedEnum {
|
||||
match data {
|
||||
TaggedEnum::Something(word) => TaggedEnum::Something(format!("{word}.")),
|
||||
TaggedEnum::Another(n, m) => TaggedEnum::Another(n + 1, m * 2),
|
||||
}
|
||||
}
|
||||
|
||||
#[export]
|
||||
fn test_trailing_optional(first: u32, second: Option<u32>) {
|
||||
println!("{first:?}, {second:?}");
|
||||
|
4
test.pl
4
test.pl
@ -130,3 +130,7 @@ my $err = $@;
|
||||
die "test_deserialized_error error is not a hash\n" if ref($err) ne 'HASH';
|
||||
die "structured error has invalid fields\n" if join(',', sort(keys(%$err))) ne 'a,b';
|
||||
print('error type: { a: ', $err->{a}, ', b: ', $err->{b}, " }\n");
|
||||
|
||||
my $a = RSPM::Foo142::test_enums2({ something => "hello" });
|
||||
print(join(', ', keys %$a), "\n");
|
||||
print($a->{something}, "\n");
|
||||
|
@ -47,3 +47,5 @@ Testing optional parameters
|
||||
Substring test
|
||||
[OneTwoThree] [Two]
|
||||
error type: { a: first, b: second }
|
||||
something
|
||||
hello.
|
||||
|
Loading…
Reference in New Issue
Block a user