1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 17:04:47 +03:00
semantic/test/Analysis/PHP/Spec.hs
2018-03-20 16:46:32 -07:00

34 lines
914 B
Haskell

{-# LANGUAGE OverloadedLists #-}
module Analysis.PHP.Spec (spec) where
import Data.Abstract.Value
import Data.Map
import SpecHelpers
spec :: Spec
spec = parallel $ do
describe "evalutes PHP" $ do
it "include and require" $ do
env <- evaluate "main.php"
let expectedEnv = [ (qualifiedName ["foo"], addr 0)
, (qualifiedName ["bar"], addr 1) ]
env `shouldBe` expectedEnv
it "include_once and require_once" $ do
env <- evaluate "main_once.php"
let expectedEnv = [ (qualifiedName ["foo"], addr 0)
, (qualifiedName ["bar"], addr 1) ]
env `shouldBe` expectedEnv
where
addr = Address . Precise
fixtures = "test/fixtures/php/analysis/"
evaluate entry = snd . fst . fst . fst . fst <$>
evaluateFiles phpParser
[ fixtures <> entry
, fixtures <> "foo.php"
, fixtures <> "bar.php"
]