Skip to content

Commit

Permalink
fixes a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ArquintL committed Mar 10, 2023
1 parent a2b9b6c commit 04874c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/main/scala/viper/gobra/ast/frontend/PrettyPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class DefaultPrettyPrinter extends PrettyPrinter with kiama.output.PrettyPrinter
def show(node: PNode): Doc = node match {
case n: PPackage => showPackage(n)
case n: PProgram => showProgram(n)
case n: PPreamble => showPreamble(n)
case n: PPackageClause => showPackageClause(n)
case n: PImport => showImport(n)
case n: PMember => showMember(n)
Expand Down Expand Up @@ -61,12 +62,22 @@ class DefaultPrettyPrinter extends PrettyPrinter with kiama.output.PrettyPrinter

def showProgram(p: PProgram): Doc = p match {
case PProgram(packageClause, progPosts, imports, declarations) =>
vcat(progPosts.map("initEnsures" <+> showExpr(_))) <>
showPackageClause(packageClause) <> line <> line <>
ssep(imports map showImport, line) <> line <>
showPreamble(packageClause, progPosts, imports) <>
ssep(declarations map showMember, line <> line) <> line
}

// preamble

def showPreamble(p: PPreamble): Doc = p match {
case PPreamble(packageClause, progPosts, imports) =>
showPreamble(packageClause, progPosts, imports)
}

private def showPreamble(packageClause: PPackageClause, progPosts: Vector[PExpression], imports: Vector[PImport]): Doc =
vcat(progPosts.map("initEnsures" <+> showExpr(_))) <>
showPackageClause(packageClause) <> line <> line <>
ssep(imports map showImport, line) <> line

// package

def showPackageClause(node: PPackageClause): Doc = "package" <+> showPackageId(node.id)
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/viper/gobra/frontend/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object Desugar extends LazyLogging {
// registers main package to generate proof obligations for its init code
mainDesugarer.registerMainPackage(pkg, importsCollector)(config)
val res = (mainDesugarer, mainDesugarer.packageD(pkg))
logger.debug {
logger.trace {
val durationS = f"${(System.currentTimeMillis() - mainDesugaringStartMs) / 1000f}%.1f"
s"desugaring package ${info.pkgInfo.id} done, took ${durationS}s"
}
Expand All @@ -68,7 +68,7 @@ object Desugar extends LazyLogging {
val futResults = Await.result(allPackagesFut, Duration.Inf)
val (mainDesugarer, mainProgram) = futResults.head
val importedPrograms = futResults.tail
logger.debug {
logger.trace {
val importedDurationS = f"${importeDesugaringDurationMs.get() / 1000f}%.1f"
s"desugaring imported packages done, took ${importedDurationS}s"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package pkg

// ##(-I src/test/resources/regressions/features/errors)
// ##(-I ./)
import . "bar"

func foo(e error) int {
Expand Down

0 comments on commit 04874c9

Please sign in to comment.