mirror of
https://github.com/github/semantic.git
synced 2024-12-24 15:35:14 +03:00
TDD FTW
This commit is contained in:
parent
9e118aac51
commit
1e276dddef
@ -207,6 +207,7 @@ test-suite test
|
||||
other-modules: Assigning.Assignment.Spec
|
||||
, Analysis.Go.Spec
|
||||
, Analysis.Python.Spec
|
||||
, Analysis.Ruby.Spec
|
||||
, Analysis.TypeScript.Spec
|
||||
, Data.Diff.Spec
|
||||
, Data.Functor.Classes.Generic.Spec
|
||||
|
29
test/Analysis/Ruby/Spec.hs
Normal file
29
test/Analysis/Ruby/Spec.hs
Normal file
@ -0,0 +1,29 @@
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
module Analysis.Ruby.Spec (spec) where
|
||||
|
||||
import Data.Abstract.Value
|
||||
import Data.Map
|
||||
|
||||
import SpecHelpers
|
||||
|
||||
|
||||
spec :: Spec
|
||||
spec = parallel $ do
|
||||
describe "evalutes Ruby" $ do
|
||||
it "require_relatives" $ do
|
||||
res <- evaluate "main.rb"
|
||||
let expectedEnv = Environment $ fromList [ (qualifiedName ["foo"], addr 0) ]
|
||||
assertEnvironment res expectedEnv
|
||||
|
||||
where
|
||||
assertEnvironment result expectedEnv = case result of
|
||||
Left e -> expectationFailure ("Evaluating expected to succeed, but failed with: " <> e)
|
||||
Right res -> let Just (Interface _ env) = prjValue @(Interface Precise) res in env `shouldBe` expectedEnv
|
||||
|
||||
addr = Address . Precise
|
||||
fixtures = "test/fixtures/ruby/analysis/"
|
||||
evaluate entry = fst . fst . fst . fst <$>
|
||||
evaluateFiles @RubyValue rubyParser
|
||||
[ fixtures <> entry
|
||||
, fixtures <> "foo.rb"
|
||||
]
|
@ -2,6 +2,7 @@ module Main where
|
||||
|
||||
import qualified Analysis.Go.Spec
|
||||
import qualified Analysis.Python.Spec
|
||||
import qualified Analysis.Ruby.Spec
|
||||
import qualified Analysis.TypeScript.Spec
|
||||
import qualified Assigning.Assignment.Spec
|
||||
import qualified Data.Diff.Spec
|
||||
@ -27,6 +28,7 @@ main = hspec $ do
|
||||
parallel $ do
|
||||
describe "Analysis.Go" Analysis.Go.Spec.spec
|
||||
describe "Analysis.Python" Analysis.Python.Spec.spec
|
||||
describe "Analysis.Ruby" Analysis.Ruby.Spec.spec
|
||||
describe "Analysis.TypeScript" Analysis.TypeScript.Spec.spec
|
||||
describe "Assigning.Assignment" Assigning.Assignment.Spec.spec
|
||||
describe "Data.Diff" Data.Diff.Spec.spec
|
||||
|
Loading…
Reference in New Issue
Block a user