module Latte.Compile.CommonsSpec (main, spec) where

import Test.Hspec

import Latte.Commons
import Latte.Compile.Commons

main :: IO ()
main = hspec spec

spec :: Spec
spec = do
    describe "Next label number" $ do
        it "call from 0 status" $ do
            let entryState = initialCompileState
            (nextLabel entryState) `shouldBe` 0
            let result = runRunner giveLabelNumber entryState
            (>>=) result $ shouldBe $ Right (0, entryState { nextLabel = 1 }) 
        it "call from 3 times" $ do
            let entryState = initialCompileState
            (nextLabel entryState) `shouldBe` 0
            let result = runRunner (giveLabelNumber >> giveLabelNumber >> giveLabelNumber) entryState
            (>>=) result $ shouldBe $ Right (2, entryState { nextLabel = 3 }) 
