Skip to content

Commit ec365a2

Browse files
committed
ES: added tests for TrivialCaseElimination
1 parent ab4bf04 commit ec365a2

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{-# LANGUAGE OverloadedStrings, QuasiQuotes, ViewPatterns #-}
22
module Transformations.ExtendedSyntax.Optimising.TrivialCaseEliminationSpec where
33

4-
import Transformations.Optimising.TrivialCaseElimination
4+
import Transformations.ExtendedSyntax.Optimising.TrivialCaseElimination
55

66
import Test.Hspec
7-
import Grin.TH
8-
import Test.Test hiding (newVar)
9-
import Test.Assertions
7+
import Grin.ExtendedSyntax.TH
8+
import Test.ExtendedSyntax.New.Test hiding (newVar)
9+
import Test.ExtendedSyntax.Assertions
1010

1111

1212
runTests :: IO ()
@@ -18,35 +18,36 @@ spec = do
1818
it "Figure 4.24" $ do
1919
let before = [expr|
2020
case v of
21-
(Ffun a1 a2 a3) -> fun a1 a2 a3
21+
(Ffun a1 a2 a3) @ alt1 -> fun a1 a2 a3
2222
|]
2323
let after = [expr|
2424
do
25-
(Ffun a1 a2 a3) <- pure v
25+
(Ffun a1 a2 a3) @ alt1 <- pure v
2626
fun a1 a2 a3
2727
|]
2828
trivialCaseElimination (ctx before) `sameAs` (ctx after)
2929

3030
it "bypass" $ do
3131
let before = [expr|
3232
case v of
33-
(Ffun1 a1 a2 a3) -> fun1 a1 a2 a3
34-
#default -> pure 2
33+
(Ffun1 a1 a2 a3) @ alt1 -> fun1 a1 a2 a3
34+
#default @ alt2 -> pure 2
3535
|]
3636
let after = [expr|
3737
case v of
38-
(Ffun1 a1 a2 a3) -> fun1 a1 a2 a3
39-
#default -> pure 2
38+
(Ffun1 a1 a2 a3) @ alt1 -> fun1 a1 a2 a3
39+
#default @ alt2 -> pure 2
4040
|]
4141
trivialCaseElimination (ctx before) `sameAs` (ctx after)
4242

4343
it "default alternative" $ do
4444
let before = [expr|
4545
case v of
46-
#default -> pure 2
46+
#default @ alt1 -> pure 2
4747
|]
4848
let after = [expr|
4949
do
50+
alt1 <- pure v
5051
pure 2
5152
|]
5253
trivialCaseElimination (ctx before) `sameAs` (ctx after)

0 commit comments

Comments
 (0)