diff options
| author | jackkoenig | 2016-04-13 17:35:50 -0700 |
|---|---|---|
| committer | jackkoenig | 2016-04-22 13:46:15 -0700 |
| commit | 976810c78f43f8e9087f53463d32ce321f1184d1 (patch) | |
| tree | 5202a53f1e1d461a65e957a7c7d8ab055bfc9c6a /src | |
| parent | 6fcf8bcf215106d3c34a5d33ad89fa5a1adaa4db (diff) | |
Add "normalize" function to FirrtlSpec for easier string comparison testing
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/scala/firrtlTests/FirrtlSpec.scala | 15 |
1 files changed, 13 insertions, 2 deletions
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 |
