Issue 46 in xspec: Combination of @test and content in x:expect doesn't work

12 views
Skip to first unread message

xs...@googlecode.com

unread,
May 7, 2012, 10:03:32 AM5/7/12
to xspe...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 46 by volodymy...@gmail.com: Combination of @test and content in
x:expect doesn't work
http://code.google.com/p/xspec/issues/detail?id=46

Following xspec:
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
stylesheet="identical.xsl">

<x:scenario label="Test combination of expect content and @test
attribute">
<x:context>
<topic>
<body>Body</body>
</topic>
</x:context>

<x:expect label="Should select one element from result and compare
to content" test="descendant::body">
<body>Body</body>
</x:expect>
</x:scenario>

</x:description>

using identity transformation:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output indent="no"/>

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

always fail


xs...@googlecode.com

unread,
May 7, 2012, 10:27:53 AM5/7/12
to xspe...@googlegroups.com

Comment #1 on issue 46 by volodymy...@gmail.com: Combination of @test and
content in x:expect doesn't work
http://code.google.com/p/xspec/issues/detail?id=46

I've tracked down the problem. When test attribute is specified and expect
have context elements results are wrapped in document node. When expected
content is simple sequence.

Expected is evaluated using following function:
<xsl:variable name="impl:successful"
as="xs:boolean"
select="test:deep-equal($impl:expected, if (
$impl:with-context ) then $impl:context else $x:result, 2)"/>

In our case $impl:with-context is true(). So we using $impl:context which
is evaluated as:
<xsl:variable name="impl:context" as="item()?">
<xsl:choose>
<xsl:when test="$impl:context-tmp instance of node()+">
<xsl:document>
<xsl:sequence select="$impl:context-tmp"/>
</xsl:document>
</xsl:when>
<xsl:otherwise>
<xsl:sequence select="$impl:context-tmp"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

$impl:context-tmp contain nodes selected by @test attribute of x:excpect.
As result they wrapped into document.

Question why?

xs...@googlecode.com

unread,
May 7, 2012, 10:35:06 AM5/7/12
to xspe...@googlegroups.com

Comment #2 on issue 46 by volodymy...@gmail.com: Combination of @test and
content in x:expect doesn't work
http://code.google.com/p/xspec/issues/detail?id=46

Solution: remove impl:context variable and rename $impl:context-tmp to
$impl:context

xs...@googlecode.com

unread,
Oct 15, 2014, 12:54:05 PM10/15/14
to xspe...@googlegroups.com

Comment #3 on issue 46 by mikegerw...@gmail.com: Combination of @test and
content in x:expect doesn't work
https://code.google.com/p/xspec/issues/detail?id=46

I discovered the same thing while working on some of my own test cases.

This issue has existed since May 2012; I have therefore forked the xspec
repository, where this bug has been corrected (and a test case added):

https://github.com/lovullo/xspec/commit/e48b5282256e1fc47246f4b7fae35008631ba56d

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages