Skip to content

Commit

Permalink
Fix term equality (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbressler13 authored Feb 6, 2024
1 parent 18d5ab6 commit 814cec0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion exact-numbers/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "xyz.lbres"
version = "1.0.0"
version = "1.0.1"

val githubUsername: String? = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
val githubPassword: String? = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,6 @@ internal class TermImpl(coefficient: ExactFraction, factors: ConstMultiSet<Irrat
return string!!
}

override fun equals(other: Any?): Boolean {
if (other !is Term) {
return false
}

val simplified = getSimplified() as TermImpl
val otherSimplified = other.getSimplified() as TermImpl

return simplified.coefficient == otherSimplified.coefficient && simplified.factorSet == otherSimplified.factorSet
}

override fun equals(other: Any?): Boolean = other is Term && getValue() == other.getValue()
override fun hashCode(): Int = createHashCode(listOf(coefficient, factorSet, "Term"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ fun runEqualsTests() {
assertEquals(term1, term2)
assertEquals(term2, term1)

term1 = Term.fromValues(ExactFraction(-3, 187), listOf(log4, Sqrt(11), piInverse, piInverse))
term2 = Term.fromValues(ExactFraction(-3, 17), listOf(log4, Sqrt(ExactFraction(1, 11)), piInverse, piInverse))
assertEquals(term1, term2)
assertEquals(term2, term1)

// not equal
term1 = Term.ONE
term2 = -Term.ONE
Expand Down
2 changes: 1 addition & 1 deletion signatures/v1.0.0/v1.0.0.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*Versions: v1.0.0*
*Versions: v1.0.0, v1.0.1*

### xyz.lbres.exactnumbers.exactfraction

Expand Down

0 comments on commit 814cec0

Please sign in to comment.