mirror of
https://github.com/icewind1991/ivory.git
synced 2026-06-04 03:04:08 +02:00
tests and optional arguments
This commit is contained in:
parent
aa1e5d7dca
commit
b8cd60fff5
10 changed files with 356 additions and 37 deletions
53
tests/src/lib.rs
Normal file
53
tests/src/lib.rs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
use std::fmt::Debug;
|
||||
|
||||
use ivory::externs::printf;
|
||||
use ivory::PhpVal;
|
||||
use ivory::{ivory_export, ivory_module};
|
||||
|
||||
fn dump<T: Debug>(arg: T) {
|
||||
printf(format!("{:?}", arg));
|
||||
}
|
||||
|
||||
#[ivory_export]
|
||||
fn dump_arg(arg: PhpVal) {
|
||||
dump(arg);
|
||||
}
|
||||
|
||||
#[ivory_export]
|
||||
fn expect_long(arg: i64) {
|
||||
dump(arg);
|
||||
}
|
||||
|
||||
#[ivory_export]
|
||||
fn expect_double(arg: f64) {
|
||||
dump(arg);
|
||||
}
|
||||
|
||||
#[ivory_export]
|
||||
fn expect_string(arg: String) {
|
||||
dump(arg);
|
||||
}
|
||||
|
||||
#[ivory_export]
|
||||
fn expect_bool(arg: bool) {
|
||||
dump(arg);
|
||||
}
|
||||
|
||||
#[ivory_export]
|
||||
fn expect_option_bool(arg: Option<bool>) {
|
||||
dump(arg);
|
||||
}
|
||||
|
||||
ivory_module!({
|
||||
name: "tests",
|
||||
version: "0.0.1",
|
||||
functions: &[
|
||||
dump_arg,
|
||||
expect_long,
|
||||
expect_double,
|
||||
expect_string,
|
||||
expect_bool,
|
||||
expect_option_bool
|
||||
],
|
||||
info: &[("test extension", "enabled")]
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue