-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compat version of the macro (needed for rai) (#50)
Version 2.1.0 Co-authored-by: Mary McGrath <[email protected]>
- Loading branch information
1 parent
0a1e379
commit f31cd07
Showing
8 changed files
with
95 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "AutoHashEquals" | ||
uuid = "15f4f7f2-30c1-5605-9d31-71845cf9641f" | ||
authors = ["Neal Gafter <[email protected]>", "andrew cooke <[email protected]>"] | ||
version = "2.0.0" | ||
version = "2.1.0" | ||
|
||
[deps] | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
|
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,25 @@ | ||
module Compat | ||
|
||
using AutoHashEquals: AutoHashEquals | ||
|
||
export @auto_hash_equals | ||
|
||
""" | ||
@auto_hash_equals [options] struct Foo ... end | ||
Generate `Base.hash`, `Base.isequal`, and `Base.==` methods for `Foo`. | ||
Options: | ||
* `cache=true|false` whether or not to generate an extra cache field to store the precomputed hash value. Default: `false`. | ||
* `hashfn=myhash` the hash function to use. Default: `Base.hash`. | ||
* `fields=a,b,c` the fields to use for hashing and equality. Default: all fields. | ||
* `typearg=true|false` whether or not to make type arguments significant. Default: `false`. | ||
* `typeseed=e` Use `e` (or `e(type)` if `typearg=true`) as the seed for hashing type arguments. | ||
* `compat1=true` To have `==` defined by using `isequal`. Default: `true`. | ||
""" | ||
macro auto_hash_equals(args...) | ||
esc(:($AutoHashEquals.@auto_hash_equals(compat1=true, $(args...)))) | ||
end | ||
|
||
end |
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,16 @@ | ||
module compat | ||
|
||
using AutoHashEquals.Compat: @auto_hash_equals | ||
using Test | ||
|
||
@testset "test the compat macro" begin | ||
@auto_hash_equals struct Box851{T} | ||
x::T | ||
end | ||
@test Box851(missing) == Box851(missing) | ||
@test isequal(Box851(missing), Box851(missing)) | ||
@test Box851(missing) != Box851(1) | ||
@test !isequal(Box851(missing), Box851(1)) | ||
end | ||
|
||
end |
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