mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
AStar with uniqueness inference
This commit is contained in:
parent
455ab1da16
commit
d34c96ec96
2 changed files with 25 additions and 5 deletions
|
@ -5,11 +5,11 @@ interface AStar
|
||||||
|
|
||||||
# a port of https://github.com/krisajenkins/elm-astar/blob/2.1.3/src/AStar/Generalised.elm
|
# a port of https://github.com/krisajenkins/elm-astar/blob/2.1.3/src/AStar/Generalised.elm
|
||||||
|
|
||||||
Model xyz :
|
Model position :
|
||||||
{ evaluated : Set xyz
|
{ evaluated : Set position
|
||||||
, openSet : Set xyz
|
, openSet : Set position
|
||||||
, costs : Map.Map xyz Float
|
, costs : Map.Map position Float
|
||||||
, cameFrom : Map.Map xyz xyz
|
, cameFrom : Map.Map position position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -222,6 +222,26 @@ mod test_uniqueness_load {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn load_astar() {
|
||||||
|
test_async(async {
|
||||||
|
let subs_by_module = MutMap::default();
|
||||||
|
let loaded_module = load_fixture("interface_with_deps", "AStar", subs_by_module).await;
|
||||||
|
|
||||||
|
expect_types(
|
||||||
|
loaded_module,
|
||||||
|
hashmap! {
|
||||||
|
"findPath" => "Attr * (Attr * { costFunction : (Attr Shared (Attr Shared position, Attr Shared position -> Attr Shared Float)), end : (Attr Shared position), moveFunction : (Attr Shared (Attr Shared position -> Attr * (Set (Attr Shared position)))), start : (Attr Shared position) } -> Attr * (Result (Attr * (List (Attr Shared position))) (Attr * [ KeyNotFound ]*)))",
|
||||||
|
"initialModel" => "Attr * (Attr Shared position -> Attr * (Model (Attr Shared position)))",
|
||||||
|
"reconstructPath" => "Attr Shared (Attr Shared (Map (Attr Shared position) (Attr Shared position)), Attr Shared position -> Attr * (List (Attr Shared position)))",
|
||||||
|
"updateCost" => "Attr * (Attr Shared position, Attr Shared position, Attr Shared (Model (Attr Shared position)) -> Attr Shared (Model (Attr Shared position)))",
|
||||||
|
"cheapestOpen" => "Attr * (Attr * (Attr Shared position -> Attr Shared Float), Attr * (Model (Attr Shared position)) -> Attr * (Result (Attr Shared position) (Attr * [ KeyNotFound ]*)))",
|
||||||
|
"astar" => "Attr Shared (Attr Shared (Attr Shared position, Attr Shared position -> Attr Shared Float), Attr Shared (Attr Shared position -> Attr * (Set (Attr Shared position))), Attr Shared position, Attr Shared (Model (Attr Shared position)) -> Attr * [ Err (Attr * [ KeyNotFound ]*), Ok (Attr * (List (Attr Shared position))) ]*)",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn load_and_typecheck_quicksort() {
|
fn load_and_typecheck_quicksort() {
|
||||||
test_async(async {
|
test_async(async {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue