-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Showing
2 changed files
with
31 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
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,25 @@ | ||
package nrktkt.ninny | ||
|
||
import org.scalatest._ | ||
import org.scalatest.flatspec._ | ||
import org.scalatest.matchers._ | ||
import io.github.kag0.ninny.ast._ | ||
|
||
class ToJsonInstancesSpec extends AnyFlatSpec with should.Matchers { | ||
"Either values" should | ||
"convert right to json" in { | ||
val right = Right[Int, String]("test") | ||
val either: Either[Int, String] = right | ||
val expected = Some(JsonString("test")) | ||
right.toJson shouldEqual expected | ||
either.toJson shouldEqual expected | ||
} | ||
|
||
it should "convert left to json" in { | ||
val left = Left[Int, String](5) | ||
val either: Either[Int, String] = left | ||
val expected = Some(JsonNumber(5)) | ||
left.toJson shouldEqual expected | ||
either.toJson shouldEqual expected | ||
} | ||
} |