Skip to content

Commit

Permalink
Minor refactoring of PotMap/PotVector construction.
Browse files Browse the repository at this point in the history
Dropped support for Scala 2.10
  • Loading branch information
ochrons committed Dec 30, 2015
1 parent a8c0e87 commit dca598a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: scala
scala:
- 2.10.5
- 2.11.7
sudo: false
jdk:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbt._
import Keys._
import com.typesafe.sbt.pgp.PgpKeys._

crossScalaVersions := Seq("2.11.7", "2.10.5")
crossScalaVersions := Seq("2.11.7")

val commonSettings = Seq(
organization := "me.chrons",
Expand Down
4 changes: 2 additions & 2 deletions diode/shared/src/main/scala/diode/data/PotMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package diode.data

class PotMap[K, V](
private val fetcher: Fetch[K],
private val elems: Map[K, Pot[V]] = Map.empty[K, Pot[V]]
private val elems: Map[K, Pot[V]]
) extends PotCollection[K, V] {

override def updated(key: K, value: Pot[V]): PotMap[K, V] =
Expand Down Expand Up @@ -101,5 +101,5 @@ class PotMap[K, V](
}

object PotMap {
def apply[K, V](fetcher: Fetch[K]) = new PotMap[K, V](fetcher)
def apply[K, V](fetcher: Fetch[K], elems: Map[K, Pot[V]] = Map.empty[K, Pot[V]]) = new PotMap[K, V](fetcher, elems)
}
2 changes: 1 addition & 1 deletion diode/shared/src/main/scala/diode/data/PotVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.util
class PotVector[V](
private val fetcher: Fetch[Int],
private val length: Int,
private val elems: Array[Option[Pot[V]]] = Array.empty[Option[Pot[V]]]
private val elems: Array[Option[Pot[V]]]
) extends PotCollection[Int, V] {

private def enlarge[V](newSize: Int) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ object PotActionTests extends TestSuite {
}
}
'CollectionHandler - {
val model = CollModel(new PotMap[String, String](fetcher))
val model = CollModel(PotMap[String, String](fetcher))
val modelRW = new RootModelRW(model)
val handler = new TestCollHandler(modelRW.zoomRW(_.c)((m, v) => m.copy(c = v)), Set("A"))
'empty - {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object PotCollectionTests extends TestSuite {
}
'get - {
val fetcher = new TestFetcher[String]
val m = new PotMap[String, String](fetcher)
val m = PotMap[String, String](fetcher)
val m1 = m + ("test1" -> Ready("Yeaa"))
assert(m1.get("test2").isPending)
assert(fetcher.lastFetch == "test2")
Expand Down
7 changes: 4 additions & 3 deletions diode/shared/src/test/scala/diode/data/RefToTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import diode.RootModelRW
import utest._

object RefToTests extends TestSuite {

case class Model(users: PotMap[String, User], employees: Seq[Employee])

case class User(name: String)

case class Employee(role: String, user: RefTo[Pot[User]])

class TestFetcher[K] extends Fetch[K] {
var lastFetch:Any = _
var lastFetch: Any = _
override def fetch(key: K): Unit = lastFetch = key
override def fetch(start: K, end: K): Unit = lastFetch = (start, end)
override def fetch(keys: Traversable[K]): Unit = lastFetch = keys
Expand All @@ -20,9 +21,9 @@ object RefToTests extends TestSuite {
def tests = TestSuite {
'refToMap - {
val fetcher = new TestFetcher[String]
val root = Model(new PotMap(fetcher, Map("ceoID" -> Ready(User("Ms. CEO")))), Seq())
val root = Model(PotMap(fetcher, Map("ceoID" -> Ready(User("Ms. CEO")))), Seq())
val modelRW = new RootModelRW[Model](root)
val m = root.copy(employees = Seq(Employee("CEO", RefTo("ceoID", modelRW.zoom(_.users))( (id, value) => s"Update $id to $value"))))
val m = root.copy(employees = Seq(Employee("CEO", RefTo("ceoID", modelRW.zoom(_.users))((id, value) => s"Update $id to $value"))))
assert(m.employees.head.user().get.name == "Ms. CEO")
assert(m.employees.head.user.updateAction(Ready(User("Ms. Kathy CEO"))) == "Update ceoID to Ready(User(Ms. Kathy CEO))")
}
Expand Down

0 comments on commit dca598a

Please sign in to comment.