-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests to printing Scala code - fix extra space after package decl…
…aration
- Loading branch information
lemastero
committed
Apr 30, 2024
1 parent
8ea4c25
commit 4b76a54
Showing
4 changed files
with
55 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Main (main) where | ||
|
||
import Test.HUnit ( | ||
Test(..) | ||
, failures | ||
, runTestTT | ||
) | ||
import System.Exit ( exitFailure , exitSuccess ) | ||
|
||
import PrintScalaExprTest ( printScalaTests ) | ||
import ScalaBackendTest ( backendTests ) | ||
|
||
allTests :: Test | ||
allTests = TestList [ backendTests , printScalaTests ] | ||
|
||
main :: IO () | ||
main = do | ||
result <- runTestTT allTests | ||
if (failures result) > 0 then exitFailure else exitSuccess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module PrintScalaExprTest ( printScalaTests ) where | ||
|
||
import Test.HUnit ( Test(..), assertEqual ) | ||
import Agda.Compiler.Scala.PrintScalaExpr ( | ||
printSealedTrait | ||
, printCaseObject | ||
, printPackage | ||
) | ||
|
||
testPrintCaseObject :: Test | ||
testPrintCaseObject = TestCase | ||
(assertEqual "printCaseObject" (printCaseObject "Color" "Light") "case object Light extends Color") | ||
|
||
testPrintSealedTrait :: Test | ||
testPrintSealedTrait = TestCase | ||
(assertEqual "printSealedTrait" (printSealedTrait "Color") "sealed trait Color") | ||
|
||
testPrintPackage :: Test | ||
testPrintPackage = TestCase | ||
(assertEqual "printPackage" (printPackage "adts") "package adts") | ||
|
||
printScalaTests :: Test | ||
printScalaTests = TestList [ | ||
TestLabel "printCaseObject" testPrintCaseObject | ||
, TestLabel "printSealedTrait" testPrintSealedTrait | ||
, TestLabel "printPackage" testPrintPackage | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,12 @@ | ||
module Main (main) where | ||
module ScalaBackendTest ( backendTests ) where | ||
|
||
import Agda.Compiler.Scala.Backend ( scalaBackend', defaultOptions ) | ||
import Test.HUnit ( | ||
Test(..) | ||
, assertEqual | ||
, failures | ||
, runTestTT) | ||
import System.Exit ( exitFailure , exitSuccess ) | ||
import Test.HUnit ( Test(..), assertEqual ) | ||
import Agda.Compiler.Backend ( isEnabled ) | ||
import Agda.Compiler.Scala.Backend ( scalaBackend', defaultOptions ) | ||
|
||
testIsEnabled :: Test | ||
testIsEnabled = TestCase | ||
(assertEqual "isEnabled" (isEnabled scalaBackend' defaultOptions) True) | ||
|
||
tests :: Test | ||
tests = TestList [TestLabel "scalaBackend" testIsEnabled] | ||
|
||
main :: IO () | ||
main = do | ||
result <- runTestTT tests | ||
if failures result > 0 then exitFailure else exitSuccess | ||
backendTests :: Test | ||
backendTests = TestList [TestLabel "scalaBackend" testIsEnabled] |