diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/chiselTests/Assert.scala | 28 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/Printf.scala | 28 |
2 files changed, 56 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/Assert.scala b/src/test/scala/chiselTests/Assert.scala new file mode 100644 index 00000000..31e53f36 --- /dev/null +++ b/src/test/scala/chiselTests/Assert.scala @@ -0,0 +1,28 @@ +// See LICENSE for license details. + +package chiselTests + +import org.scalatest._ +import Chisel._ +import Chisel.testers.BasicTester + +class FailingAssertTester() extends BasicTester { + assert(Bool(false)) + io.done := Bool(true) + io.error := Bool(false) +} + +class SucceedingAssertTester() extends BasicTester { + assert(Bool(true)) + io.done := Bool(true) + io.error := Bool(false) +} + +class AssertSpec extends ChiselFlatSpec { + "A failing assertion" should "fail the testbench" in { + assert(!execute{ new FailingAssertTester }) + } + "A succeeding assertion" should "not fail the testbench" in { + assert(execute{ new SucceedingAssertTester }) + } +} diff --git a/src/test/scala/chiselTests/Printf.scala b/src/test/scala/chiselTests/Printf.scala new file mode 100644 index 00000000..e6f5d222 --- /dev/null +++ b/src/test/scala/chiselTests/Printf.scala @@ -0,0 +1,28 @@ +// See LICENSE for license details. + +package chiselTests + +import org.scalatest._ +import Chisel._ +import Chisel.testers.BasicTester + +class SinglePrintfTester() extends BasicTester { + printf("done=%x", io.done) + io.done := Bool(true) + io.error := Bool(false) +} + +class MultiPrintfTester() extends BasicTester { + printf("done=%x error=%x", io.done, io.error) + io.done := Bool(true) + io.error := Bool(false) +} + +class PrintfSpec extends ChiselFlatSpec { + "A printf with a single argument" should "run" in { + assert(execute{ new SinglePrintfTester }) + } + "A printf with multiple arguments" should "run" in { + assert(execute{ new MultiPrintfTester }) + } +} |
