-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #208 from asomers/where_clause_with_qself2
Fix using QSelf in a where clause or a return type.
- Loading branch information
Showing
5 changed files
with
140 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// vim: tw=80 | ||
//! Using QSelf in an argument, a where clause, or a return type | ||
#![deny(warnings)] | ||
|
||
use mockall::*; | ||
|
||
pub trait Foo { | ||
type Output; | ||
} | ||
|
||
pub struct SendFoo {} | ||
impl Foo for SendFoo { | ||
type Output = u32; | ||
} | ||
|
||
pub struct A{} | ||
#[automock] | ||
impl A { | ||
pub fn foo<T: Foo + 'static>(&self, _q: <T as Foo>::Output) { | ||
} | ||
pub fn bar<T: Foo + 'static>(&self, _t: T) -> <T as Foo>::Output { | ||
unimplemented!() | ||
} | ||
pub fn bean<T>(&self, _t: T) | ||
where T: Foo + 'static, | ||
<T as Foo>::Output: Send | ||
{ | ||
} | ||
} | ||
|
||
#[test] | ||
fn arguments() { | ||
let mut mock = MockA::new(); | ||
mock.expect_foo::<SendFoo>() | ||
.with(predicate::eq(42u32)) | ||
.return_const(()); | ||
mock.foo::<SendFoo>(42u32); | ||
} | ||
|
||
#[test] | ||
fn where_clause() { | ||
let mut mock = MockA::new(); | ||
mock.expect_bean::<SendFoo>() | ||
.return_const(()); | ||
mock.bean(SendFoo{}); | ||
} | ||
|
||
#[test] | ||
fn return_value() { | ||
let mut mock = MockA::new(); | ||
mock.expect_bar::<SendFoo>() | ||
.return_const(42u32); | ||
assert_eq!(42, mock.bar(SendFoo{})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters