Skip to content

Commit

Permalink
Merge pull request #17 from galtm/ensure-nonempty-path
Browse files Browse the repository at this point in the history
Use exactly-one to ensure nonempty context for accumulator function
  • Loading branch information
galtm committed Aug 13, 2023
2 parents 03e4a11 + 84f6cbe commit 40397c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/sample-acc/test/internal-elem-dedicated.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@
label="At end of subsection remark, 1 element name in stack"
test="$myv:tree/section/section/remark/accumulator-after('internal-elem')"
select="('section')"/>
<!--
Use of exactly-one() ensures that if $myv:tree yields an empty sequence
by mistake, you'll get an error instead of having the accumulator function
return empty for the wrong reason.
-->
<x:expect
label="At end of document, stack is empty"
test="$myv:tree/accumulator-after('internal-elem')"
test="exactly-one($myv:tree)/accumulator-after('internal-elem')"
select="()"/>

<!-- Variation: Boolean @test and no @select -->
<x:expect
label="At end of document, stack is empty"
test="empty($myv:tree/accumulator-after('internal-elem'))"/>
test="empty(exactly-one($myv:tree)/accumulator-after('internal-elem'))"/>
</x:scenario>

<!--
Expand Down
7 changes: 6 additions & 1 deletion src/test/acc-report-inclusion.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@
</x:variable>
<x:call function="true"/>
<x:like label="at:prior-value accumulator values for nodes other than document node"/>
<!--
Use of exactly-one() ensures that if $av:tree/self::document-node() yields an empty sequence
by mistake, you'll get an error instead of having the accumulator function
return empty for the wrong reason.
-->
<x:expect label="At start of document node, result is () because there is no prior value"
test="$av:tree/self::document-node()/accumulator-before('at:prior-value')"
test="exactly-one($av:tree/self::document-node())/accumulator-before('at:prior-value')"
select="()"/>
<x:expect label="At end of document node, prior indent level is 0"
test="$av:tree/self::document-node()/accumulator-after('at:prior-value')"
Expand Down

0 comments on commit 40397c5

Please sign in to comment.