From 44bd42587532755439fcdc175eb95604966bbea8 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 5 Nov 2017 14:12:48 -0800 Subject: Add a simple consistency checker on `Discovered` to test if any of the observable `Target`s in the given base are not being properly cached --- core/src/main/scala/forge/discover/Discovered.scala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core/src/main/scala/forge/discover') diff --git a/core/src/main/scala/forge/discover/Discovered.scala b/core/src/main/scala/forge/discover/Discovered.scala index 964732be..8d340569 100644 --- a/core/src/main/scala/forge/discover/Discovered.scala +++ b/core/src/main/scala/forge/discover/Discovered.scala @@ -12,6 +12,13 @@ class Discovered[T](val value: Seq[(Seq[String], Format[_], T => Target[_])]){ } object Discovered { + def consistencyCheck[T](base: T, d: Discovered[T]) = { + val inconsistent = for{ + (path, formatter, targetGen) <- d.value + if targetGen(base) ne targetGen(base) + } yield path + inconsistent + } def makeTuple[T, V](path: Seq[String], func: T => Target[V])(implicit f: Format[V]) = { (path, f, func) } -- cgit v1.2.3