From 976810c78f43f8e9087f53463d32ce321f1184d1 Mon Sep 17 00:00:00 2001 From: jackkoenig Date: Wed, 13 Apr 2016 17:35:50 -0700 Subject: Add "normalize" function to FirrtlSpec for easier string comparison testing --- src/test/scala/firrtlTests/FirrtlSpec.scala | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/test/scala/firrtlTests/FirrtlSpec.scala b/src/test/scala/firrtlTests/FirrtlSpec.scala index 930100b3..8e1dd8cb 100644 --- a/src/test/scala/firrtlTests/FirrtlSpec.scala +++ b/src/test/scala/firrtlTests/FirrtlSpec.scala @@ -29,6 +29,7 @@ package firrtlTests import java.io._ +import com.typesafe.scalalogging.LazyLogging import scala.sys.process._ import org.scalatest._ import org.scalatest.prop._ @@ -146,7 +147,17 @@ trait FirrtlRunners extends BackendCompilationUtilities { } } -class FirrtlPropSpec extends PropSpec with PropertyChecks with FirrtlRunners +trait FirrtlMatchers { + // Replace all whitespace with a single space and remove leading and + // trailing whitespace + // Note this is intended for single-line strings, no newlines + def normalized(s: String): String = { + require(!s.contains("\n")) + s.replaceAll("\\s+", " ").trim + } +} + +class FirrtlPropSpec extends PropSpec with PropertyChecks with FirrtlRunners with LazyLogging -class FirrtlFlatSpec extends FlatSpec with Matchers with FirrtlRunners +class FirrtlFlatSpec extends FlatSpec with Matchers with FirrtlRunners with FirrtlMatchers with LazyLogging -- cgit v1.2.3