Skip to content

Commit 4b551b8

Browse files
committed
Adds some XSpec test cases for escaping/escaped string values
1 parent 814c6e9 commit 4b551b8

File tree

2 files changed

+148
-3
lines changed

2 files changed

+148
-3
lines changed

src/test/xspec/css-model-serializer.xspec

+89-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:cssm="http://www.nkutsche.com/css3-model" xmlns="http://www.nkutsche.com/css3-model"
44
stylesheet="../../main/resources/xsl/css3-model-serializer.xsl">
55

6-
<x:scenario label="Testing function cssm:serialize-property-value" focus="">
6+
<x:scenario label="Testing function cssm:serialize-property-value">
77
<x:call function="cssm:serialize-property-value"/>
88

99
<x:scenario label="without quotes and important">
@@ -20,7 +20,15 @@
2020
</x:call>
2121
<x:expect label="result" select="'value'"/>
2222
</x:scenario>
23-
<x:scenario label="value serialization">
23+
<x:scenario label="string serialization with spaces">
24+
<x:call>
25+
<x:param>
26+
<property name="prop" string="string with space"/>
27+
</x:param>
28+
</x:call>
29+
<x:expect label="result" select="string(.)">'string with space'</x:expect>
30+
</x:scenario>
31+
<x:scenario label="value list serialization">
2432
<x:call>
2533
<x:param>
2634
<property name="property">
@@ -30,7 +38,85 @@
3038
</property>
3139
</x:param>
3240
</x:call>
33-
<x:expect label="result" select="'value1 value2 value3'"/>
41+
<x:expect label="result" select="string(.)">value1 value2 value3</x:expect>
42+
</x:scenario>
43+
<x:scenario label="string in list serialization">
44+
<x:call>
45+
<x:param>
46+
<property name="property">
47+
<string>value1</string>
48+
<value>value2</value>
49+
<value>value3</value>
50+
</property>
51+
</x:param>
52+
</x:call>
53+
<x:expect label="result" select="string(.)">value1 value2 value3</x:expect>
54+
</x:scenario>
55+
<x:scenario label="string in list serialization with spaces">
56+
<x:call>
57+
<x:param>
58+
<property name="property">
59+
<string>value1 value2</string>
60+
<value>value3</value>
61+
</property>
62+
</x:param>
63+
</x:call>
64+
<x:expect label="result" select="string(.)">'value1 value2' value3</x:expect>
65+
</x:scenario>
66+
<x:scenario label="property:'value1&quot;value2' value3">
67+
<x:call>
68+
<x:param>
69+
<property name="property">
70+
<string>value1"value2</string>
71+
<value>value3</value>
72+
</property>
73+
</x:param>
74+
</x:call>
75+
<x:expect label="result" select="string(.)">'value1"value2' value3</x:expect>
76+
</x:scenario>
77+
<x:scenario label='property:"value1&apos;value2" value3'>
78+
<x:call>
79+
<x:param>
80+
<property name="property">
81+
<string>value1'value2</string>
82+
<value>value3</value>
83+
</property>
84+
</x:param>
85+
</x:call>
86+
<x:expect label="result" select="string(.)">"value1'value2" value3</x:expect>
87+
</x:scenario>
88+
<x:scenario label='property:"value1&apos;\"value2" value3'>
89+
<x:call>
90+
<x:param>
91+
<property name="property">
92+
<string>value1'"value2</string>
93+
<value>value3</value>
94+
</property>
95+
</x:param>
96+
</x:call>
97+
<x:expect label="result" select="string(.)">"value1'\"value2" value3</x:expect>
98+
</x:scenario>
99+
<x:scenario label='property:"value1\value2" value3'>
100+
<x:call>
101+
<x:param>
102+
<property name="property">
103+
<string>value1\value2</string>
104+
<value>value3</value>
105+
</property>
106+
</x:param>
107+
</x:call>
108+
<x:expect label="result" select="string(.)">'value1\\value2' value3</x:expect>
109+
</x:scenario>
110+
<x:scenario label='property:"value1\\value2" value3'>
111+
<x:call>
112+
<x:param>
113+
<property name="property">
114+
<string>value1\\value2</string>
115+
<value>value3</value>
116+
</property>
117+
</x:param>
118+
</x:call>
119+
<x:expect label="result" select="string(.)">'value1\\\\value2' value3</x:expect>
34120
</x:scenario>
35121
</x:scenario>
36122

src/test/xspec/css-model.xspec

+59
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,65 @@
11841184
</css>
11851185
</x:expect>
11861186
</x:scenario>
1187+
<x:scenario label="escaped-string:'foo''bar'">
1188+
<x:call>
1189+
<x:param select="string(.)">* {escaped-string:'foo''bar'}</x:param>
1190+
</x:call>
1191+
<x:expect label="This is a parsing error">
1192+
<ERROR b="29" e="29" s="22" xmlns="">...</ERROR>
1193+
</x:expect>
1194+
</x:scenario>
1195+
<x:scenario label='escaped-string:"&apos;"'>
1196+
<x:call>
1197+
<x:param select="string(.)">* {escaped-string:"'"}</x:param>
1198+
</x:call>
1199+
<x:expect label="rule selector">
1200+
<css>
1201+
<rule>
1202+
<selector specificity="...">
1203+
<select/>
1204+
</selector>
1205+
<property-set>
1206+
<property name="escaped-string" string="'"/>
1207+
</property-set>
1208+
</rule>
1209+
</css>
1210+
</x:expect>
1211+
</x:scenario>
1212+
<x:scenario label="escaped-string:'&quot;'">
1213+
<x:call>
1214+
<x:param select="string(.)">* {escaped-string:'"'}</x:param>
1215+
</x:call>
1216+
<x:expect label="rule selector">
1217+
<css>
1218+
<rule>
1219+
<selector specificity="...">
1220+
<select/>
1221+
</selector>
1222+
<property-set>
1223+
<property name="escaped-string" string='"'/>
1224+
</property-set>
1225+
</rule>
1226+
</css>
1227+
</x:expect>
1228+
</x:scenario>
1229+
<x:scenario label="backslash-in-value:foo\bar">
1230+
<x:call>
1231+
<x:param select="string(.)">* {backslash-in-value:foo\bar}</x:param>
1232+
</x:call>
1233+
<x:expect label="rule selector">
1234+
<css>
1235+
<rule>
1236+
<selector specificity="...">
1237+
<select/>
1238+
</selector>
1239+
<property-set>
1240+
<property name="backslash-in-value" value="foo\bar"/>
1241+
</property-set>
1242+
</rule>
1243+
</css>
1244+
</x:expect>
1245+
</x:scenario>
11871246
</x:scenario>
11881247

11891248
<x:scenario label="attr-ref:attr(aname)">

0 commit comments

Comments
 (0)