mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Correct the tests.
This commit is contained in:
parent
1c9ad27288
commit
0ec9584a6d
@ -31,7 +31,6 @@ import Control.Monad.Free as Free
|
||||
import Control.Monad.Trans.Free as FreeF
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Char (chr)
|
||||
import Data.Functor.Binding
|
||||
import Data.Functor.Both
|
||||
import Data.Functor.Identity
|
||||
import Data.Functor.Product as Product
|
||||
@ -180,10 +179,6 @@ instance Listable1 Identity where
|
||||
liftTiers tiers = liftCons1 tiers Identity
|
||||
|
||||
|
||||
instance Listable1 f => Listable1 (BindingF f) where
|
||||
liftTiers tiers = liftCons1 (liftTiers tiers) (Let mempty)
|
||||
|
||||
|
||||
instance Listable1 f => Listable2 (DiffF f) where
|
||||
liftTiers2 annTiers recurTiers
|
||||
= liftCons1 (liftTiers (liftTiers2 annTiers recurTiers)) Patch
|
||||
@ -196,7 +191,7 @@ instance (Listable1 f, Listable a, Listable b) => Listable (DiffF f a b) where
|
||||
tiers = tiers1
|
||||
|
||||
instance Listable1 f => Listable1 (Diff f) where
|
||||
liftTiers annTiers = go where go = liftCons1 (liftCons1 (liftTiers2 annTiers go) (Let mempty)) Diff
|
||||
liftTiers annTiers = go where go = liftCons1 (liftTiers2 annTiers go) Diff
|
||||
|
||||
instance (Listable1 f, Listable a) => Listable (Diff f a) where
|
||||
tiers = tiers1
|
||||
|
@ -62,7 +62,7 @@ diffFixtures =
|
||||
|
||||
patchOutput = "diff --git a/test/fixtures/ruby/method-declaration.A.rb b/test/fixtures/ruby/method-declaration.B.rb\nindex 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644\n--- a/test/fixtures/ruby/method-declaration.A.rb\n+++ b/test/fixtures/ruby/method-declaration.B.rb\n@@ -1,3 +1,4 @@\n-def foo\n+def bar(a)\n+ baz\n end\n\n"
|
||||
|
||||
jsonOutput = "{\"diff\":{\"merge\":{\"after\":{\"category\":\"Program\",\"sourceRange\":[0,21],\"sourceSpan\":{\"start\":[1,1],\"end\":[4,1]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Method\",\"identifier\":\"bar\",\"sourceRange\":[0,20],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,4]}},\"children\":[{\"patch\":{\"replace\":[{\"category\":\"Identifier\",\"children\":[],\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}},{\"category\":\"Identifier\",\"children\":[],\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}}]},\"vars\":[]},{\"patch\":{\"insert\":{\"category\":\"Params\",\"children\":[{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}},\"vars\":[]}],\"sourceRange\":[7,13],\"sourceSpan\":{\"start\":[1,8],\"end\":[2,3]}}},\"vars\":[]},{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}}},\"vars\":[]}],\"before\":{\"category\":\"Method\",\"identifier\":\"foo\",\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,4]}}},\"vars\":[]}],\"before\":{\"category\":\"Program\",\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}}},\"vars\":[]},\"oids\":[\"0000000000000000000000000000000000000000\",\"0000000000000000000000000000000000000000\"],\"paths\":[\"test/fixtures/ruby/method-declaration.A.rb\",\"test/fixtures/ruby/method-declaration.B.rb\"]}\n"
|
||||
jsonOutput = "{\"diff\":{\"merge\":{\"after\":{\"category\":\"Program\",\"sourceRange\":[0,21],\"sourceSpan\":{\"start\":[1,1],\"end\":[4,1]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Method\",\"identifier\":\"bar\",\"sourceRange\":[0,20],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,4]}},\"children\":[{\"patch\":{\"replace\":[{\"category\":\"Identifier\",\"children\":[],\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}},{\"category\":\"Identifier\",\"children\":[],\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}}]}},{\"patch\":{\"insert\":{\"category\":\"Params\",\"children\":[{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}}}],\"sourceRange\":[7,13],\"sourceSpan\":{\"start\":[1,8],\"end\":[2,3]}}}},{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}}}}],\"before\":{\"category\":\"Method\",\"identifier\":\"foo\",\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Program\",\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}}}},\"oids\":[\"0000000000000000000000000000000000000000\",\"0000000000000000000000000000000000000000\"],\"paths\":[\"test/fixtures/ruby/method-declaration.A.rb\",\"test/fixtures/ruby/method-declaration.B.rb\"]}\n"
|
||||
sExpressionOutput = "(Program\n (Method\n { (Identifier)\n ->(Identifier) }\n {+(Params\n {+(Identifier)+})+}\n {+(Identifier)+}))\n"
|
||||
tocOutput = "{\"changes\":{\"test/fixtures/ruby/method-declaration.A.rb -> test/fixtures/ruby/method-declaration.B.rb\":[{\"span\":{\"start\":[1,1],\"end\":[3,4]},\"category\":\"Method\",\"term\":\"bar\",\"changeType\":\"modified\"}]},\"errors\":{}}\n"
|
||||
|
||||
|
@ -2,7 +2,6 @@ module SemanticSpec where
|
||||
|
||||
import Data.Blob
|
||||
import Data.Functor (void)
|
||||
import Data.Functor.Binding
|
||||
import Data.Functor.Both as Both
|
||||
import Data.Functor.Sum
|
||||
import Diff
|
||||
@ -34,11 +33,11 @@ spec = parallel $ do
|
||||
describe "diffTermPair" $ do
|
||||
it "produces an Insert when the first blob is missing" $ do
|
||||
result <- runTask (diffTermPair (both (emptyBlob "/foo") (sourceBlob "/foo" Nothing "")) (runBothWith replacing) (pure (termIn () [])))
|
||||
result `shouldBe` Diff (Let mempty (Patch (Insert (In () (InR [])))))
|
||||
result `shouldBe` Diff (Patch (Insert (In () (InR []))))
|
||||
|
||||
it "produces a Delete when the second blob is missing" $ do
|
||||
result <- runTask (diffTermPair (both (sourceBlob "/foo" Nothing "") (emptyBlob "/foo")) (runBothWith replacing) (pure (termIn () [])))
|
||||
result `shouldBe` Diff (Let mempty (Patch (Delete (In () (InR [])))))
|
||||
result `shouldBe` Diff (Patch (Delete (In () (InR []))))
|
||||
|
||||
where
|
||||
methodsBlob = Blob "def foo\nend\n" "ff7bbbe9495f61d9e1e58c597502d152bab1761e" "methods.rb" (Just defaultPlainBlob) (Just Ruby)
|
||||
|
Loading…
Reference in New Issue
Block a user