Skip to content

Commit 3fafbc2

Browse files
committed
Merge pull request #4222 from gbasler/topic/patmat-unit-tests-rebased
Add unit tests for Tseitin CNF conversion and implement missing `equals` method for `Sym`.
2 parents 409b280 + 5c296a4 commit 3fafbc2

File tree

2 files changed

+567
-1
lines changed

2 files changed

+567
-1
lines changed

Diff for: src/compiler/scala/tools/nsc/transform/patmat/Logic.scala

+12-1
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,20 @@ trait Logic extends Debugging {
122122

123123
// symbols are propositions
124124
final class Sym private[PropositionalLogic] (val variable: Var, val const: Const) extends Prop {
125+
126+
override def equals(other: scala.Any): Boolean = other match {
127+
case that: Sym => this.variable == that.variable &&
128+
this.const == that.const
129+
case _ => false
130+
}
131+
132+
override def hashCode(): Int = {
133+
variable.hashCode * 41 + const.hashCode
134+
}
135+
125136
private val id: Int = Sym.nextSymId
126137

127-
override def toString = variable + "=" + const + "#" + id
138+
override def toString = s"$variable=$const#$id"
128139
}
129140

130141
object Sym {

0 commit comments

Comments
 (0)