From eb0841d27f5cd077c5f27f339ef9eb86cbe64599 Mon Sep 17 00:00:00 2001 From: Jared Barocsi Date: Fri, 18 Jun 2021 09:05:17 -0700 Subject: Fix MultiInfo parser + serialization bug (#2265) * Restore parsed MultiInfo structure in firrtl parser * Change erroneous expected output in InfoSpec test FileInfo compression sorts the outputted entries alphabetically, but this test did not reflect that fact * Fix typo in comment * Add unit tests for file locator parsing * Fix syntax issues and typos * More redundant braces removed Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>--- src/test/scala/firrtlTests/InfoSpec.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/InfoSpec.scala b/src/test/scala/firrtlTests/InfoSpec.scala index 85b4efac..99000d37 100644 --- a/src/test/scala/firrtlTests/InfoSpec.scala +++ b/src/test/scala/firrtlTests/InfoSpec.scala @@ -288,7 +288,7 @@ class InfoSpec extends FirrtlFlatSpec with FirrtlMatchers { " wire [31:0] a = c ? b : d; // @[A 1:{2,3,4} B 2:3 4:5]" ) result("A 2:3", "B 1:{2,3,4}", "C 4:5") should containLine( - " wire [31:0] a = c ? b : d; // @[B 1:{2,3,4} A 2:3 C 4:5]" + " wire [31:0] a = c ? b : d; // @[A 2:3 B 1:{2,3,4} C 4:5]" ) } @@ -321,4 +321,17 @@ class InfoSpec extends FirrtlFlatSpec with FirrtlMatchers { for (line <- check) result should containLine(line) } + + "Source Locators" should "not lose information when going through serialization + parsing" in { + def check(info: ir.Info): Unit = { + assert(Parser.parseInfo(info.serialize) == info) + } + + check(ir.NoInfo) + check(ir.FileInfo("B")) + check(ir.FileInfo("A 4:5")) + check(ir.FileInfo("A 4:6")) + check(ir.MultiInfo(ir.FileInfo("A 4:5"), ir.FileInfo("B 5:5"))) + check(ir.MultiInfo(ir.FileInfo("A 4:5"), ir.FileInfo("A 5:5"))) + } } -- cgit v1.2.3