Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.AssignmentExpression


        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case PPPackage.ASSIGNMENT_EXPRESSION: {
        AssignmentExpression assignmentExpression = (AssignmentExpression) theEObject;
        T result = caseAssignmentExpression(assignmentExpression);
        if(result == null)
          result = caseBinaryExpression(assignmentExpression);
        if(result == null)
          result = caseExpression(assignmentExpression);
View Full Code Here


      p = p.eContainer();
    if(p == null)
      return 0; // not in an assignment

    // p is an AssignmentExpression at this point
    AssignmentExpression d = (AssignmentExpression) p;
    final String definitionFragment = d.eResource().getURIFragment(d);
    final String definitionURI = d.eResource().getURI().toString();

    int removedCount = 0;
    ListIterator<IEObjectDescription> litor = descs.listIterator();
    while(litor.hasNext()) {
      IEObjectDescription x = litor.next();
View Full Code Here

  @Test
  public void test_Serialize_assignArray() throws Exception {
    PuppetManifest pp = pf.createPuppetManifest();
    EList<Expression> statements = pp.getStatements();
    AssignmentExpression assignment = PPFactory.eINSTANCE.createAssignmentExpression();
    assignment.setLeftExpr(createVariable("a"));
    LiteralList pplist = PPFactory.eINSTANCE.createLiteralList();
    assignment.setRightExpr(pplist);
    pplist.getElements().add(createSqString("10"));
    pplist.getElements().add(createSqString("20"));
    statements.add(assignment);
    String fmt = "$a = ['10', '20',]\n";
    String s = serialize(pp);
View Full Code Here

   * Test that model without node-model formats and adds the optional end comma in a list.
   */
  @Test
  public void test_List_NoNodeModel() throws Exception {
    PuppetManifest pp = pf.createPuppetManifest();
    AssignmentExpression assignment = PPFactory.eINSTANCE.createAssignmentExpression();
    assignment.setLeftExpr(createVariable("a"));
    LiteralList pplist = PPFactory.eINSTANCE.createLiteralList();
    assignment.setRightExpr(pplist);
    pplist.getElements().add(createSqString("10"));
    pplist.getElements().add(createSqString("20"));
    pp.getStatements().add(assignment);
    String fmt = "$a = ['10', '20',]\n";
    String s = serializeFormatted(pp);
View Full Code Here

  }

  @Test
  public void test_Serialize_assignArray() throws Exception {
    PuppetManifest pp = pf.createPuppetManifest();
    AssignmentExpression assignment = PPFactory.eINSTANCE.createAssignmentExpression();
    assignment.setLeftExpr(createVariable("a"));
    LiteralList pplist = PPFactory.eINSTANCE.createLiteralList();
    assignment.setRightExpr(pplist);
    pplist.getElements().add(createSqString("10"));
    pplist.getElements().add(createSqString("20"));
    pp.getStatements().add(assignment);
    String fmt = "$a = [ '10' , '20' , ]";
    String s = serialize(pp);
View Full Code Here

  // }

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

    String s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_Assignment1, s);

    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(v);
    at.getParameters().add(createNameOrReference("a"));
    ae.setLeftExpr(at);
    tester.validate(pp).assertOK();
    s = serializeFormatted(pp);
    assertEquals("serialization should produce specified result", Sample_Assignment2, s);
  }
View Full Code Here

  }

  @Test
  public void test_Validate_AssignmentExpression_NotOk() {
    PuppetManifest pp = pf.createPuppetManifest();
    AssignmentExpression ae = pf.createAssignmentExpression();
    LiteralBoolean b = pf.createLiteralBoolean();
    LiteralNameOrReference v = createNameOrReference("x");
    ae.setLeftExpr(v);
    ae.setRightExpr(b);
    pp.getStatements().add(ae);

    tester.validate(pp).assertError(IPPDiagnostics.ISSUE__NOT_ASSIGNABLE);

  }
View Full Code Here

   * - $0 = expr
   */
  @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

   * - $a::b = expr
   */
  @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

   * - $x[expr] = expr
   */
  @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();

    AtExpression at = pf.createAtExpression();
    at.setLeftExpr(v);
    at.getParameters().add(createNameOrReference("a"));
    ae.setLeftExpr(at);
    tester.validate(pp).assertOK();
  }
View Full Code Here

TOP

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

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.