mirror of
https://github.com/Smaug123/agda-utils
synced 2025-10-10 22:18:41 +00:00
Working prototype of unused-reference remover
This commit is contained in:
@@ -4,6 +4,8 @@ open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
|
||||
open AgdaUnusedOpens
|
||||
open AgdaUnusedOpens.Types
|
||||
open AgdaUnusedOpens.Internals
|
||||
|
||||
[<TestFixture>]
|
||||
module TestGraph =
|
||||
@@ -12,9 +14,9 @@ module TestGraph =
|
||||
let g =
|
||||
"Example.dot"
|
||||
|> Utils.getResource
|
||||
|> Graph.parse
|
||||
|> AdjacencyList.parse
|
||||
match g with
|
||||
| Success (Graph g) ->
|
||||
| Ok (AdjacencyList g) ->
|
||||
let m0 = Path.make ["Sequences"]
|
||||
let m1 = Path.make ["Setoids" ; "Setoids"]
|
||||
let m2 = Path.make ["LogicalFormulae"]
|
||||
@@ -44,3 +46,104 @@ module TestGraph =
|
||||
|> Set.ofList
|
||||
actual |> shouldEqual expected
|
||||
| x -> failwithf "oh no: %O" x
|
||||
|
||||
[<Test>]
|
||||
let ``Convert to a graph`` () =
|
||||
let g = "Example.dot" |> Utils.getResource |> AdjacencyList.parse
|
||||
let g = match g with | Error _ -> failwith "oh no" | Ok g -> g
|
||||
let i = Graph.toGraph g
|
||||
let m0 = Path.make ["Sequences"]
|
||||
let m1 = Path.make ["Setoids" ; "Setoids"]
|
||||
let m2 = Path.make ["LogicalFormulae"]
|
||||
let m3 = Path.make ["Agda" ; "Primitive"]
|
||||
let m4 = Path.make ["Functions"]
|
||||
let m5 = Path.make ["Sets" ; "EquivalenceRelations"]
|
||||
let m6 = Path.make ["Numbers" ; "Naturals" ; "Definition"]
|
||||
|
||||
let primitive =
|
||||
{
|
||||
Node = m3
|
||||
Unblocks = Set.empty
|
||||
}
|
||||
let logical =
|
||||
{
|
||||
Node = m2
|
||||
Unblocks = Set.singleton primitive
|
||||
}
|
||||
let functions =
|
||||
{
|
||||
Node = m4
|
||||
Unblocks =
|
||||
[
|
||||
logical
|
||||
primitive
|
||||
]
|
||||
|> Set.ofList
|
||||
}
|
||||
let numbers =
|
||||
{
|
||||
Node = m6
|
||||
Unblocks = Set.singleton logical
|
||||
}
|
||||
let equivRel =
|
||||
{
|
||||
Node = m5
|
||||
Unblocks =
|
||||
[
|
||||
functions
|
||||
primitive
|
||||
logical
|
||||
]
|
||||
|> Set.ofList
|
||||
}
|
||||
let setoids =
|
||||
{
|
||||
Node = m1
|
||||
Unblocks =
|
||||
[
|
||||
equivRel
|
||||
logical
|
||||
functions
|
||||
primitive
|
||||
]
|
||||
|> Set.ofList
|
||||
}
|
||||
let sequences =
|
||||
{
|
||||
Node = m0
|
||||
Unblocks =
|
||||
[
|
||||
numbers
|
||||
setoids
|
||||
logical
|
||||
]
|
||||
|> Set.ofList
|
||||
}
|
||||
|
||||
i
|
||||
|> shouldEqual sequences
|
||||
|
||||
[<Test>]
|
||||
let ``Cata traversal order`` () =
|
||||
let g = "Example.dot" |> Utils.getResource |> AdjacencyList.parse
|
||||
let g = match g with | Error _ -> failwith "oh no" | Ok g -> g
|
||||
let i = Graph.toGraph g
|
||||
|
||||
let nodes = ResizeArray<Path> ()
|
||||
|
||||
i
|
||||
|> Graph.cata (fun p _ -> nodes.Add p)
|
||||
|
||||
nodes
|
||||
|> Seq.toList
|
||||
|> List.map Path.toString
|
||||
|> shouldEqual
|
||||
[
|
||||
"Agda.Primitive"
|
||||
"LogicalFormulae"
|
||||
"Numbers.Naturals.Definition"
|
||||
"Functions"
|
||||
"Sets.EquivalenceRelations"
|
||||
"Setoids.Setoids"
|
||||
"Sequences"
|
||||
]
|
||||
|
Reference in New Issue
Block a user