1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Fix up tests for Name wrapper

This commit is contained in:
Timothy Clem 2018-04-04 08:59:13 -07:00
parent 7df5567a92
commit 4b9caec4c5
30 changed files with 285 additions and 312 deletions

View File

@ -47,6 +47,7 @@ import qualified Data.Syntax as Syntax
import qualified Data.Syntax.Comment as Comment
import qualified Data.Syntax.Declaration as Declaration
import qualified Data.Syntax.Statement as Statement
import qualified Data.Abstract.FreeVariables as FV
import Data.Term
import Data.Text as T (Text, pack)
import qualified Data.Text.Encoding as T
@ -256,6 +257,9 @@ type ListableSyntax = Union
, []
]
instance Listable FV.Name where
tiers = cons1 FV.name
instance Listable1 Gram where
liftTiers tiers = liftCons2 (liftTiers (liftTiers tiers)) (liftTiers (liftTiers tiers)) Gram

View File

@ -166,14 +166,14 @@ programWithChange :: Term' -> Diff'
programWithChange body = merge (programInfo, programInfo) (inj [ function' ])
where
function' = merge (Just (FunctionDeclaration "foo" mempty Nothing) :. emptyInfo, Just (FunctionDeclaration "foo" mempty Nothing) :. emptyInfo) (inj (Declaration.Function [] name' [] (merge (Nothing :. emptyInfo, Nothing :. emptyInfo) (inj [ inserting body ]))))
name' = let info = Nothing :. emptyInfo in merge (info, info) (inj (Syntax.Identifier "foo"))
name' = let info = Nothing :. emptyInfo in merge (info, info) (inj (Syntax.Identifier (name "foo")))
-- Return a diff where term is inserted in the program, below a function found on both sides of the diff.
programWithChangeOutsideFunction :: Term' -> Diff'
programWithChangeOutsideFunction term = merge (programInfo, programInfo) (inj [ function', term' ])
where
function' = merge (Just (FunctionDeclaration "foo" mempty Nothing) :. emptyInfo, Just (FunctionDeclaration "foo" mempty Nothing) :. emptyInfo) (inj (Declaration.Function [] name' [] (merge (Nothing :. emptyInfo, Nothing :. emptyInfo) (inj []))))
name' = let info = Nothing :. emptyInfo in merge (info, info) (inj (Syntax.Identifier "foo"))
name' = let info = Nothing :. emptyInfo in merge (info, info) (inj (Syntax.Identifier (name "foo")))
term' = inserting term
programWithInsert :: Text -> Term' -> Diff'
@ -191,7 +191,7 @@ programOf diff = merge (programInfo, programInfo) (inj [ diff ])
functionOf :: Text -> Term' -> Term'
functionOf n body = termIn (Just (FunctionDeclaration n mempty Nothing) :. emptyInfo) (inj (Declaration.Function [] name' [] (termIn (Nothing :. emptyInfo) (inj [body]))))
where
name' = termIn (Nothing :. emptyInfo) (inj (Syntax.Identifier (encodeUtf8 n)))
name' = termIn (Nothing :. emptyInfo) (inj (Syntax.Identifier (name (encodeUtf8 n))))
programInfo :: Record '[Maybe Declaration, Range, Span]
programInfo = Nothing :. emptyInfo
@ -218,7 +218,7 @@ blobsForPaths :: Both FilePath -> IO BlobPair
blobsForPaths = readFilePair . fmap ("test/fixtures/toc/" <>)
blankDiff :: Diff'
blankDiff = merge (arrayInfo, arrayInfo) (inj [ inserting (termIn literalInfo (inj (Syntax.Identifier "\"a\""))) ])
blankDiff = merge (arrayInfo, arrayInfo) (inj [ inserting (termIn literalInfo (inj (Syntax.Identifier (name "\"a\"")))) ])
where
arrayInfo = Nothing :. Range 0 3 :. Span (Pos 1 1) (Pos 1 5) :. Nil
literalInfo = Nothing :. Range 1 2 :. Span (Pos 1 2) (Pos 1 4) :. Nil

View File

@ -27,19 +27,26 @@
->(Identifier) }
{ (Identifier)
->(Identifier) })
{+(Not
{+(Equal
{+(Identifier)+}
{+(Identifier)+})+})+}
{+(LessThan
{+(Identifier)+}
{+(Identifier)+})+}
(Not
(Equal
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }))
(LessThan
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) })
{+(LessThanEqual
{+(Identifier)+}
{+(Identifier)+})+}
{+(GreaterThan
{ (LessThanEqual
{-(Identifier)-}
{-(Identifier)-})
->(GreaterThan
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+}) }
{+(GreaterThanEqual
{+(Identifier)+}
{+(Identifier)+})+}
@ -76,16 +83,6 @@
{+(BAnd
{+(Identifier)+}
{+(Identifier)+})+}
{-(Not
{-(Equal
{-(Identifier)-}
{-(Identifier)-})-})-}
{-(LessThan
{-(Identifier)-}
{-(Identifier)-})-}
{-(LessThanEqual
{-(Identifier)-}
{-(Identifier)-})-}
{-(GreaterThan
{-(Identifier)-}
{-(Identifier)-})-}

View File

@ -27,13 +27,17 @@
->(Identifier) }
{ (Identifier)
->(Identifier) })
{+(Not
{+(Equal
{+(Identifier)+}
{+(Identifier)+})+})+}
{+(LessThan
{+(Identifier)+}
{+(Identifier)+})+}
(Not
(Equal
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }))
(LessThan
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) })
{+(LessThanEqual
{+(Identifier)+}
{+(Identifier)+})+}
@ -76,13 +80,6 @@
{+(BAnd
{+(Identifier)+}
{+(Identifier)+})+}
{-(Not
{-(Equal
{-(Identifier)-}
{-(Identifier)-})-})-}
{-(LessThan
{-(Identifier)-}
{-(Identifier)-})-}
{-(LessThanEqual
{-(Identifier)-}
{-(Identifier)-})-}

View File

@ -6,15 +6,18 @@
(Identifier)
([])
(
{+(Assignment
{+(Identifier)+}
{+(Identifier)+})+}
(Assignment
{ (Identifier)
->(Identifier) }
(Identifier))
{ (Identifier)
->([]) })
(Assignment
{ (Identifier)
->(Identifier) }
([]))
(Assignment
{ (Identifier)
->(Identifier) }
([])))))
{-(Assignment
{-(Identifier)-}
{-([])-})-})))

View File

@ -6,15 +6,20 @@
(Identifier)
([])
(
{+(Assignment
{+(Identifier)+}
{+(Identifier)+})+}
(Assignment
{ (Identifier)
->(Identifier) }
(Identifier))
(Assignment
{ (Identifier)
->(Identifier) }
([]))
(Assignment
{ (Identifier)
->(Identifier) }
([])))))
->([]) })
{+(Assignment
{+(Identifier)+}
{+([])+})+}
{-(Assignment
{-(Identifier)-}
{-([])-})-}
{-(Assignment
{-(Identifier)-}
{-([])-})-})))

View File

@ -2,18 +2,18 @@
(Package
(Identifier))
(
{+(QualifiedImport
{+(Identifier)+})+}
{+(Import
{+(TextElement)+})+}
{ (QualifiedImport
{-(Identifier)-})
->(QualifiedImport
{+(Identifier)+}) }
{ (Import
{-(TextElement)-})
->(Import
{+(TextElement)+}) }
{ (QualifiedImport
{-(Identifier)-})
->(QualifiedImport
{+(Identifier)+}) })
{-(Import
{-(TextElement)-})-}
{-(QualifiedImport
{-(Identifier)-})-})
(Function
(Empty)
(Identifier)

View File

@ -2,18 +2,18 @@
(Package
(Identifier))
(
{+(QualifiedImport
{+(Identifier)+})+}
{+(Import
{+(TextElement)+})+}
{ (QualifiedImport
{-(Identifier)-})
->(QualifiedImport
{+(Identifier)+}) }
{ (Import
{-(TextElement)-})
->(Import
{+(TextElement)+}) }
{ (QualifiedImport
{-(Identifier)-})
->(QualifiedImport
{+(Identifier)+}) })
{-(Import
{-(TextElement)-})-}
{-(QualifiedImport
{-(Identifier)-})-})
(Function
(Empty)
(Identifier)

View File

@ -1,18 +1,18 @@
(Program
(Package
(Identifier))
{ (QualifiedImport
{-(Identifier)-})
->(QualifiedImport
{+(Identifier)+}) }
{ (Import
{-(TextElement)-})
->(Import
{+(TextElement)+}) }
{ (QualifiedImport
{-(Identifier)-})
->(QualifiedImport
{+(Identifier)+}) }
{+(QualifiedImport
{+(Identifier)+})+}
{+(Import
{+(TextElement)+})+}
{+(QualifiedImport
{+(Identifier)+})+}
{-(QualifiedImport
{-(Identifier)-})-}
{-(Import
{-(TextElement)-})-}
{-(QualifiedImport
{-(Identifier)-})-}
(Function
(Empty)
(Identifier)

View File

@ -1,18 +1,18 @@
(Program
(Package
(Identifier))
{+(QualifiedImport
{+(Identifier)+})+}
{+(Import
{+(TextElement)+})+}
{ (QualifiedImport
{-(Identifier)-})
->(QualifiedImport
{+(Identifier)+}) }
{ (Import
{-(TextElement)-})
->(Import
{+(TextElement)+}) }
{ (QualifiedImport
{-(Identifier)-})
->(QualifiedImport
{+(Identifier)+}) }
{-(Import
{-(TextElement)-})-}
{-(QualifiedImport
{-(Identifier)-})-}
(Function
(Empty)
(Identifier)

View File

@ -11,11 +11,14 @@
{+(Integer)+}
{+(Empty)+}
{+(Empty)+})+}
{+(Slice
{+(Identifier)+}
{+(Empty)+}
{+(Integer)+}
{+(Empty)+})+}
(Slice
{ (Identifier)
->(Identifier) }
{ (Integer)
->(Empty) }
{ (Empty)
->(Integer) }
(Empty))
{+(Slice
{+(Identifier)+}
{+(Integer)+}
@ -24,9 +27,10 @@
(Slice
{ (Identifier)
->(Identifier) }
(Integer)
{ (Empty)
->(Integer) }
{ (Integer)
->(Integer) }
{ (Empty)
->(Integer) })
{+(Slice
@ -34,11 +38,6 @@
{+(Integer)+}
{+(Integer)+}
{+(Empty)+})+}
{-(Slice
{-(Identifier)-}
{-(Empty)-}
{-(Integer)-}
{-(Empty)-})-}
{-(Slice
{-(Identifier)-}
{-(Empty)-}

View File

@ -8,35 +8,25 @@
(
{ (Identifier)
->(Identifier) }
{+(Negate
{+(Identifier)+})+}
{+(Not
{+(ReceiveOperator
{+(Identifier)+})+})+}
{+(Pointer
{+(Call
{+(Identifier)+}
{+([])+}
{+(Empty)+})+})+}
{+(Complement
{+(Identifier)+})+}
{+(Reference
{+(Identifier)+})+}
{+(ReceiveOperator
{+(Identifier)+})+}
{-(Negate
{-(Identifier)-})-}
{-(Not
{-(ReceiveOperator
{-(Identifier)-})-})-}
{-(Pointer
{-(Call
{-(Identifier)-}
{-([])-}
{-(Empty)-})-})-}
{-(Complement
{-(Identifier)-})-}
{-(Reference
{-(Identifier)-})-}
{-(ReceiveOperator
{-(Identifier)-})-})))
(Negate
{ (Identifier)
->(Identifier) })
(Not
(ReceiveOperator
{ (Identifier)
->(Identifier) }))
(Pointer
(Call
{ (Identifier)
->(Identifier) }
([])
(Empty)))
(Complement
{ (Identifier)
->(Identifier) })
(Reference
{ (Identifier)
->(Identifier) })
(ReceiveOperator
{ (Identifier)
->(Identifier) }))))

View File

@ -8,35 +8,25 @@
(
{ (Identifier)
->(Identifier) }
{+(Negate
{+(Identifier)+})+}
{+(Not
{+(ReceiveOperator
{+(Identifier)+})+})+}
{+(Pointer
{+(Call
{+(Identifier)+}
{+([])+}
{+(Empty)+})+})+}
{+(Complement
{+(Identifier)+})+}
{+(Reference
{+(Identifier)+})+}
{+(ReceiveOperator
{+(Identifier)+})+}
{-(Negate
{-(Identifier)-})-}
{-(Not
{-(ReceiveOperator
{-(Identifier)-})-})-}
{-(Pointer
{-(Call
{-(Identifier)-}
{-([])-}
{-(Empty)-})-})-}
{-(Complement
{-(Identifier)-})-}
{-(Reference
{-(Identifier)-})-}
{-(ReceiveOperator
{-(Identifier)-})-})))
(Negate
{ (Identifier)
->(Identifier) })
(Not
(ReceiveOperator
{ (Identifier)
->(Identifier) }))
(Pointer
(Call
{ (Identifier)
->(Identifier) }
([])
(Empty)))
(Complement
{ (Identifier)
->(Identifier) })
(Reference
{ (Identifier)
->(Identifier) })
(ReceiveOperator
{ (Identifier)
->(Identifier) }))))

View File

@ -35,15 +35,15 @@
(Identifier)
{ (Empty)
->(Identifier) })
{+(Assignment
{+(Empty)+}
{+(Identifier)+}
{+(Empty)+})+}
(Assignment
(Empty)
{ (Identifier)
->(Identifier) }
(Empty))))
(Empty))
{+(Assignment
{+(Empty)+}
{+(Identifier)+}
{+(Empty)+})+}))
(DefaultExport
{ (Identifier)
->(Identifier) })

View File

@ -35,14 +35,11 @@
(Identifier)
{ (Identifier)
->(Empty) })
{+(Assignment
{+(Empty)+}
{+(Identifier)+}
{+(Empty)+})+}
{-(Assignment
{-(Empty)-}
{-(Identifier)-}
{-(Empty)-})-}
(Assignment
(Empty)
{ (Identifier)
->(Identifier) }
(Empty))
{-(Assignment
{-(Empty)-}
{-(Identifier)-}

View File

@ -1,14 +1,11 @@
(Program
{ (Import)
->(Import) }
{ (QualifiedAliasedImport
{-(Identifier)-})
->(QualifiedAliasedImport
{+(Identifier)+}) }
{+(Import)+}
{+(QualifiedAliasedImport
{+(Identifier)+})+}
{+(Import)+}
{+(Import)+}
{ (Import)
->(Import) }
{+(Import)+}
{+(
{+(Import)+}
{+(Import)+})+}
@ -17,6 +14,9 @@
{+(QualifiedAliasedImport
{+(Identifier)+})+})+}
{+(SideEffectImport)+}
{-(QualifiedAliasedImport
{-(Identifier)-})-}
{-(Import)-}
{-(Import)-}
{-(Import)-}
{-(

View File

@ -1,10 +1,7 @@
(Program
{ (Import)
->(Import) }
{ (QualifiedAliasedImport
{-(Identifier)-})
->(QualifiedAliasedImport
{+(Identifier)+}) }
{+(Import)+}
{+(QualifiedAliasedImport
{+(Identifier)+})+}
{+(Import)+}
{+(Import)+}
{ (Import)
@ -17,6 +14,9 @@
{+(QualifiedAliasedImport
{+(Identifier)+})+})+}
{+(SideEffectImport)+}
{-(QualifiedAliasedImport
{-(Identifier)-})-}
{-(Import)-}
{-(Import)-}
{-(Import)-}
{-(

View File

@ -10,18 +10,14 @@
{ (Identifier)
->(Identifier) }
(Integer))
{+(Assignment
{+(Identifier)+}
{+(
{+(Integer)+}
{+(Integer)+})+})+}
{-(Assignment
{-(
(Assignment
{ (
{-(Identifier)-}
{-(Identifier)-})-}
{-(
{-(Integer)-}
{-(Integer)-})-})-}
{-(Identifier)-})
->(Identifier) }
(
(Integer)
(Integer)))
{-(Assignment
{-(Identifier)-}
{-(

View File

@ -7,21 +7,21 @@
->(RShift
{+(Identifier)+}
{+(Integer)+}) })
{+(Assignment
{+(Identifier)+}
{+(DividedBy
{+(Identifier)+}
{+(Integer)+})+})+}
(Assignment
(Identifier)
{ (Identifier)
->(Identifier) }
{ (RShift
{-(Identifier)-}
{-(Integer)-})
->(DividedBy
{+(Identifier)+}
{+(Integer)+}) })
(Assignment
{ (Identifier)
->(Identifier) }
{ (DividedBy
{-(Identifier)-}
{-(Integer)-})
->(Plus
{+(Identifier)+}
{+(Integer)+}) })
{-(Assignment
{-(Identifier)-}
{-(DividedBy
{-(Identifier)-}
{-(Integer)-})-})-})
{+(Integer)+}) }))

View File

@ -7,23 +7,21 @@
->(Plus
{+(Identifier)+}
{+(Integer)+}) })
{+(Assignment
{+(Identifier)+}
{+(RShift
{+(Identifier)+}
{+(Integer)+})+})+}
{+(Assignment
{+(Identifier)+}
{+(DividedBy
{+(Identifier)+}
{+(Integer)+})+})+}
{-(Assignment
{-(Identifier)-}
{-(DividedBy
(Assignment
{ (Identifier)
->(Identifier) }
{ (DividedBy
{-(Identifier)-}
{-(Integer)-})-})-}
{-(Assignment
{-(Identifier)-}
{-(Plus
{-(Integer)-})
->(RShift
{+(Identifier)+}
{+(Integer)+}) })
(Assignment
{ (Identifier)
->(Identifier) }
{ (Plus
{-(Identifier)-}
{-(Integer)-})-})-})
{-(Integer)-})
->(DividedBy
{+(Identifier)+}
{+(Integer)+}) }))

View File

@ -5,22 +5,22 @@
{+(LessThanEqual
{+(Identifier)+}
{+(Identifier)+})+}
{+(Not
{+(Equal
{+(Identifier)+}
{+(Identifier)+})+})+}
{+(GreaterThanEqual
{+(Identifier)+}
{+(Identifier)+})+}
{+(GreaterThan
{+(Identifier)+}
{+(Identifier)+})+}
(Not
(Equal
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }))
{+(GreaterThanEqual
{+(Identifier)+}
{+(Identifier)+})+}
{+(GreaterThan
{+(Identifier)+}
{+(Identifier)+})+}
{+(Not
{+(Equal
{+(Identifier)+}
{+(Identifier)+})+})+}
{+(Member
{+(Identifier)+}
{+(Identifier)+})+}

View File

@ -3,10 +3,10 @@
{+(Import)+}
{ (Import)
->(Import) }
{ (Import)
->(Import) }
{+(Import)+}
{+(Import)+}
{-(Import)-}
{-(Import)-}
{-(Import)-}
{-(Import)-}
{-(Import)-})

View File

@ -1,11 +1,14 @@
(Program
(Tuple
{-(Identifier)-}
(Identifier)
{+(Tuple
{+(Identifier)+}
{+(Identifier)+})
{+(Identifier)+}
{+(Identifier)+})+}
(Tuple
{-(Identifier)-}
(Identifier)
(Identifier))
{+(Identifier)+})
{+(Identifier)+})
{+(Identifier)+}
{-(Tuple
{-(Identifier)-}
{-(Identifier)-}
{-(Identifier)-})-})

View File

@ -1,11 +1,13 @@
(Program
(Tuple
{-(Identifier)-}
{-(Identifier)-}
(Identifier)
{+(Identifier)+})
{+(Tuple
{+(Identifier)+}
{+(Identifier)+})+}
(Tuple
{+(Identifier)+}
(Identifier)
(Identifier))
(Identifier)
{-(Identifier)-})
{-(Tuple
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-})

View File

@ -1,23 +1,20 @@
(Program
(Hash
{+(KeyValue
{+(Identifier)+}
{+(TextElement)+})+}
{+(KeyValue
{+(Identifier)+}
{+(Integer)+})+}
{+(KeyValue
{+(Identifier)+}
{+(Boolean)+})+}
{-(KeyValue
{-(Symbol)-}
{-(TextElement)-})-}
{-(KeyValue
{-(Symbol)-}
{-(Integer)-})-}
{-(KeyValue
{-(TextElement)-}
{-(Boolean)-})-}
(KeyValue
{ (Symbol)
->(Identifier) }
{ (TextElement)
->(TextElement) })
(KeyValue
{ (Symbol)
->(Identifier) }
{ (Integer)
->(Integer) })
(KeyValue
{ (TextElement)
->(Identifier) }
{ (Boolean)
->(Boolean) })
{-(KeyValue
{-(Symbol)-}
{-(Integer)-})-})

View File

@ -1,25 +1,23 @@
(Program
(Hash
{+(KeyValue
{+(Symbol)+}
{+(TextElement)+})+}
{+(KeyValue
{+(Symbol)+}
{+(Integer)+})+}
(KeyValue
{ (Identifier)
->(Symbol) }
{ (TextElement)
->(TextElement) })
(KeyValue
{ (Identifier)
->(Symbol) }
{ (Integer)
->(Integer) })
(KeyValue
{ (Identifier)
->(TextElement) }
{ (TextElement)
{ (Boolean)
->(Boolean) })
{+(KeyValue
{+(Symbol)+}
{+(Integer)+})+}
{-(KeyValue
{-(Identifier)-}
{-(Integer)-})-}
{-(KeyValue
{-(Identifier)-}
{-(Boolean)-})-})
{+(Integer)+})+})
{+(Hash)+}
{+(Hash
{+(Context

View File

@ -35,15 +35,15 @@
(Identifier)
{ (Empty)
->(Identifier) })
{+(Assignment
{+(Empty)+}
{+(Identifier)+}
{+(Empty)+})+}
(Assignment
(Empty)
{ (Identifier)
->(Identifier) }
(Empty))))
(Empty))
{+(Assignment
{+(Empty)+}
{+(Identifier)+}
{+(Empty)+})+}))
(DefaultExport
{ (Identifier)
->(Identifier) })

View File

@ -35,14 +35,11 @@
(Identifier)
{ (Identifier)
->(Empty) })
{+(Assignment
{+(Empty)+}
{+(Identifier)+}
{+(Empty)+})+}
{-(Assignment
{-(Empty)-}
{-(Identifier)-}
{-(Empty)-})-}
(Assignment
(Empty)
{ (Identifier)
->(Identifier) }
(Empty))
{-(Assignment
{-(Empty)-}
{-(Identifier)-}

View File

@ -1,14 +1,11 @@
(Program
{ (Import)
->(Import) }
{ (QualifiedAliasedImport
{-(Identifier)-})
->(QualifiedAliasedImport
{+(Identifier)+}) }
{+(Import)+}
{+(QualifiedAliasedImport
{+(Identifier)+})+}
{+(Import)+}
{+(Import)+}
{ (Import)
->(Import) }
{+(Import)+}
{+(
{+(Import)+}
{+(Import)+})+}
@ -17,6 +14,9 @@
{+(QualifiedAliasedImport
{+(Identifier)+})+})+}
{+(SideEffectImport)+}
{-(QualifiedAliasedImport
{-(Identifier)-})-}
{-(Import)-}
{-(Import)-}
{-(Import)-}
{-(

View File

@ -1,10 +1,7 @@
(Program
{ (Import)
->(Import) }
{ (QualifiedAliasedImport
{-(Identifier)-})
->(QualifiedAliasedImport
{+(Identifier)+}) }
{+(Import)+}
{+(QualifiedAliasedImport
{+(Identifier)+})+}
{+(Import)+}
{+(Import)+}
{ (Import)
@ -17,8 +14,11 @@
{+(QualifiedAliasedImport
{+(Identifier)+})+})+}
{+(SideEffectImport)+}
{+(QualifiedAliasedImport
{+(Identifier)+})+}
{ (QualifiedAliasedImport
{-(Identifier)-})
->(QualifiedAliasedImport
{+(Identifier)+}) }
{-(Import)-}
{-(Import)-}
{-(Import)-}
{-(