From fa780264ca47a8f706dfb3b24fcd34cf4e40ab23 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 23 Jun 2021 10:58:31 +0200 Subject: [PATCH] update test files Signed-off-by: Wolfgang Bumiller --- perlmod-test/Cargo.toml | 1 + perlmod-test/src/pkg142.rs | 11 +++++++++++ test.pl | 2 ++ test.pl.expected | 1 + 4 files changed, 15 insertions(+) diff --git a/perlmod-test/Cargo.toml b/perlmod-test/Cargo.toml index 058323b..09006fe 100644 --- a/perlmod-test/Cargo.toml +++ b/perlmod-test/Cargo.toml @@ -10,3 +10,4 @@ crate-type = [ "cdylib" ] [dependencies] anyhow = "1.0" perlmod = { path = "../perlmod", features = [ "exporter" ] } +serde = { version = "1.0", features = [ "derive" ] } diff --git a/perlmod-test/src/pkg142.rs b/perlmod-test/src/pkg142.rs index 6a9b75a..14e4690 100644 --- a/perlmod-test/src/pkg142.rs +++ b/perlmod-test/src/pkg142.rs @@ -1,3 +1,8 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Deserialize, Serialize)] +pub struct Blubber(String); + #[perlmod::package(name = "RSPM::Foo142", lib = "perlmod_test")] mod export { use anyhow::{bail, Error}; @@ -22,4 +27,10 @@ mod export { println!("teststr called with {:?}", t); Ok(()) } + + #[export] + fn test_serde(value: super::Blubber) -> Result<(), Error> { + println!("got {:?}", value); + Ok(()) + } } diff --git a/test.pl b/test.pl index 782e467..e75c867 100644 --- a/test.pl +++ b/test.pl @@ -24,3 +24,5 @@ print "Parameter exists: " . (exists($param->{x}) ? "YES" : "NO") . "\n"; RSPM::Foo142::test($param->{x}); print "Was auto-vivified: " . (exists($param->{x}) ? "YES" : "NO") . "\n"; RSPM::Foo142::teststr($param->{x}); + +RSPM::Foo142::test_serde("Hello"); diff --git a/test.pl.expected b/test.pl.expected index c118214..226bb7e 100644 --- a/test.pl.expected +++ b/test.pl.expected @@ -4,6 +4,7 @@ test called with Some("lo ") teststr called with Some("lo ") test called with None teststr called with None +got Blubber("Hello") Got (17, 32, ) Got: 2 values: 17 32 These should be called with a valid substr: