for (Expression testCase
: ((ArrayConstructor) testcases.getValueExpr()).children()) {
ObjectConstructor testCaseObj = (ObjectConstructor) testCase;
String cssText = null;
String golden = null;
ArrayConstructor messages = null;
for (ObjProperty oprop : testCaseObj.children()) {
ValueProperty prop = (ValueProperty) oprop;
String pname = prop.getPropertyName();
try {
if ("cssText".equals(pname)) {
cssText = ((StringLiteral) prop.getValueExpr())
.getUnquotedValue();
} else if ("golden".equals(pname)) {
golden = ((StringLiteral) prop.getValueExpr())
.getUnquotedValue();
} else if ("messages".equals(pname)) {
messages = (ArrayConstructor) prop.getValueExpr();
} else if ("altGolden".equals(pname)) {
// OK.
} else {
fail(
"Unrecognized testcase property " + pname + " in "
+ render(testCase) + " at " + testCase.getFilePosition());
}
} catch (RuntimeException ex) {
System.err.println(
"Type mismatch in " + name
+ " at " + testCase.getFilePosition());
throw ex;
}
}
String normalizedGolden = "".equals(golden)
? "" : render(css(fromString(golden)));
mq.getMessages().clear();
try {
runTest(cssText, normalizedGolden);
if (messages != null) {
for (Expression message : messages.children()) {
ObjectConstructor messageObj = (ObjectConstructor) message;
String type = ((StringLiteral)
((ValueProperty) messageObj.propertyWithName("type"))
.getValueExpr())
.getUnquotedValue();
String level = ((StringLiteral)
((ValueProperty) messageObj.propertyWithName("level"))
.getValueExpr())
.getUnquotedValue();
List<String> args = Lists.newArrayList();
ArrayConstructor argsArray = (ArrayConstructor)
((ValueProperty) messageObj.propertyWithName("args"))
.getValueExpr();
for (Expression argExpr : argsArray.children()) {
args.add(((StringLiteral) argExpr).getUnquotedValue());
}
consumeMessage(message.getFilePosition(), type, level, args);
}
assertNoErrors();