diff options
| author | Kevin Laeufer | 2020-07-15 12:21:26 -0700 |
|---|---|---|
| committer | GitHub | 2020-07-15 19:21:26 +0000 |
| commit | 24be0ac3121e8f5d7b4bf8d6247e305ed0f0a656 (patch) | |
| tree | 9acbdf85c86985921a84fa329838062a78e71588 /src/test/scala/firrtlTests/InfoSpec.scala | |
| parent | 005a3d1644742029e744a64c2d9c452969bc64ff (diff) | |
ir: store FileInfo string in escaped format (#1690)
This should speed up the common case
as the compiler never operates on the
unescaped string.
The new escape function also fixes a bug
where ']' was not escaped even though it
is the delimiting character for FileInfo.
In order to maintain backwards
compatibility for the ProtoBuf format,
this patch adds escape/unescape calls
when going from/to protobuf format.
For better performance we should consider
changing the protobuf format.
Diffstat (limited to 'src/test/scala/firrtlTests/InfoSpec.scala')
| -rw-r--r-- | src/test/scala/firrtlTests/InfoSpec.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/InfoSpec.scala b/src/test/scala/firrtlTests/InfoSpec.scala index 48567d69..01e0a0ac 100644 --- a/src/test/scala/firrtlTests/InfoSpec.scala +++ b/src/test/scala/firrtlTests/InfoSpec.scala @@ -172,4 +172,27 @@ class InfoSpec extends FirrtlFlatSpec with FirrtlMatchers { val expectedInfos = Seq(FileInfo(StringLit("Top.scala 15:14")), FileInfo(StringLit("myfile.fir 6:4"))) circuitState should containTree { case MultiInfo(`expectedInfos`) => true } } + + "FileInfo" should "be able to contain a escaped characters" in { + def input(info: String): String = + s"""circuit m: @[$info] + | module m: + | skip + |""".stripMargin + def parseInfo(info: String): FileInfo = { + firrtl.Parser.parse(input(info)).info.asInstanceOf[FileInfo] + } + + parseInfo("test\\ntest").escaped should be ("test\\ntest") + parseInfo("test\\ntest").unescaped should be ("test\ntest") + parseInfo("test\\ttest").escaped should be ("test\\ttest") + parseInfo("test\\ttest").unescaped should be ("test\ttest") + parseInfo("test\\\\test").escaped should be ("test\\\\test") + parseInfo("test\\\\test").unescaped should be ("test\\test") + parseInfo("test\\]test").escaped should be ("test\\]test") + parseInfo("test\\]test").unescaped should be ("test]test") + parseInfo("test[\\][\\]test").escaped should be ("test[\\][\\]test") + parseInfo("test[\\][\\]test").unescaped should be ("test[][]test") + } + } |
