aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/ParserSpec.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/scala/firrtlTests/ParserSpec.scala')
-rw-r--r--src/test/scala/firrtlTests/ParserSpec.scala59
1 files changed, 37 insertions, 22 deletions
diff --git a/src/test/scala/firrtlTests/ParserSpec.scala b/src/test/scala/firrtlTests/ParserSpec.scala
index bb7c2ab2..5003871d 100644
--- a/src/test/scala/firrtlTests/ParserSpec.scala
+++ b/src/test/scala/firrtlTests/ParserSpec.scala
@@ -129,29 +129,33 @@ class ParserSpec extends FirrtlFlatSpec {
firrtl.Parser.parse(c.serialize)
}
- an[UnsupportedVersionException] should be thrownBy {
- val input = """
- |FIRRTL version 1.2.0
- |circuit Test :
- | module Test :
- | input in : UInt<1>
- | in <= UInt(0)
- """.stripMargin
- firrtl.Parser.parse(input)
+ "Version 1.2.0" should "be rejected" in {
+ an[UnsupportedVersionException] should be thrownBy {
+ val input = """
+ |FIRRTL version 1.2.0
+ |circuit Test :
+ | module Test :
+ | input in : UInt<1>
+ | in <= UInt(0)
+ """.stripMargin
+ firrtl.Parser.parse(input)
+ }
}
- an[UnsupportedVersionException] should be thrownBy {
- val input = """
- |FIRRTL version 2.0.0
- |crcuit Test :
- | module Test @@#!# :
- | input in1 : UInt<2>
- | input in2 : UInt<3>
- | output out : UInt<4>
- | out[1:0] <= in1
- | out[3:2] <= in2[1:0]
- """.stripMargin
- firrtl.Parser.parse(input)
+ "Version 2.0.0" should "be rejected" in {
+ an[UnsupportedVersionException] should be thrownBy {
+ val input = """
+ |FIRRTL version 2.0.0
+ |crcuit Test :
+ | module Test @@#!# :
+ | input in1 : UInt<2>
+ | input in2 : UInt<3>
+ | output out : UInt<4>
+ | out[1:0] <= in1
+ | out[3:2] <= in2[1:0]
+ """.stripMargin
+ firrtl.Parser.parse(input)
+ }
}
// ********** Memories **********
@@ -379,7 +383,7 @@ class ParserSpec extends FirrtlFlatSpec {
}
}
- it should "be able to parse a MultiInfo as a FileInfo" in {
+ "The Parser" should "be able to parse a MultiInfo as a FileInfo" in {
// currently MultiInfo gets flattened into a single string which can only be recovered as a FileInfo
val info = ir.MultiInfo(Seq(ir.MultiInfo(Seq(ir.FileInfo("a"))), ir.FileInfo("b"), ir.FileInfo("c")))
val input =
@@ -390,6 +394,17 @@ class ParserSpec extends FirrtlFlatSpec {
val c = firrtl.Parser.parse(input)
assert(c.info == ir.FileInfo("a b c"))
}
+
+ it should "handle parse errors gracefully" in {
+ val input =
+ s"""circuit test :
+ | module test :
+ | output out :
+ |""".stripMargin
+ a[SyntaxErrorsException] should be thrownBy {
+ firrtl.Parser.parse(input)
+ }
+ }
}
class ParserPropSpec extends FirrtlPropSpec {