xpath/trunk/XMLv2__XPathExpressionOptimizerTests.st
changeset 0 5057afe1ec87
equal deleted inserted replaced
-1:000000000000 0:5057afe1ec87
       
     1 "{ Package: 'stx:goodies/xmlsuite/xpath' }"
       
     2 
       
     3 "{ NameSpace: XMLv2 }"
       
     4 
       
     5 TestCase subclass:#XPathExpressionOptimizerTests
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'XML Suite-XPath-Tests'
       
    10 !
       
    11 
       
    12 
       
    13 !XPathExpressionOptimizerTests methodsFor:'parsing'!
       
    14 
       
    15 parseAndOptimize: string
       
    16 
       
    17     ^XPathExpressionOptimizer optimize: (XPathParser parse: string).
       
    18 
       
    19     "Created: / 21-11-2007 / 10:49:20 / janfrog"
       
    20 ! !
       
    21 
       
    22 !XPathExpressionOptimizerTests methodsFor:'tests - descendant-or-self'!
       
    23 
       
    24 test_descendantOrSelf_01
       
    25 
       
    26     | xpath |
       
    27     xpath := self parseAndOptimize: '//test'.
       
    28 
       
    29     self assert: xpath size = 1.
       
    30     self assert: xpath first axis class == XPathAxisDescendantOrSelf.
       
    31     self assert: xpath first nodeTest class == XPathNameTest.
       
    32 
       
    33     "Created: / 21-11-2007 / 10:58:15 / janfrog"
       
    34 !
       
    35 
       
    36 test_descendantOrSelf_02
       
    37 
       
    38     | xpath |
       
    39     xpath := self parseAndOptimize: 'test1//test2'.
       
    40 
       
    41     self assert: xpath size = 2.
       
    42 
       
    43     self assert: xpath first axis class == XPathAxisChild.
       
    44     self assert: xpath first nodeTest class == XPathNameTest.
       
    45     self assert: xpath first nodeTest localName = 'test1'.
       
    46 
       
    47     self assert: xpath second axis class == XPathAxisDescendantOrSelf.
       
    48     self assert: xpath second nodeTest class == XPathNameTest.
       
    49     self assert: xpath second nodeTest localName = 'test2'.
       
    50 
       
    51     "Created: / 21-11-2007 / 10:59:38 / janfrog"
       
    52 !
       
    53 
       
    54 test_descendantOrSelf_03
       
    55 
       
    56     | xpath |
       
    57     xpath := self parseAndOptimize: '//@test2'.
       
    58 
       
    59     self assert: xpath size = 2.
       
    60 
       
    61     self assert: xpath first axis class == XPathAxisDescendantOrSelf.
       
    62     self assert: xpath first nodeTest class == XPathAnyKindTest.
       
    63 
       
    64     self assert: xpath second axis class == XPathAxisAttribute.
       
    65     self assert: xpath second nodeTest class == XPathNameTest.
       
    66     self assert: xpath second nodeTest localName = 'test2'.
       
    67 
       
    68     "Created: / 21-11-2007 / 11:00:55 / janfrog"
       
    69 ! !
       
    70 
       
    71 !XPathExpressionOptimizerTests class methodsFor:'documentation'!
       
    72 
       
    73 version
       
    74     ^ '$Header: /opt/data/cvs/stx/goodies/xmlsuite/xpath/XMLv2__XPathExpressionOptimizerTests.st,v 1.1 2007-11-22 21:46:50 vranyj1 Exp $'
       
    75 ! !