Skip to content

Commit

Permalink
Add tests for async methods and associated functions (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Mar 3, 2024
1 parent 4580259 commit ddd5f1b
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 3 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@ trait Visitor {
- ✓ Support for traits with generic arguments.
-`#[derive(Ref)]`
-`#[derive(Mut)]`
-`#[derive(Box)]`
-`#[derive(Box)]` for both sized and unsized types.
-`#[derive(Rc)]`
-`#[derive(Arc)]`
- ✗ Update `Box` derive to allow unsized types if possible.
-`#[derive(Cow)]`
-`#[derive(Cow)]`

## 🤝 Credits

Expand Down
20 changes: 20 additions & 0 deletions tests/derive_arc/successes/async_assoc_function.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::sync::Arc;

use impls::impls;

#[blanket::blanket(derive(Arc))]
trait Foo {
async fn bar();
}

#[derive(Default)]
struct Baz;

impl Foo for Baz {
async fn bar() {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(Arc<Baz>: Foo));
}
20 changes: 20 additions & 0 deletions tests/derive_arc/successes/async_method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::sync::Arc;

use impls::impls;

#[blanket::blanket(derive(Arc))]
trait Foo {
async fn bar(&self);
}

#[derive(Default)]
struct Baz;

impl Foo for Baz {
async fn bar(&self) {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(Arc<Baz>: Foo));
}
18 changes: 18 additions & 0 deletions tests/derive_box/successes/async_assoc_function.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use impls::impls;

#[blanket::blanket(derive(Box))]
trait Foo {
async fn bar();
}

#[derive(Default)]
struct Baz;

impl Foo for Baz {
async fn bar() {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(Box<Baz>: Foo));
}
18 changes: 18 additions & 0 deletions tests/derive_box/successes/async_method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use impls::impls;

#[blanket::blanket(derive(Box))]
trait Foo {
async fn bar(&self);
}

#[derive(Default)]
struct Baz;

impl Foo for Baz {
async fn bar(&self) {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(Box<Baz>: Foo));
}
20 changes: 20 additions & 0 deletions tests/derive_cow/successes/async_assoc_function.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::borrow::Cow;

use impls::impls;

#[blanket::blanket(derive(Cow))]
trait Foo {
async fn bar();
}

#[derive(Default, Clone)]
struct Baz;

impl Foo for Baz {
async fn bar() {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(Cow<Baz>: Foo));
}
20 changes: 20 additions & 0 deletions tests/derive_cow/successes/async_method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::borrow::Cow;

use impls::impls;

#[blanket::blanket(derive(Cow))]
trait Foo {
async fn bar(&self);
}

#[derive(Default, Clone)]
struct Baz;

impl Foo for Baz {
async fn bar(&self) {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(Cow<Baz>: Foo));
}
20 changes: 20 additions & 0 deletions tests/derive_rc/successes/async_assoc_function.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::rc::Rc;

use impls::impls;

#[blanket::blanket(derive(Rc))]
trait Foo {
async fn bar();
}

#[derive(Default)]
struct Baz;

impl Foo for Baz {
async fn bar() {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(Rc<Baz>: Foo));
}
20 changes: 20 additions & 0 deletions tests/derive_rc/successes/async_method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use std::rc::Rc;

use impls::impls;

#[blanket::blanket(derive(Rc))]
trait Foo {
async fn bar(&self);
}

#[derive(Default)]
struct Baz;

impl Foo for Baz {
async fn bar(&self) {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(Rc<Baz>: Foo));
}
18 changes: 18 additions & 0 deletions tests/derive_ref/successes/async_assoc_function.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use impls::impls;

#[blanket::blanket(derive(Ref))]
trait Foo {
async fn bar();
}

#[derive(Default)]
struct Baz;

impl Foo for Baz {
async fn bar() {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(&Baz: Foo));
}
18 changes: 18 additions & 0 deletions tests/derive_ref/successes/async_method.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use impls::impls;

#[blanket::blanket(derive(Ref))]
trait Foo {
async fn bar(&self);
}

#[derive(Default)]
struct Baz;

impl Foo for Baz {
async fn bar(&self) {}
}

fn main() {
assert!(impls!(Baz: Foo));
assert!(impls!(&Baz: Foo));
}

0 comments on commit ddd5f1b

Please sign in to comment.