-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from theiterators/fix/implementation_from_method
Fixed from implementation
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tagged-meta/src/test/scala/TaggedAnnotationFromMethodTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import org.scalatest._ | ||
import pl.iterators.kebs.tagged._ | ||
import pl.iterators.kebs.tag.meta.tagged | ||
import org.scalatest.funsuite.AnyFunSuite | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
@tagged object DomainTrimmedString { | ||
trait NameTag | ||
type Name = String @@ NameTag | ||
|
||
object Name { | ||
sealed trait Error | ||
case object Empty extends Error | ||
|
||
def validate(name: String) = if (name.trim.isEmpty) Left(Empty) else Right(name.trim) | ||
} | ||
} | ||
|
||
class TaggedAnnotationFromMethodTest extends AnyFunSuite with Matchers with EitherValues { | ||
import DomainTrimmedString._ | ||
|
||
test("from method must use result from validation") { | ||
Name(" name ") shouldEqual "name" | ||
} | ||
|
||
test("from method must forward Error value") { | ||
intercept[Exception] { | ||
Name(" ") | ||
} | ||
} | ||
} |