-
Notifications
You must be signed in to change notification settings - Fork 4
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 #103 from ChenCMD/master
Implement hashCode() in ArrayRecord and Record classes
- Loading branch information
Showing
4 changed files
with
32 additions
and
0 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
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 |
---|---|---|
|
@@ -807,6 +807,22 @@ class RecordSpec extends helper.UnitSpec { | |
} | ||
} | ||
|
||
describe(".hashCode()") { | ||
it("should return the same hash code for equal records") { | ||
val r1 = %(name = "tarao", age = 3) | ||
val r2 = %(name = "tarao", age = 3) | ||
val r3 = %(name = "ikura", age = 1) | ||
val r4 = %(name = "tarao", age = 3, email = "[email protected]") | ||
val r5: % { val name: String; val age: Int } = r4 | ||
|
||
(r1.hashCode() == r1.hashCode()) shouldBe true | ||
(r1.hashCode() == r2.hashCode()) shouldBe true | ||
(r2.hashCode() == r1.hashCode()) shouldBe true | ||
(r1.hashCode() == r5.as.hashCode()) shouldBe true | ||
(r5.as.hashCode() == r1.hashCode()) shouldBe true | ||
} | ||
} | ||
|
||
describe(".toString()") { | ||
it("can express empty Record") { | ||
Record.empty.toString() shouldBe "%()" | ||
|