Skip to content

Releases: msz/hammox

v0.7.0

24 Jul 17:21
@msz msz
5e97881
Compare
Choose a tag to compare

New features

[#120]

Hammox now includes telemetry events! See Telemetry Guide for more information.

Big thanks to @SophisticaSean for carrying this start to finish!

v0.6.1

18 Jun 13:52
@msz msz
24b557f
Compare
Choose a tag to compare

Performance improvements

[#103]

Hammox now uses :persistent_term instead of a GenServer for caching typespecs, resulting in a ~5x speedup. Thanks @SophisticaSean for making and benchmarking the changes and @Adzz for suggesting :persistent_term!

v0.6.0

05 Jun 17:29
@msz msz
95ff46e
Compare
Choose a tag to compare

New features

Multiple behaviour support in Hammox.Protect and Hammox.protect/2 [#93]

use Hammox.Protect now accepts multiple :behaviour options:

use Hammox.Protect, module: My.Module, behaviour: My.Module.Contract, behaviour: My.Module.OtherContract

Which is functionally equivalent to:

use Hammox.Protect, module: My.Module, behaviour: My.Module.Contract
use Hammox.Protect, module: My.Module, behaviour: My.Module.OtherContract

Likewise, Hammox.protect/2 now additionally supports a list of behaviours as second argument:

Hammox.protect(My.Module, [My.Module.Contract, My.Module.OtherContract]),

Big thanks to @camilleryr for submitting these changes.

Bug fixes

  • Complex multiline typespecs no longer cause a CaseClauseError with recent versions of Elixir when Hammox tries to print them [#113]
  • The bool() type is now correctly supported and no longer causes an exception [#115]
  • Type guards are now correctly supported and no longer cause an exception [#116]
  • Fixes incorrect usage of Code.ensure_compiled/1 [#111] (thanks to @Adzz)

Other

v0.5.0

06 Mar 17:12
@msz msz
bf1f7da
Compare
Choose a tag to compare

Raising when Hammox.Protect is used on a module without callbacks

[#75]

Using Hammox.Protect on a module without callbacks is essentially a no-op. This is most likely due to a mistake, and we now raise in this scenario.

v0.4.0

23 Jan 18:49
@msz msz
0c31179
Compare
Choose a tag to compare

Hammox.Protect

[#71]

You can now do use Hammox.Protect instead of calling Hammox.protect/3 directly as a less verbose way of creating protected functions in tests. See the Hammox.Protect API docs for more details and the README for an example.

Dependency upgrades

  • :ordinal 0.1.0 -> 0.2.0 [#68]

v0.3.1

12 Dec 12:28
@msz msz
Compare
Choose a tag to compare

Bug fixes

  • fixes crash when using maps explicitly specifying a __struct__ key [#64]

Acknlowledgements

Thanks to @randycoulman for the fix!

v0.3.0

21 Oct 23:36
@msz msz
Compare
Choose a tag to compare

The biggest release yet!

Huge speed improvements

[#53]

Hammox v0.2 and below was completely stateless. Any time a Hammox-protected function was called, types needed to be read from disk and parsed from the compiled binary files. This created a huge bottleneck which given complex typespecs with many types slowed down Hammox-heavy test suites considerably.

Hammox v0.3 includes a typespec cache server and keeps all types in memory once first read from disk. Now the performance impact is practically indistinguishable from Mox.

Interface simplifications and shortcuts

Decorate all functions designated by a behaviour by default

[#54] [#55]

When using the "batch" version of protect where you pass an implementation module, a behaviour module, and a list of functions, the list of functions is now optional. Hammox will decorate all functions from the behaviour by default.

Example:

defmodule Calculator do
  @callback add(integer(), integer()) :: integer()
end

defmodule TestCalculator do
  def add(a, b), do: a + b
end

# Hammox v0.2
Hammox.protect(TestCalculator, Calculator, add: 2)

# Hammox v0.3
Hammox.protect(TestCalculator, Calculator)

Shortcuts for behaviour-implementation modules

[#51] [#62]

When using modules which contain both callbacks and implementations, you now only need to pass the module to protect once.

Example:

defmodule Calculator do
  @callback add(integer(), integer()) :: integer()
  def add(a, b), do: a + b
end

# Hammox v0.2
Hammox.protect(Calculator, Calculator, add: 2)

# Hammox v0.3
Hammox.protect(Calculator, add: 2)

Better exceptions for protect edge cases

[#52]

Before, passing nonexistent module to protect resulted in an ugly internal exception. Now, we raise a better exception explaning what happened.

Type checking for stubs

[#58]

Before, calls to stubs created by Hammox were not being type checked. This was an oversight. In Hammox v0.3, calls to stubs created by Hammox using Hammox.stub/3 are type checked.

Mox update

[#50]

Hammox v0.3 now includes Mox 1.0.0.

Acknlowledgements

Thanks to @saneery, @randycoulman, @jotaviobiondo and @SophisticaSean for helping make this release happen!

v0.2.5

08 Jun 20:16
@msz msz
ecad450
Compare
Choose a tag to compare

Bug fixes

  • adds support for all of @type, @typep, @opaque [#41, #42]

Acknowledments

Thanks to @gabrielpra1 for spotting this!

v0.2.4

28 Apr 23:04
@msz msz
9907c74
Compare
Choose a tag to compare

Fixes

  • fixes error when using parametrized type definitions spanning multiple lines [#29]

v0.2.3

13 Apr 14:33
@msz msz
b819a0c
Compare
Choose a tag to compare

Dependency upgrades

  • :mox 0.5.1 -> 0.5.2