diff --git a/CHANGELOG.md b/CHANGELOG.md index cd474a9..b3aec48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## 1.0.3 - 2016-11-29 +* Added `equals` implementation for `Patch` +* Added Scala 2.12 support + ## 1.0.2 - 2016-11-28 * Add apply syntax for `Patch` @@ -11,4 +15,4 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Minor cleanup ## 1.0.0 - 2016-11-27 -* Initial release \ No newline at end of file +* Initial release diff --git a/build.sbt b/build.sbt index 053a576..ec50fa6 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ val versions = new { } val commonSettings = Seq( - version := "1.0.2", + version := "1.0.3", scalaVersion := "2.11.8", crossScalaVersions := Seq("2.11.8","2.12.1"), organization := "io.github.jeremyrsmith", diff --git a/patchless-core/src/main/scala/patchless/Patch.scala b/patchless-core/src/main/scala/patchless/Patch.scala index a33fe00..64dea2b 100644 --- a/patchless-core/src/main/scala/patchless/Patch.scala +++ b/patchless-core/src/main/scala/patchless/Patch.scala @@ -11,6 +11,11 @@ import scala.language.dynamics abstract class Patch[T] extends (T => T) { type Updates <: HList def updates: Updates + + override def equals(obj: scala.Any): Boolean = obj match { + case patch: Patch[_] => patch.updates == updates + case _ => false + } } object Patch extends Dynamic { @@ -53,6 +58,7 @@ object Patch extends Dynamic { ) { def patchUpdates: U = patch.updates.asInstanceOf[U] } + } // Macros to support patch Apply syntax diff --git a/patchless-core/src/test/scala/patchless/PatchSpec.scala b/patchless-core/src/test/scala/patchless/PatchSpec.scala index d90ba19..c2ffba6 100644 --- a/patchless-core/src/test/scala/patchless/PatchSpec.scala +++ b/patchless-core/src/test/scala/patchless/PatchSpec.scala @@ -107,5 +107,11 @@ class PatchSpec extends FreeSpec with Matchers { } + "comparison" in { + case class Foo(a: Int, b: String) + Patch[Foo](a = 10) shouldEqual Patch[Foo](a = 10) + Patch[Foo](a = 10) shouldNot equal (Patch[Foo](a = 11)) + } + }