File: JavaSpec.hs

package info (click to toggle)
bnfc 2.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,252 kB
  • sloc: haskell: 16,607; yacc: 240; makefile: 85
file content (24 lines) | stat: -rw-r--r-- 720 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module BNFC.Backend.JavaSpec where

import BNFC.Options
import BNFC.GetCF

import Test.Hspec
import BNFC.Hspec
import BNFC.Backend.Java -- SUT

calcOptions = defaultOptions { lang = "Calc" }
getCalc = parseCF  calcOptions TargetJava $
  unlines [ "EAdd. Exp ::= Exp \"+\" Exp1  ;"
          , "ESub. Exp ::= Exp \"-\" Exp1  ;"
          , "EMul. Exp1  ::= Exp1  \"*\" Exp2  ;"
          , "EDiv. Exp1  ::= Exp1  \"/\" Exp2  ;"
          , "EInt. Exp2  ::= Integer ;"
          , "coercions Exp 2 ;" ]

spec = do
  describe "Java backend" $
    it "respect the makefile option" $ do
      calc <- getCalc
      let opts = calcOptions { optMake = Just "MyMakefile" }
      makeJava opts calc `shouldGenerate` "MyMakefile"