Skip to content

Commit f2d249c

Browse files
committed
add missing test cases
1 parent 5fa7c93 commit f2d249c

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

src/main/javacc/CSS3Parser.jj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ LexicalUnit rgbColor(LexicalUnit prev) :
19691969
| next = percentage(next, op)
19701970
)
19711971
)
1972-
{ op = ' '; }
1972+
{ op = ' '; }
19731973

19741974
( <S> )*
19751975
(
@@ -1985,7 +1985,7 @@ LexicalUnit rgbColor(LexicalUnit prev) :
19851985
| next = percentage(next, op)
19861986
)
19871987
)
1988-
{ op = ' '; }
1988+
{ op = ' '; }
19891989

19901990
( <S> )*
19911991
(
@@ -2054,7 +2054,7 @@ LexicalUnit hslColor(LexicalUnit prev) :
20542054
| next = percentage(next, op)
20552055
)
20562056
)
2057-
{ op = ' '; }
2057+
{ op = ' '; }
20582058

20592059
( <S> )*
20602060
(
@@ -2069,7 +2069,7 @@ LexicalUnit hslColor(LexicalUnit prev) :
20692069
| next = percentage(next, op)
20702070
)
20712071
)
2072-
{ op = ' '; }
2072+
{ op = ' '; }
20732073

20742074
( <S> )*
20752075
(
@@ -2134,7 +2134,7 @@ LexicalUnit hwbColor(LexicalUnit prev) :
21342134
| next = percentage(next, op)
21352135
)
21362136
)
2137-
{ op = ' '; }
2137+
{ op = ' '; }
21382138

21392139
( <S> )*
21402140

@@ -2145,7 +2145,7 @@ LexicalUnit hwbColor(LexicalUnit prev) :
21452145
| next = percentage(next, op)
21462146
)
21472147
)
2148-
{ op = ' '; }
2148+
{ op = ' '; }
21492149

21502150
( <S> )*
21512151
(
@@ -2205,7 +2205,7 @@ LexicalUnit labColor(LexicalUnit prev) :
22052205
| next = percentage(next, op)
22062206
)
22072207
)
2208-
{ op = ' '; }
2208+
{ op = ' '; }
22092209

22102210
( <S> )*
22112211

@@ -2217,7 +2217,7 @@ LexicalUnit labColor(LexicalUnit prev) :
22172217
| next = percentage(next, op)
22182218
)
22192219
)
2220-
{ op = ' '; }
2220+
{ op = ' '; }
22212221

22222222
( <S> )*
22232223
(
@@ -2277,7 +2277,7 @@ LexicalUnit lchColor(LexicalUnit prev) :
22772277
| next = percentage(next, op)
22782278
)
22792279
)
2280-
{ op = ' '; }
2280+
{ op = ' '; }
22812281

22822282
( <S> )*
22832283

@@ -2291,7 +2291,7 @@ LexicalUnit lchColor(LexicalUnit prev) :
22912291
| t = <ANGLE_TURN> { next = LexicalUnitImpl.createTurn(next, doubleValue(op, t.image)); }
22922292
)
22932293
)
2294-
{ op = ' '; }
2294+
{ op = ' '; }
22952295

22962296
( <S> )*
22972297
(

src/test/java/org/htmlunit/cssparser/parser/CSS3ParserTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import org.htmlunit.cssparser.parser.selector.Selector;
5858
import org.htmlunit.cssparser.parser.selector.Selector.SelectorType;
5959
import org.htmlunit.cssparser.parser.selector.SelectorList;
60+
import org.junit.jupiter.api.Assertions;
6061
import org.junit.jupiter.api.Test;
6162

6263
/**
@@ -1271,6 +1272,15 @@ public void hslVariousErrors() throws Exception {
12711272
color(1, "DOM exception: ''hsl' has to use blank as separator if none is used.'", "foreground: hsl(10, 20%, none)");
12721273
color(1, "DOM exception: ''hsl' has to use blank as separator if none is used.'", "foreground: hsl(10, 20%, 30%, none)");
12731274

1275+
color(1, "Error in expression. (Invalid token \"-none\". Was expecting one of: <S>, <NUMBER>, \"none\", \"-\", \"+\", <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>.)",
1276+
"foreground: hsl(-none 20% 30%)");
1277+
color(1, "Error in expression. (Invalid token \"-none\". Was expecting one of: <S>, \"none\", \"-\", \"+\", \",\", <PERCENTAGE>.)",
1278+
"foreground: hsl(10 -none 30%)");
1279+
color(1, "Error in expression. (Invalid token \"-none\". Was expecting one of: <S>, \"none\", \"-\", \"+\", \",\", <PERCENTAGE>.)",
1280+
"foreground: hsl(10 20% -none)");
1281+
color(1, "Error in expression. (Invalid token \"-none\". Was expecting one of: <S>, <NUMBER>, \"none\", \"-\", \"+\", <PERCENTAGE>.)",
1282+
"foreground: hsl(10 20% 30% / -none)");
1283+
12741284
// mixing numbers and percentages is supported by current browsers
12751285
// color(1, "DOM exception: 'hsl mixing numbers and percentages.'", "foreground: hsl(10rad, 20, 30)");
12761286
// color(1, "DOM exception: 'hsl mixing numbers and percentages.'", "foreground: hsl(10rad, 20%, 30)");
@@ -1349,6 +1359,15 @@ public void hwbVariousErrors() throws Exception {
13491359

13501360
color(1, "DOM exception: ''hwb' alpha value must be separated by '/'.'", "foreground: hwb(10 20% 30% 40)");
13511361

1362+
color(1, "Error in expression. (Invalid token \"-none\". Was expecting one of: <S>, <NUMBER>, \"none\", \"-\", \"+\", <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>.)",
1363+
"foreground: hwb(-none 20% 30%)");
1364+
color(1, "Error in expression. (Invalid token \"-none\". Was expecting one of: <S>, \"none\", \"-\", \"+\", <PERCENTAGE>.)",
1365+
"foreground: hwb(10 -none 30%)");
1366+
color(1, "Error in expression. (Invalid token \"-none\". Was expecting one of: <S>, \"none\", \"-\", \"+\", <PERCENTAGE>.)",
1367+
"foreground: hwb(10 20% -none)");
1368+
color(1, "Error in expression. (Invalid token \"-none\". Was expecting one of: <S>, <NUMBER>, \"none\", \"-\", \"+\", <PERCENTAGE>.)",
1369+
"foreground: hwb(10 20% 30% / -none)");
1370+
13521371
color(1, "Error in expression. (Invalid token \")\". Was expecting one of: <S>, <NUMBER>, \"none\", \"-\", \"+\", <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <ANGLE_TURN>.)",
13531372
"foreground: hwb()");
13541373
color(1, "Error in expression. (Invalid token \")\". Was expecting one of: <S>, \"none\", \"-\", \"+\", <PERCENTAGE>.)",
@@ -1693,6 +1712,9 @@ private void color(final int errorCount, final String expected, final String css
16931712

16941713
final CSSStyleDeclarationImpl style = parser.parseStyleDeclaration(cssText);
16951714

1715+
if (errorCount == 0 && errorHandler.getErrorCount() > 0) {
1716+
Assertions.fail("Found errors; First: " + errorHandler.getErrorMessage());
1717+
}
16961718
assertEquals(errorCount, errorHandler.getErrorCount());
16971719
if (errorCount > 0) {
16981720
assertEquals(expected, errorHandler.getErrorMessage());

0 commit comments

Comments
 (0)