Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.VariableExpression


  @Test
  public void test_Validate_AssignmentExpression_NotOk_Decimal() {
    PuppetManifest pp = pf.createPuppetManifest();
    AssignmentExpression ae = pf.createAssignmentExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$0");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

    tester.validate(pp).assertError(IPPDiagnostics.ISSUE__ASSIGNMENT_DECIMAL_VAR);
View Full Code Here


  @Test
  public void test_Validate_AssignmentExpression_NotOk_Scope() {
    PuppetManifest pp = pf.createPuppetManifest();
    AssignmentExpression ae = pf.createAssignmentExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$a::b");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

    tester.validate(pp).assertError(IPPDiagnostics.ISSUE__ASSIGNMENT_OTHER_NAMESPACE);
View Full Code Here

  @Test
  public void test_Validate_AssignmentExpression_Ok() {
    PuppetManifest pp = pf.createPuppetManifest();
    AssignmentExpression ae = pf.createAssignmentExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$x");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

    tester.validate(pp).assertOK();
View Full Code Here

  }

  @Test
  public void test_Validate_Manifest_NotOk() {
    PuppetManifest pp = pf.createPuppetManifest();
    VariableExpression v = pf.createVariableExpression();
    pp.getStatements().add(v);
    v.setVarName("$x");
    tester.validate(pp).assertError(IPPDiagnostics.ISSUE__NOT_TOPLEVEL);
  }
View Full Code Here

  @Test
  public void test_Validate_Manifest_Ok() {
    PuppetManifest pp = pf.createPuppetManifest();
    AssignmentExpression a = pf.createAssignmentExpression();
    VariableExpression v = pf.createVariableExpression();
    pp.getStatements().add(a);
    v.setVarName("$x");
    a.setLeftExpr(v);
    LiteralNameOrReference value = createNameOrReference("10");
    a.setRightExpr(value);
    tester.validate(pp).assertOK();
  }
View Full Code Here

  @Test
  public void test_Validate_MatchingExpression_NotOk() {
    PuppetManifest pp = pf.createPuppetManifest();
    MatchingExpression me = pf.createMatchingExpression();
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$x");
    VariableExpression v2 = pf.createVariableExpression();
    v2.setVarName("$y");

    me.setLeftExpr(v);
    me.setOpName("=~");
    me.setRightExpr(v2);
    pp.getStatements().add(me);
View Full Code Here

  public void test_Validate_MatchingExpression_Ok() {
    PuppetManifest pp = pf.createPuppetManifest();
    MatchingExpression me = pf.createMatchingExpression();
    LiteralRegex regex = pf.createLiteralRegex();
    regex.setValue("/[a-z]*/");
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$x");
    me.setLeftExpr(v);
    me.setOpName("=~");
    me.setRightExpr(regex);
    pp.getStatements().add(me);

View Full Code Here

  }

  @Test
  public void test_Validate_VariableExpression_NotOk() {
    PuppetManifest pp = pf.createPuppetManifest();
    VariableExpression v = pf.createVariableExpression();
    pp.getStatements().add(v);

    // name is null
    tester.validate(v).assertError(IPPDiagnostics.ISSUE__NOT_VARNAME);

    v.setVarName("");
    tester.validate(v).assertError(IPPDiagnostics.ISSUE__NOT_VARNAME);

    v.setVarName("x");
    tester.validate(v).assertError(IPPDiagnostics.ISSUE__NOT_VARNAME);

    // period is allowed in names, but not in variables
    v.setVarName("$3.4");
    tester.validate(v).assertError(IPPDiagnostics.ISSUE__NOT_VARNAME);
  }
View Full Code Here

  }

  @Test
  public void test_Validate_VariableExpression_Ok() {
    PuppetManifest pp = pf.createPuppetManifest();
    VariableExpression v = pf.createVariableExpression();
    pp.getStatements().add(v);
    v.setVarName("$x");

    tester.validate(v).assertOK();

    v.setVarName("$abc123");
    tester.validate(v).assertOK();

    v.setVarName("$0");
    tester.validate(v).assertOK();

    v.setVarName("$3_4");
    tester.validate(v).assertOK();

  }
View Full Code Here

    v.setValue(txt);
    return v;
  }

  protected VariableExpression createVariable(String name) {
    VariableExpression v = pf.createVariableExpression();
    v.setVarName("$" + name);
    return v;
  }
View Full Code Here

TOP

Related Classes of com.puppetlabs.geppetto.pp.VariableExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.