Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Jan 29, 2024
1 parent 15208b3 commit 0f755f4
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions tests/build_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,28 +160,19 @@ fn test_build_type() {
#[test]
fn test_build_type_macro() {
#[derive(Debug, Clone, Eq, PartialEq, CustomType)]
#[rhai_type_name("MyFoo")]
#[rhai_type_extra(Self::build_extra)]
#[rhai_type(name = "MyFoo", extra = Self::build_extra)]
struct Foo {
#[rhai_type_skip]
#[rhai_type(skip)]
dummy: i64,
#[rhai_type_readonly]
#[rhai_type(readonly)]
bar: i64,
#[rhai_type_name("emphasize")]
#[rhai_type(name = "emphasize")]
baz: bool,
#[rhai_type_set(Self::set_hello)]
#[rhai_type(set = Self::set_hello)]
hello: String,
}

impl Foo {
pub fn new() -> Self {
Self {
dummy: 0,
bar: 5,
baz: false,
hello: "hey".to_string(),
}
}
pub fn set_hello(&mut self, value: String) {
self.hello = if self.baz {
let mut s = self.hello.clone();
Expand All @@ -195,7 +186,12 @@ fn test_build_type_macro() {
};
}
fn build_extra(builder: &mut TypeBuilder<Self>) {
builder.with_fn("new_foo", || Self::new());
builder.with_fn("new_foo", || Self {
dummy: 0,
bar: 5,
baz: false,
hello: "hey".to_string(),
});
}
}

Expand Down

0 comments on commit 0f755f4

Please sign in to comment.