-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
map.deepEquals
for deep map comparison (#637)
Sometimes extensionally equal maps can have different hashes because of different encodings, so `==` won't recognize extensionally equal maps as equal, but `deepEquals` will
- Loading branch information
Showing
8 changed files
with
532 additions
and
1 deletion.
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
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,45 @@ | ||
message Compare { | ||
m1: map<Int as uint8, Bool>; | ||
m2: map<Int as uint8, Bool>; | ||
} | ||
|
||
message CompareDeep { | ||
m1: map<Int as uint8, Bool>; | ||
m2: map<Int as uint8, Bool>; | ||
} | ||
|
||
contract MapComparisonTestContract { | ||
receive() {} | ||
|
||
receive(msg: Compare) { | ||
require(msg.m1 == msg.m2, "Maps are not equal"); | ||
} | ||
|
||
receive(msg: CompareDeep) { | ||
require(msg.m1.deepEquals(msg.m2), "Maps are not equal"); | ||
} | ||
|
||
get fun compareIntInt(m1: map<Int, Int>, m2: map<Int, Int>): Bool { | ||
return m1.deepEquals(m2); | ||
} | ||
|
||
get fun compareIntCell(m1: map<Int, Cell>, m2: map<Int, Cell>): Bool { | ||
return m1.deepEquals(m2); | ||
} | ||
|
||
get fun compareIntAddress(m1: map<Int, Address>, m2: map<Int, Address>): Bool { | ||
return m1.deepEquals(m2); | ||
} | ||
|
||
get fun compareAddressInt(m1: map<Address, Int>, m2: map<Address, Int>): Bool { | ||
return m1.deepEquals(m2); | ||
} | ||
|
||
get fun compareAddressCell(m1: map<Address, Cell>, m2: map<Address, Cell>): Bool { | ||
return m1.deepEquals(m2); | ||
} | ||
|
||
get fun compareAddressAddress(m1: map<Address, Address>, m2: map<Address, Address>): Bool { | ||
return m1.deepEquals(m2); | ||
} | ||
} |
Oops, something went wrong.