Add tests for explicit context setting that check failure conditions and implement a helper function to generate a new breadcrumb stack.
This commit is contained in:
@@ -37,4 +37,24 @@ Explicitly setting a context does not work on a reference, but it has revealed t
|
||||
Paths
|
||||
-----
|
||||
|
||||
Explicit contexts do support deep paths
|
||||
Explicit contexts do support deep paths.
|
||||
|
||||
Else Blocks
|
||||
-----------
|
||||
|
||||
Else blocks also use an explicit context.
|
||||
|
||||
Complete Failure
|
||||
----------------
|
||||
|
||||
If the walk destination does not exist, and the explicit context does not exist, then you end up with absolutely no context.
|
||||
|
||||
Regular Path Failure
|
||||
--------------------
|
||||
|
||||
If the regular path fails but the explicit path succeeds then the context is set to the explicit path.
|
||||
|
||||
Falsey Explicit Path
|
||||
--------------------
|
||||
|
||||
Since dust would not walk to a falsey path, theres no difference between a falsey path and a non-existent path.
|
||||
|
||||
@@ -24,5 +24,6 @@
|
||||
"explicit": {
|
||||
"pet": "cat"
|
||||
}
|
||||
}
|
||||
},
|
||||
"empty_array": []
|
||||
}
|
||||
|
||||
@@ -157,3 +157,101 @@ Variable Explicit{~n}
|
||||
{/person}
|
||||
{/loop}
|
||||
|
||||
{! What context is set on else blocks? !}
|
||||
Else Block Regular{~n}
|
||||
=================={~n}
|
||||
{#loop}
|
||||
{#empty_array}
|
||||
MAIN {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{:else}
|
||||
ELSE {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{/empty_array}
|
||||
{/loop}
|
||||
|
||||
Else Block Explicit{~n}
|
||||
==================={~n}
|
||||
{#loop}
|
||||
{#empty_array:explicit}
|
||||
MAIN {$idx}: {person.name} has a pet {pet} but not a {some_global}{~n}
|
||||
{:else}
|
||||
ELSE {$idx}: {person.name} has a pet {pet} but not a {some_global}{~n}
|
||||
{/empty_array}
|
||||
{/loop}
|
||||
|
||||
{! What context is set when the explicit context path does not exist? !}
|
||||
Failed Explicit Regular{~n}
|
||||
======================={~n}
|
||||
{#loop}
|
||||
{#person}
|
||||
{$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{/person}
|
||||
{/loop}
|
||||
|
||||
Failed Explicit Explicit{~n}
|
||||
========================{~n}
|
||||
{#loop}
|
||||
{#person:foobar}
|
||||
{$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{/person}
|
||||
{/loop}
|
||||
|
||||
{! What context is set when the regular path and explicit context path does not exist? !}
|
||||
Failed Everything Regular{~n}
|
||||
========================={~n}
|
||||
BEFORE {.|js}{~n}
|
||||
{#foo}
|
||||
MAIN {.|js}{~n}
|
||||
{:else}
|
||||
ELSE {.|js}{~n}
|
||||
{/foo}
|
||||
|
||||
Failed Everything Explicit{~n}
|
||||
=========================={~n}
|
||||
{#foo:bar}
|
||||
MAIN {.|js}{~n}
|
||||
{:else}
|
||||
ELSE {.|js}{~n}
|
||||
{/foo}
|
||||
|
||||
{! What context is set when the regular context path does not exist? !}
|
||||
Failed Regular Path Regular{~n}
|
||||
==========================={~n}
|
||||
{#loop}
|
||||
{#foo}
|
||||
MAIN {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{:else}
|
||||
ELSE {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{/foo}
|
||||
{/loop}
|
||||
|
||||
Failed Regular Path Explicit{~n}
|
||||
============================{~n}
|
||||
{#loop}
|
||||
{#foo:explicit}
|
||||
MAIN {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{:else}
|
||||
ELSE {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{/foo}
|
||||
{/loop}
|
||||
|
||||
{! What context is set when the explicit path is falsey? !}
|
||||
Falsey Explicit Path Regular{~n}
|
||||
============================{~n}
|
||||
{#loop}
|
||||
{#foo}
|
||||
MAIN {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{:else}
|
||||
ELSE {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{/foo}
|
||||
{/loop}
|
||||
|
||||
Falsey Explicit Path Explicit{~n}
|
||||
============================={~n}
|
||||
{#loop}
|
||||
{#foo:empty_array}
|
||||
MAIN {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{:else}
|
||||
ELSE {$idx}: {name} has a pet {pet} but not a {some_global}{~n}
|
||||
{.|js}{~n}
|
||||
{/foo}
|
||||
{/loop}
|
||||
|
||||
Reference in New Issue
Block a user