aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtl/testutils/PassTests.scala
diff options
context:
space:
mode:
authorchick2020-08-14 19:47:53 -0700
committerJack Koenig2020-08-14 19:47:53 -0700
commit6fc742bfaf5ee508a34189400a1a7dbffe3f1cac (patch)
tree2ed103ee80b0fba613c88a66af854ae9952610ce /src/test/scala/firrtl/testutils/PassTests.scala
parentb516293f703c4de86397862fee1897aded2ae140 (diff)
All of src/ formatted with scalafmt
Diffstat (limited to 'src/test/scala/firrtl/testutils/PassTests.scala')
-rw-r--r--src/test/scala/firrtl/testutils/PassTests.scala108
1 files changed, 56 insertions, 52 deletions
diff --git a/src/test/scala/firrtl/testutils/PassTests.scala b/src/test/scala/firrtl/testutils/PassTests.scala
index 49dea199..7a5dc306 100644
--- a/src/test/scala/firrtl/testutils/PassTests.scala
+++ b/src/test/scala/firrtl/testutils/PassTests.scala
@@ -15,49 +15,53 @@ import org.scalatest.flatspec.AnyFlatSpec
// An example methodology for testing Firrtl Passes
// Spec class should extend this class
abstract class SimpleTransformSpec extends AnyFlatSpec with FirrtlMatchers with Compiler with LazyLogging {
- // Utility function
- def squash(c: Circuit): Circuit = RemoveEmpty.run(c)
-
- // Executes the test. Call in tests.
- // annotations cannot have default value because scalatest trait Suite has a default value
- def execute(input: String, check: String, annotations: Seq[Annotation]): CircuitState = {
- val finalState = compileAndEmit(CircuitState(parse(input), ChirrtlForm, annotations))
- val actual = RemoveEmpty.run(parse(finalState.getEmittedCircuit.value)).serialize
- val expected = parse(check).serialize
- logger.debug(actual)
- logger.debug(expected)
- (actual) should be (expected)
- finalState
- }
-
- def executeWithAnnos(input: String, check: String, annotations: Seq[Annotation],
- checkAnnotations: Seq[Annotation]): CircuitState = {
- val finalState = compileAndEmit(CircuitState(parse(input), ChirrtlForm, annotations))
- val actual = RemoveEmpty.run(parse(finalState.getEmittedCircuit.value)).serialize
- val expected = parse(check).serialize
- logger.debug(actual)
- logger.debug(expected)
- (actual) should be (expected)
-
- annotations.foreach { anno =>
- logger.debug(anno.serialize)
- }
-
- finalState.annotations.toSeq.foreach { anno =>
- logger.debug(anno.serialize)
- }
- checkAnnotations.foreach { check =>
- (finalState.annotations.toSeq) should contain (check)
- }
- finalState
- }
- // Executes the test, should throw an error
- // No default to be consistent with execute
- def failingexecute(input: String, annotations: Seq[Annotation]): Exception = {
- intercept[PassExceptions] {
- compile(CircuitState(parse(input), ChirrtlForm, annotations), Seq.empty)
- }
- }
+ // Utility function
+ def squash(c: Circuit): Circuit = RemoveEmpty.run(c)
+
+ // Executes the test. Call in tests.
+ // annotations cannot have default value because scalatest trait Suite has a default value
+ def execute(input: String, check: String, annotations: Seq[Annotation]): CircuitState = {
+ val finalState = compileAndEmit(CircuitState(parse(input), ChirrtlForm, annotations))
+ val actual = RemoveEmpty.run(parse(finalState.getEmittedCircuit.value)).serialize
+ val expected = parse(check).serialize
+ logger.debug(actual)
+ logger.debug(expected)
+ (actual) should be(expected)
+ finalState
+ }
+
+ def executeWithAnnos(
+ input: String,
+ check: String,
+ annotations: Seq[Annotation],
+ checkAnnotations: Seq[Annotation]
+ ): CircuitState = {
+ val finalState = compileAndEmit(CircuitState(parse(input), ChirrtlForm, annotations))
+ val actual = RemoveEmpty.run(parse(finalState.getEmittedCircuit.value)).serialize
+ val expected = parse(check).serialize
+ logger.debug(actual)
+ logger.debug(expected)
+ (actual) should be(expected)
+
+ annotations.foreach { anno =>
+ logger.debug(anno.serialize)
+ }
+
+ finalState.annotations.toSeq.foreach { anno =>
+ logger.debug(anno.serialize)
+ }
+ checkAnnotations.foreach { check =>
+ (finalState.annotations.toSeq) should contain(check)
+ }
+ finalState
+ }
+ // Executes the test, should throw an error
+ // No default to be consistent with execute
+ def failingexecute(input: String, annotations: Seq[Annotation]): Exception = {
+ intercept[PassExceptions] {
+ compile(CircuitState(parse(input), ChirrtlForm, annotations), Seq.empty)
+ }
+ }
}
@deprecated(
@@ -86,19 +90,19 @@ object ReRunResolveAndCheck extends Transform with DependencyAPIMigration with I
}
trait LowTransformSpec extends SimpleTransformSpec {
- def emitter = new LowFirrtlEmitter
- def transform: Transform
- def transforms: Seq[Transform] = transform +: ReRunResolveAndCheck +: Forms.LowForm.map(_.getObject)
+ def emitter = new LowFirrtlEmitter
+ def transform: Transform
+ def transforms: Seq[Transform] = transform +: ReRunResolveAndCheck +: Forms.LowForm.map(_.getObject)
}
trait MiddleTransformSpec extends SimpleTransformSpec {
- def emitter = new MiddleFirrtlEmitter
- def transform: Transform
- def transforms: Seq[Transform] = transform +: ReRunResolveAndCheck +: Forms.MidForm.map(_.getObject)
+ def emitter = new MiddleFirrtlEmitter
+ def transform: Transform
+ def transforms: Seq[Transform] = transform +: ReRunResolveAndCheck +: Forms.MidForm.map(_.getObject)
}
trait HighTransformSpec extends SimpleTransformSpec {
- def emitter = new HighFirrtlEmitter
- def transform: Transform
- def transforms = transform +: ReRunResolveAndCheck +: Forms.HighForm.map(_.getObject)
+ def emitter = new HighFirrtlEmitter
+ def transform: Transform
+ def transforms = transform +: ReRunResolveAndCheck +: Forms.HighForm.map(_.getObject)
}