aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSchuyler Eldridge2018-11-05 16:54:42 -0500
committerGitHub2018-11-05 16:54:42 -0500
commitd04af59c233cec994087df3d0d3fff14e20ac04c (patch)
tree0b7ae45a3901986a40bf06abad24adf3ea6fe15d /src/test
parent3935914116d7289a8b545cc8d758785d9f8dcd13 (diff)
parent2fdc984223393ee4996f7f7fde8d6b12c9fe36c3 (diff)
Merge pull request #932 from seldridge/f269
- Add Target.prettyPrint method - Improve UninferredWidth exception message
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/WidthSpec.scala25
-rw-r--r--src/test/scala/firrtlTests/annotationTests/TargetSpec.scala28
2 files changed, 52 insertions, 1 deletions
diff --git a/src/test/scala/firrtlTests/WidthSpec.scala b/src/test/scala/firrtlTests/WidthSpec.scala
index ab8cb7ac..058cc1fa 100644
--- a/src/test/scala/firrtlTests/WidthSpec.scala
+++ b/src/test/scala/firrtlTests/WidthSpec.scala
@@ -156,4 +156,29 @@ class WidthSpec extends FirrtlFlatSpec {
executeTest(input, check, passes)
}
}
+
+ behavior of "CheckWidths.UniferredWidth"
+
+ it should "provide a good error message with a full target if a user forgets an assign" in {
+ val passes = Seq(
+ ToWorkingIR,
+ ResolveKinds,
+ InferTypes,
+ CheckTypes,
+ ResolveGenders,
+ InferWidths,
+ CheckWidths)
+ val input =
+ """|circuit Foo :
+ | module Foo :
+ | input clock : Clock
+ | inst bar of Bar
+ | module Bar :
+ | wire a: { b : UInt<1>, c : { d : UInt<1>, e : UInt } }
+ |""".stripMargin
+ val msg = intercept[CheckWidths.UninferredWidth] { executeTest(input, Nil, passes) }
+ .getMessage should include ("""| circuit Foo:
+ | └── module Bar:
+ | └── a.c.e""".stripMargin)
+ }
}
diff --git a/src/test/scala/firrtlTests/annotationTests/TargetSpec.scala b/src/test/scala/firrtlTests/annotationTests/TargetSpec.scala
index 4ae4e036..da154b6a 100644
--- a/src/test/scala/firrtlTests/annotationTests/TargetSpec.scala
+++ b/src/test/scala/firrtlTests/annotationTests/TargetSpec.scala
@@ -55,5 +55,31 @@ class TargetSpec extends FirrtlPropSpec {
assert(Target.deserialize(t.serialize) == t, s"$t does not properly serialize/deserialize")
}
}
+ property("Pretty Printer should work") {
+ val circuit = CircuitTarget("A")
+ val top = circuit.module("B")
+ val targets = Seq(
+ (circuit, "circuit A:"),
+ (top,
+ """|circuit A:
+ |└── module B:""".stripMargin),
+ (top.instOf("c", "C"),
+ """|circuit A:
+ |└── module B:
+ | └── inst c of C:""".stripMargin),
+ (top.ref("r"),
+ """|circuit A:
+ |└── module B:
+ | └── r""".stripMargin),
+ (top.ref("r").index(1).field("hi").clock,
+ """|circuit A:
+ |└── module B:
+ | └── r[1].hi@clock""".stripMargin),
+ (GenericTarget(None, None, Vector(Ref("r"))),
+ """|circuit ???:
+ |└── module ???:
+ | └── r""".stripMargin)
+ )
+ targets.foreach { case (t, str) => assert(t.prettyPrint() == str, s"$t didn't properly prettyPrint") }
+ }
}
-