-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dave Gurnell
committed
Oct 5, 2011
1 parent
35277bd
commit bba0d8e
Showing
6 changed files
with
117 additions
and
41 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
name := "real-paths" | ||
|
||
version := "0.1" | ||
|
||
libraryDependencies += "org.scala-tools.testing" %% "specs" % "1.6.9" % "test" |
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
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
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,37 @@ | ||
import org.specs._ | ||
|
||
class ArgSpec extends Specification { | ||
|
||
"IntArg.encode encodes as expected" in { | ||
IntArg.encode(123) mustEqual "123" | ||
} | ||
|
||
"IntArg.decode decodes integers correctly" in { | ||
IntArg.decode("123") must beSome(123) | ||
} | ||
|
||
"IntArg.decode only decodes integers" in { | ||
IntArg.decode("abc") must beNone | ||
} | ||
|
||
"StringArg.encode unescapes reserved characters" in { | ||
StringArg.encode("a/b") mustEqual "a%2Fb" | ||
} | ||
|
||
"StringArg.decode escapes reserved characters" in { | ||
StringArg.decode("a%2Fb") must beSome("a/b") | ||
} | ||
|
||
"LiteralArg.encode encodes to a literal" in { | ||
LiteralArg("anything").encode(()) mustEqual "anything" | ||
} | ||
|
||
"LiteralArg.decode decodes to Unit" in { | ||
LiteralArg("anything").decode("anything") must beSome(()) | ||
} | ||
|
||
"LiteralArg.decode only decodes the correct path segment" in { | ||
LiteralArg("anything").decode("nothing") must beNone | ||
} | ||
|
||
} |
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,15 @@ | ||
import org.specs._ | ||
|
||
class HListSpec extends Specification { | ||
|
||
"HLists can have heterogeneous arguments" in { | ||
val list = 2.0 :: 1 :: HNil | ||
|
||
list.head must be_==(2.0) | ||
list.tail must be_==(HCons(1, HNil)) | ||
|
||
list.tail.head must be_==(1) | ||
list.tail.tail must be_==(HNil) | ||
} | ||
|
||
} |
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,16 @@ | ||
import org.specs._ | ||
|
||
class PathSpec extends Specification { | ||
|
||
val path = StringArg :/: IntArg :/: PNil | ||
|
||
"Path.encode works as expected" in { | ||
path.encode(HCons("abc", HCons(123, HNil))) mustEqual List("abc", "123") | ||
} | ||
|
||
"Path.decode works as expected" in { | ||
path.decode(List("abc", "123")) must beSome(HCons("abc", HCons(123, HNil))) | ||
path.decode(List("123", "abc")) must beNone | ||
} | ||
|
||
} |