Skip to content

Commit

Permalink
change module name interpret as object name not package name - fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lemastero committed Apr 30, 2024
1 parent c5abcb6 commit 9f31cec
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion examples/adts.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package adts
object adts {

sealed trait Rgb
case object Red extends Rgb
Expand All @@ -12,3 +12,4 @@ case object False extends Bool
def idRgb(x: Rgb): Rgb = x

final case class RgbPair(snd: Bool, fst: Rgb)
}
2 changes: 0 additions & 2 deletions src/Agda/Compiler/Scala/Backend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ scalaPostModule :: ScalaEnv
scalaPostModule env modEnv isMain mName cdefs = do
outDir <- compileDir
compileLog $ "compiling " <> mkOutFile outDir
compileLog $ "scalaExprs " <> (show scalaExprs)
compileLog $ "fileContent " <> fileContent
unless (all unHandled cdefs)
$ liftIO
$ writeFile (mkOutFile outDir) fileContent
Expand Down
6 changes: 3 additions & 3 deletions src/Agda/Compiler/Scala/PrintScalaExpr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import Agda.Compiler.Scala.ScalaExpr ( ScalaName, ScalaExpr(..), SeVar(..))
printScalaExpr :: ScalaExpr -> String
printScalaExpr def = case def of
(SePackage pName defs) ->
(printPackage pName) <> defsSeparator
<> (
(printPackage pName) <> exprSeparator -- TODO this should be package + object
<> bracket (
blankLine -- between package declaration and first definition
<> combineLines (map printScalaExpr defs)
)
Expand Down Expand Up @@ -54,7 +54,7 @@ printCaseObject superName caseName =
"case object" <> exprSeparator <> caseName <> exprSeparator <> "extends" <> exprSeparator <> superName

printPackage :: ScalaName -> String
printPackage pName = "package" <> exprSeparator <> pName
printPackage pName = "object" <> exprSeparator <> pName

bracket :: String -> String
bracket str = "{\n" <> str <> "\n}"
Expand Down
14 changes: 7 additions & 7 deletions test/PrintScalaExprTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ testPrintSealedTrait = TestCase
"sealed trait Color"
(printSealedTrait "Color"))

testPrintPackage :: Test
testPrintPackage = TestCase
(assertEqual "printPackage"
"package adts"
(printPackage "adts"))
--testPrintPackage :: Test
--testPrintPackage = TestCase
-- (assertEqual "printPackage"
-- "package adts"
-- (printPackage "adts"))

testCombineLines :: Test
testCombineLines = TestCase
Expand All @@ -38,7 +38,7 @@ testCombineLines = TestCase
testPrintScalaExpr :: Test
testPrintScalaExpr = TestCase
(assertEqual "printScalaExpr" (printScalaExpr $ SePackage "adts" moduleContent)
"package adts\n\nsealed trait Rgb\ncase object Red extends Rgb\ncase object Green extends Rgb\ncase object Blue extends Rgb\n\nsealed trait Color\ncase object Light extends Color\ncase object Dark extends Color\n"
"object adts {\n\nsealed trait Rgb\ncase object Red extends Rgb\ncase object Green extends Rgb\ncase object Blue extends Rgb\n\nsealed trait Color\ncase object Light extends Color\ncase object Dark extends Color\n}\n"
)
where
moduleContent = [rgbAdt, blank, blank, blank, colorAdt, blank, blank]
Expand All @@ -57,7 +57,7 @@ printScalaTests :: Test
printScalaTests = TestList [
TestLabel "printCaseObject" testPrintCaseObject
, TestLabel "printSealedTrait" testPrintSealedTrait
, TestLabel "printPackage" testPrintPackage
-- , TestLabel "printPackage" testPrintPackage
, TestLabel "combineLines" testCombineLines
, TestLabel "printCaseClass" testPrintCaseClass
, TestLabel "printScalaExpr" testPrintScalaExpr
Expand Down

0 comments on commit 9f31cec

Please sign in to comment.