All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Leaked private type for generic-argument mocks in
with_types
signature (#58).
- Silenced
clippy::multiple_bound_locations
lints - Small doc improvements
- Support for mocking embedded-hal (#55).
- Compile error encountered
&[NoDebug]
arguments. - Default methods when the trait needs generic arguments.
- Missing documentation warning for the generated
with_types
function.
- Support for returning references to non-Send types (#53)
- Basic support for mutable outputs (#49)
- Don't trigger
manual_async_fn
lint when mocking-> impl Future
methods.
- Unmocking using
async fn
when the trait fn has an-> impl Future
signature.
- Unimock now supports very flexible argument mutation, instead of one hard-coded parameter.
To achieve this, the
answers
API had to be redesigned with a new signature based on adyn Fn
. This dynamic function type has one fixed signature perMockFn
, so its return type isn't generic as it used to be in0.5.x
. All generated borrows have to be done explicitly throughUnimock::make_ref
for this to work. (#43, #47)- The function passed to
answers
must be a&static
Fn, or it can be anArc
closure that can be registered by callinganswers_arc
. - The parameters passed to this function are the same as passed to the mocked trait method, including
self
.
- The function passed to
- Output trait hierarchy (which allows safely mocking borrowed return values) rewritten to be more flexible and future-proof than previously (#46)
default_implementation
renamed toapplies_default_impl
.unmocked
renamed toapplies_unmocked
.
- Mocks for
tokio-1
andfutures-io-0-3
async read/write traits (#45)
- Fix
matching!
against references to number literals (#42) - Borrows from function arguments can now be made without leaking memory (#47)
- The
mutates
builder APIs. These are now handled usinganswers
.
- Mutation when generics are involved. (#38)
- (static) Associated constants support with
#[unimock(const FOO: Type = value;)]
.
- Proper
no_std
support by disabling default features inonce_cell
. (#35)
- Support for async fn through RPITIT, i.e.
fn -> impl Future<Output = _>
. (#34)
Pin<&mut Self>
receivers in combination with the default impl delegator with the help of polonius-the-crab! (#30)&mut Self
receivers that returns references to self, within default body (same fix as above).
- Mixed return type support for
core::task::Poll<T>
whereT
is already mixed.
- Default methods combined with arbitrary Self types like
Rc<Self>
/Arc<Self>
/Pin<&mut Self>
. - Argument debugging for
&mut T
args whereT
does not implementDebug
. - Compile error for
&mut T<'_>
arguments that are not mock-mutable. - Missing
.await
syntax when using default async methods. - Fully qualified method call syntax in default method glue, to avoid ambiguity.
- Mock of lifetime generic trait
- Missing MIT license file
- Documentation inaccuracies
- Remove outdated dependency
doc-cfg
.
- Support for mutating one
&mut
parameter with.mutates
. - Support for falling back to default implementations of methods.
- (static) Associated type support with
#[unimock(type T = Foo;)]
. no_std
support, by opting out of the"std"
feature.spin-lock
feature forno_std
users.mock-core
feature for mocking implementations of traits incore
.mock-std
feature for mocking implementations of traits instd
.- Unimock now implements
UnwindSafe
andRefUnwindSafe
by manual implementation.
macro_api
renamed toprivate
and excluded from docs.MockFn::NAME
replaced byfn info() -> MockFnInfo
.- macro keyword
emulate
renamed tomirror
.
- Generics involving
Self
.
- Unnecessary
&self
reference in macro-generated code if self was already a reference.
- Code generation: Don't parenthesize inputs when there is only one argument.
- Require dependency versions closer to latest releases.
unimock_macros
: AddedREADME
.- Most hyperlinks in README.md.
- Trait emulation, only intended for internal (and future) use.
- Upgrade to
syn
2.0.
- Support for generic trait methods.
- cfg attrs on trait methods are now honoured.
- Panic when the original unimock is destroyed in another thread than the one that created it.
- Make inexact quantification (at_least_times) of strictly ordered clauses (next_call) into a compile error instead of a runtime error.
Vec<&T>
output values.- Tuple output values with any combination of borrows of up to 4-element tuples.
matching!
of str-like arguments in or-pattern ("a" | "A"
).- Remove
T: Clone
bound on-> Option<&T>
multi-return functions. - Remove
T: Clone
bound on-> Result<&T, E>
multi-return functions. There is still aE: Clone
bound.
- Now depends on
once_cell
instead oflazycell
internally.
- Theoretical stack overflow when dropping unimock (in case of many borrowed return values).
- A bug in code generation for
impl Future
lifetime bounds.
- The unimock macro now generates
Output<'u> = Self::Response;
in MockFn if the Response and Output types are the same type. This is a backwards compatible change. - Order of keywords in Cargo.toml.
- Note in the crate documentation about
&mut
arguments and tricky lifetimes.
- Cargo package description
- More cargo keyword variants
- A bug where an input lifetime was rewritten to a self lifetime in the case of borrowed output
- Documentation note about
#[cfg_attr(test, unimock)]
.
- Compile error when
matching!
a literal string pattern against a type that implements bothAsRef<str>
andDebug
.
- New default feature:
pretty-print
- Hygiene issue when mocking a function with an argument called
eval
which can be unmocked. - Using
eq!
orne!
as part of disjuctive input tuple inmatching!
macro. - Diagnostics on mismatched call patterns. Now uses a debug print solution based on
pretty_assertions
.
#[unimock]
is now more hygienic and does not autogenerate a mock api identifier by default. Instead, the user-facing mock API is opt-in by specifyingapi=my_ident
.Unimock::new(setup)
replacesmock(clause)
.Unimock::new_partial(setup)
replacesspy(clause)
.Clause
is now a trait instead of a type.- Clause composition is now done using tuples instead of
impl IntoIterator
, because clauses now have non-uniform types. - The generated
MockFn
structs are now put in a module calledTraitMock
whereTrait
is the name of the trait. The name of the generated structs are the same as the names of the methods. - Renamed the
unmocked=[..]
attribute option tounmock_with=[..]
. - Improvements to function output modelling.
- Mock builder API simplification. There is no longer any
returns_ref
orreturns_static
, justreturns
. - Unimock is now implemented with Generic Associated Types, and requires Rust minimum 1.65.
- New mock entry point
some_call
which does not require return value to implementClone
.next_call
now also uses this API. api=[..]
attribute option for opting out of generating an encapsulating module.- Support for self references in
Option
andResult
return values (e.g.-> Option<&str>
) - Better mismatch debugging with improved
matching!
API under the hood. - Support for
Eq
-based matching in thematching!
macro.
- Avoid spitting out
#[allow(non_camel_case_types)]
when the user supplied the MockFn type names.
mod = *
attribute option at trait level.- The
.in_any_order()
and.in_order()
builder methods. Those types instead just implementClause
. - The
Unmock
trait.
- Support for unpacked modules with
mod=*
and support uniform MockFn aliases withas=alias
- Refactor code according to clippy lints.
- Problem/regression regarding trailing comma in inputs destructuring.
- Using generics when the MockFn is put in a separate module.
- Generic unmockable functions.
- Some more internal refactoring to keep more functions non-generic.
- Support for mocking generic traits. In order to work, the generic arguments have to be
'static
.
- Moved eval methods from Unimock into macro_api. Technically breaking, but these APIs were never supposed to be used directly from applications. It will be clearer that these are internal implementation details when part of macro_api rather than public methods on Unimock.
- Now supports skipping methods without a self receiver, but with a default body
- Support for return types with lifetime parameters. These are turned into
'static
for unimock.
- Support for return references borrowed from arguments instead of self.
- Output
async_trait
attribute on the same form that it was parsed.
prefix
parameter to the unimock macro, in case the crate is re-exported through another crate.
- Lots of internal refactoring to keep more things non-generic, saves code size.
- Add cargo keyword, cargo categories.
- Simplify various lifetime signatures, remove unneeded outlives bounds, remove elidable lifetimes.
- More documentation, project goals
- Support for methods returning associated futures, through return-position-impl-trait. When used, requires
generic_associated_types
andtype_alias_impl_trait
.
mockall
dev dependency
- Fix missing README file on crates.io
- Pretty formatting for fn signatures in generated MockFn documentation.
- self receiver in MockFn call pattern constructors. This works much better with rustfmt, which tends to move a dot-method call to the next line, indented. This means that each new mock will start naturally in the clause array, and all subsequent setup methods will be indented, so it's much easier to see where each mock starts and ends.
- Documentation attributes for generated MockFns
- Ability to unmock with a specific argument list:
unmocked=[foo(a, b)]
- Breaking: Ability to make call patterns with
T::method
, as these methods now take a self parameter.
RefUnwindSafe
bound on stored data, to allow things likeUnsafeCell
in return types.
- Change MockFn to not require generic associated types, by introducing new trait MockInputs
- Improvements to panic messages and related tests
- Completely new API for specifying trait mocks, greatly reducing amount of generated code
- Generic Associated Types dependency
- Unmocking/spying feature
mockall
dependency
- The
unimock
attribute macro. - The
Unimock
type.