public void test_Validate_SelectorExpression_Ok() {
PuppetManifest pp = pf.createPuppetManifest();
SelectorExpression se = pf.createSelectorExpression();
pp.getStatements().add(se);
SelectorEntry entry = pf.createSelectorEntry();
se.getParameters().add(entry);
// -- Literal String
{
SingleQuotedString slhs = pf.createSingleQuotedString();
slhs.setText("x");
LiteralName entrylhs = pf.createLiteralName();
entrylhs.setValue("a");
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
}
// -- LiteralName
{
LiteralName slhs = pf.createLiteralName();
slhs.setValue("x");
LiteralName entrylhs = pf.createLiteralName();
entrylhs.setValue("a");
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
}
// -- LiteralNameOrReference
{
LiteralNameOrReference slhs = createNameOrReference("x");
LiteralNameOrReference entrylhs = createNameOrReference("a");
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
}
// -- variable
{
VariableExpression slhs = pf.createVariableExpression();
slhs.setVarName("$x");
VariableExpression entrylhs = pf.createVariableExpression();
entrylhs.setVarName("$a");
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
}
// -- function call
{
FunctionCall slhs = pf.createFunctionCall();
slhs.setLeftExpr(createNameOrReference("include"));
slhs.getParameters().add(pf.createLiteralBoolean());
FunctionCall entrylhs = pf.createFunctionCall();
entrylhs.setLeftExpr(createNameOrReference("include"));
entrylhs.getParameters().add(pf.createLiteralBoolean());
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
}
// boolean
{
LiteralBoolean slhs = pf.createLiteralBoolean();
LiteralBoolean entrylhs = pf.createLiteralBoolean();
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
}
// -- undef
{
LiteralUndef slhs = pf.createLiteralUndef();
LiteralUndef entrylhs = pf.createLiteralUndef();
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
}
// -- regex
{
LiteralRegex slhs = pf.createLiteralRegex();
slhs.setValue("/[a-z]*/");
LiteralRegex entrylhs = pf.createLiteralRegex();
entrylhs.setValue("/[a-z]*/");
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertAll(AssertableDiagnostics.warningCode(IPPDiagnostics.ISSUE__MISSING_DEFAULT));
}
// -- default
{
LiteralDefault slhs = pf.createLiteralDefault();
LiteralDefault entrylhs = pf.createLiteralDefault();
se.setLeftExpr(slhs);
entry.setLeftExpr(entrylhs);
entry.setRightExpr(pf.createLiteralBoolean());
tester.validate(se).assertOK();
}
}