Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Jun 8, 2015 · 3 comments
Open

Comments

@GoogleCodeExporter
Copy link

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

Original issue reported on code.google.com by volodymy...@gmail.com on 7 May 2012 at 2:03

@GoogleCodeExporter
Copy link
Author

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?

Original comment by volodymy...@gmail.com on 7 May 2012 at 2:27

@GoogleCodeExporter
Copy link
Author

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

Original comment by volodymy...@gmail.com on 7 May 2012 at 2:35

@GoogleCodeExporter
Copy link
Author

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

Original comment by mikegerw...@gmail.com on 15 Oct 2014 at 4:54

innovimax pushed a commit to innovimax/xspec that referenced this issue Jan 17, 2017
innovimax pushed a commit to innovimax/xspec that referenced this issue Jan 17, 2017
innovimax pushed a commit to innovimax/xspec that referenced this issue Jan 17, 2017
* Add test case for Windows batch script for issue expath#46 / pr expath#48
* Align batch script with shell script to mimic setup/teardown functions in batch script (82a3d49)
- Use the same output dir and file as the shell script for .gitignore to fully take effect on windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant