Apply test case ensures arguments are passed by reference
Confidence in its application is also increased through a unique node.master
parent
0dc019c9ed
commit
465ef7e8a5
|
@ -30,14 +30,15 @@
|
||||||
|
|
||||||
<template mode="f:apply" match="f:ref[ foo:fn0 ]">
|
<template mode="f:apply" match="f:ref[ foo:fn0 ]">
|
||||||
<!-- return something to show that we were called properly -->
|
<!-- return something to show that we were called properly -->
|
||||||
<sequence select="0" />
|
<foo:applied n="0" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<template mode="f:apply" match="f:ref[ foo:fn1 ]">
|
<template mode="f:apply" match="f:ref[ foo:fn1 ]">
|
||||||
<param name="arg1" />
|
<param name="arg1" />
|
||||||
|
|
||||||
<sequence select="string($arg1)" />
|
<foo:applied n="1" />
|
||||||
|
<sequence select="$arg1" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +46,8 @@
|
||||||
<param name="arg1" />
|
<param name="arg1" />
|
||||||
<param name="arg2" />
|
<param name="arg2" />
|
||||||
|
|
||||||
<sequence select="concat($arg1, $arg2)" />
|
<foo:applied n="2" />
|
||||||
|
<sequence select="$arg1, $arg2" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +56,8 @@
|
||||||
<param name="arg2" />
|
<param name="arg2" />
|
||||||
<param name="arg3" />
|
<param name="arg3" />
|
||||||
|
|
||||||
<sequence select="concat($arg1, $arg2, $arg3)" />
|
<foo:applied n="3" />
|
||||||
|
<sequence select="$arg1, $arg2, $arg3" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +67,8 @@
|
||||||
<param name="arg3" />
|
<param name="arg3" />
|
||||||
<param name="arg4" />
|
<param name="arg4" />
|
||||||
|
|
||||||
<sequence select="concat($arg1, $arg2, $arg3, $arg4)" />
|
<foo:applied n="4" />
|
||||||
|
<sequence select="$arg1, $arg2, $arg3, $arg4" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,8 +79,9 @@
|
||||||
<param name="arg4" />
|
<param name="arg4" />
|
||||||
<param name="arg5" />
|
<param name="arg5" />
|
||||||
|
|
||||||
<sequence select="concat($arg1, $arg2, $arg3, $arg4,
|
<foo:applied n="5" />
|
||||||
$arg5)" />
|
<sequence select="$arg1, $arg2, $arg3, $arg4,
|
||||||
|
$arg5" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,8 +93,9 @@
|
||||||
<param name="arg5" />
|
<param name="arg5" />
|
||||||
<param name="arg6" />
|
<param name="arg6" />
|
||||||
|
|
||||||
<sequence select="concat($arg1, $arg2, $arg3, $arg4,
|
<foo:applied n="6" />
|
||||||
$arg5, $arg6)" />
|
<sequence select="$arg1, $arg2, $arg3, $arg4,
|
||||||
|
$arg5, $arg6" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,8 +108,9 @@
|
||||||
<param name="arg6" />
|
<param name="arg6" />
|
||||||
<param name="arg7" />
|
<param name="arg7" />
|
||||||
|
|
||||||
<sequence select="concat($arg1, $arg2, $arg3, $arg4,
|
<foo:applied n="7" />
|
||||||
$arg5, $arg6, $arg7)" />
|
<sequence select="$arg1, $arg2, $arg3, $arg4,
|
||||||
|
$arg5, $arg6, $arg7" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +124,8 @@
|
||||||
<param name="arg7" />
|
<param name="arg7" />
|
||||||
<param name="arg8" />
|
<param name="arg8" />
|
||||||
|
|
||||||
<sequence select="concat($arg1, $arg2, $arg3, $arg4,
|
<foo:applied n="8" />
|
||||||
$arg5, $arg6, $arg7, $arg8)" />
|
<sequence select="$arg1, $arg2, $arg3, $arg4,
|
||||||
|
$arg5, $arg6, $arg7, $arg8" />
|
||||||
</template>
|
</template>
|
||||||
</stylesheet>
|
</stylesheet>
|
||||||
|
|
164
test/apply.xspec
164
test/apply.xspec
|
@ -26,28 +26,21 @@
|
||||||
xmlns:foo="http://www.lovullo.com/_junk"
|
xmlns:foo="http://www.lovullo.com/_junk"
|
||||||
stylesheet="apply-test.xsl">
|
stylesheet="apply-test.xsl">
|
||||||
|
|
||||||
|
<variable name="args">
|
||||||
|
<foo:args>
|
||||||
|
<foo:arg1 />
|
||||||
|
<foo:arg2 />
|
||||||
|
<foo:arg3 />
|
||||||
|
<foo:arg4 />
|
||||||
|
<foo:arg5 />
|
||||||
|
<foo:arg6 />
|
||||||
|
<foo:arg7 />
|
||||||
|
<foo:arg8 />
|
||||||
|
</foo:args>
|
||||||
|
</variable>
|
||||||
|
|
||||||
<scenario label="f:apply">
|
<scenario label="f:apply">
|
||||||
<scenario label="applied to a function reference element">
|
<scenario label="applied to complete argument list of">
|
||||||
<variable name="arg"
|
|
||||||
select="'foo'" />
|
|
||||||
|
|
||||||
<call function="f:apply">
|
|
||||||
<param name="fnref">
|
|
||||||
<f:ref>
|
|
||||||
<foo:fn1 />
|
|
||||||
</f:ref>
|
|
||||||
</param>
|
|
||||||
<param name="arg1" select="$arg" />
|
|
||||||
</call>
|
|
||||||
|
|
||||||
<!-- our test appliaction template simply echoes back its only
|
|
||||||
argument -->
|
|
||||||
<expect label="applies application template with mode f:apply"
|
|
||||||
test="$x:result = ($arg)" />
|
|
||||||
</scenario>
|
|
||||||
|
|
||||||
|
|
||||||
<scenario label="applying">
|
|
||||||
<scenario label="nullary function">
|
<scenario label="nullary function">
|
||||||
<call function="f:apply">
|
<call function="f:apply">
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
|
@ -55,8 +48,9 @@
|
||||||
</param>
|
</param>
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<!-- technically it applies a template -->
|
||||||
test="$x:result = 0" />
|
<expect label="applies target function"
|
||||||
|
test="$x:result[ 1 ] = foo:applied[ @n = 0 ]" />"
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,11 +59,12 @@
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
<f:ref><foo:fn1 /></f:ref>
|
<f:ref><foo:fn1 /></f:ref>
|
||||||
</param>
|
</param>
|
||||||
<param name="arg1" select="1" />
|
<param name="arg1" select="$args/foo:arg1" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<expect label="passes each argument"
|
||||||
test="$x:result = '1'" />
|
test="$x:result[ 1 ] = foo:applied[ @n = 1 ]
|
||||||
|
and $x:result[ 2 ] is $args/foo:arg1" />
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,12 +73,14 @@
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
<f:ref><foo:fn2 /></f:ref>
|
<f:ref><foo:fn2 /></f:ref>
|
||||||
</param>
|
</param>
|
||||||
<param name="arg1" select="1" />
|
<param name="arg1" select="$args/foo:arg1" />
|
||||||
<param name="arg2" select="2" />
|
<param name="arg2" select="$args/foo:arg2" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<expect label="passes each argument"
|
||||||
test="$x:result = '12'" />
|
test="$x:result[ 1 ] = foo:applied[ @n = 2 ]
|
||||||
|
and $x:result[ 2 ] is $args/foo:arg1
|
||||||
|
and $x:result[ 3 ] is $args/foo:arg2" />
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,13 +89,16 @@
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
<f:ref><foo:fn3 /></f:ref>
|
<f:ref><foo:fn3 /></f:ref>
|
||||||
</param>
|
</param>
|
||||||
<param name="arg1" select="1" />
|
<param name="arg1" select="$args/foo:arg1" />
|
||||||
<param name="arg2" select="2" />
|
<param name="arg2" select="$args/foo:arg2" />
|
||||||
<param name="arg3" select="3" />
|
<param name="arg3" select="$args/foo:arg3" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<expect label="passes each argument"
|
||||||
test="$x:result = '123'" />
|
test="$x:result[ 1 ] = foo:applied[ @n = 3 ]
|
||||||
|
and $x:result[ 2 ] is $args/foo:arg1
|
||||||
|
and $x:result[ 3 ] is $args/foo:arg2
|
||||||
|
and $x:result[ 4 ] is $args/foo:arg3" />
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,14 +107,18 @@
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
<f:ref><foo:fn4 /></f:ref>
|
<f:ref><foo:fn4 /></f:ref>
|
||||||
</param>
|
</param>
|
||||||
<param name="arg1" select="1" />
|
<param name="arg1" select="$args/foo:arg1" />
|
||||||
<param name="arg2" select="2" />
|
<param name="arg2" select="$args/foo:arg2" />
|
||||||
<param name="arg3" select="3" />
|
<param name="arg3" select="$args/foo:arg3" />
|
||||||
<param name="arg4" select="4" />
|
<param name="arg4" select="$args/foo:arg4" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<expect label="passes each argument"
|
||||||
test="$x:result = '1234'" />
|
test="$x:result[ 1 ] = foo:applied[ @n = 4 ]
|
||||||
|
and $x:result[ 2 ] is $args/foo:arg1
|
||||||
|
and $x:result[ 3 ] is $args/foo:arg2
|
||||||
|
and $x:result[ 4 ] is $args/foo:arg3
|
||||||
|
and $x:result[ 5 ] is $args/foo:arg4" />
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,15 +127,20 @@
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
<f:ref><foo:fn5 /></f:ref>
|
<f:ref><foo:fn5 /></f:ref>
|
||||||
</param>
|
</param>
|
||||||
<param name="arg1" select="1" />
|
<param name="arg1" select="$args/foo:arg1" />
|
||||||
<param name="arg2" select="2" />
|
<param name="arg2" select="$args/foo:arg2" />
|
||||||
<param name="arg3" select="3" />
|
<param name="arg3" select="$args/foo:arg3" />
|
||||||
<param name="arg4" select="4" />
|
<param name="arg4" select="$args/foo:arg4" />
|
||||||
<param name="arg5" select="5" />
|
<param name="arg5" select="$args/foo:arg5" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<expect label="passes each argument"
|
||||||
test="$x:result = '12345'" />
|
test="$x:result[ 1 ] = foo:applied[ @n = 5 ]
|
||||||
|
and $x:result[ 2 ] is $args/foo:arg1
|
||||||
|
and $x:result[ 3 ] is $args/foo:arg2
|
||||||
|
and $x:result[ 4 ] is $args/foo:arg3
|
||||||
|
and $x:result[ 5 ] is $args/foo:arg4
|
||||||
|
and $x:result[ 6 ] is $args/foo:arg5" />
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,16 +149,22 @@
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
<f:ref><foo:fn6 /></f:ref>
|
<f:ref><foo:fn6 /></f:ref>
|
||||||
</param>
|
</param>
|
||||||
<param name="arg1" select="1" />
|
<param name="arg1" select="$args/foo:arg1" />
|
||||||
<param name="arg2" select="2" />
|
<param name="arg2" select="$args/foo:arg2" />
|
||||||
<param name="arg3" select="3" />
|
<param name="arg3" select="$args/foo:arg3" />
|
||||||
<param name="arg4" select="4" />
|
<param name="arg4" select="$args/foo:arg4" />
|
||||||
<param name="arg5" select="5" />
|
<param name="arg5" select="$args/foo:arg5" />
|
||||||
<param name="arg6" select="6" />
|
<param name="arg6" select="$args/foo:arg6" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<expect label="passes each argument"
|
||||||
test="$x:result = '123456'" />
|
test="$x:result[ 1 ] = foo:applied[ @n = 6 ]
|
||||||
|
and $x:result[ 2 ] is $args/foo:arg1
|
||||||
|
and $x:result[ 3 ] is $args/foo:arg2
|
||||||
|
and $x:result[ 4 ] is $args/foo:arg3
|
||||||
|
and $x:result[ 5 ] is $args/foo:arg4
|
||||||
|
and $x:result[ 6 ] is $args/foo:arg5
|
||||||
|
and $x:result[ 7 ] is $args/foo:arg6" />
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,17 +173,24 @@
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
<f:ref><foo:fn7 /></f:ref>
|
<f:ref><foo:fn7 /></f:ref>
|
||||||
</param>
|
</param>
|
||||||
<param name="arg1" select="1" />
|
<param name="arg1" select="$args/foo:arg1" />
|
||||||
<param name="arg2" select="2" />
|
<param name="arg2" select="$args/foo:arg2" />
|
||||||
<param name="arg3" select="3" />
|
<param name="arg3" select="$args/foo:arg3" />
|
||||||
<param name="arg4" select="4" />
|
<param name="arg4" select="$args/foo:arg4" />
|
||||||
<param name="arg5" select="5" />
|
<param name="arg5" select="$args/foo:arg5" />
|
||||||
<param name="arg6" select="6" />
|
<param name="arg6" select="$args/foo:arg6" />
|
||||||
<param name="arg7" select="7" />
|
<param name="arg7" select="$args/foo:arg7" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<expect label="passes each argument"
|
||||||
test="$x:result = '1234567'" />
|
test="$x:result[ 1 ] = foo:applied[ @n = 7 ]
|
||||||
|
and $x:result[ 2 ] is $args/foo:arg1
|
||||||
|
and $x:result[ 3 ] is $args/foo:arg2
|
||||||
|
and $x:result[ 4 ] is $args/foo:arg3
|
||||||
|
and $x:result[ 5 ] is $args/foo:arg4
|
||||||
|
and $x:result[ 6 ] is $args/foo:arg5
|
||||||
|
and $x:result[ 7 ] is $args/foo:arg6
|
||||||
|
and $x:result[ 8 ] is $args/foo:arg7" />
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,18 +199,26 @@
|
||||||
<param name="fnref">
|
<param name="fnref">
|
||||||
<f:ref><foo:fn8 /></f:ref>
|
<f:ref><foo:fn8 /></f:ref>
|
||||||
</param>
|
</param>
|
||||||
<param name="arg1" select="1" />
|
<param name="arg1" select="$args/foo:arg1" />
|
||||||
<param name="arg2" select="2" />
|
<param name="arg2" select="$args/foo:arg2" />
|
||||||
<param name="arg3" select="3" />
|
<param name="arg3" select="$args/foo:arg3" />
|
||||||
<param name="arg4" select="4" />
|
<param name="arg4" select="$args/foo:arg4" />
|
||||||
<param name="arg5" select="5" />
|
<param name="arg5" select="$args/foo:arg5" />
|
||||||
<param name="arg6" select="6" />
|
<param name="arg6" select="$args/foo:arg6" />
|
||||||
<param name="arg7" select="7" />
|
<param name="arg7" select="$args/foo:arg7" />
|
||||||
<param name="arg8" select="8" />
|
<param name="arg8" select="$args/foo:arg8" />
|
||||||
</call>
|
</call>
|
||||||
|
|
||||||
<expect label="passes each argument"
|
<expect label="passes each argument"
|
||||||
test="$x:result = '12345678'" />
|
test="$x:result[ 1 ] = foo:applied[ @n = 8 ]
|
||||||
|
and $x:result[ 2 ] is $args/foo:arg1
|
||||||
|
and $x:result[ 3 ] is $args/foo:arg2
|
||||||
|
and $x:result[ 4 ] is $args/foo:arg3
|
||||||
|
and $x:result[ 5 ] is $args/foo:arg4
|
||||||
|
and $x:result[ 6 ] is $args/foo:arg5
|
||||||
|
and $x:result[ 7 ] is $args/foo:arg6
|
||||||
|
and $x:result[ 8 ] is $args/foo:arg7
|
||||||
|
and $x:result[ 9 ] is $args/foo:arg8" />
|
||||||
</scenario>
|
</scenario>
|
||||||
</scenario>
|
</scenario>
|
||||||
</scenario>
|
</scenario>
|
||||||
|
|
Loading…
Reference in New Issue