Package com.puppetlabs.geppetto.pp

Examples of com.puppetlabs.geppetto.pp.SingleQuotedString


        if(result == null)
          result = defaultCase(theEObject);
        return result;
      }
      case PPPackage.SINGLE_QUOTED_STRING: {
        SingleQuotedString singleQuotedString = (SingleQuotedString) theEObject;
        T result = caseSingleQuotedString(singleQuotedString);
        if(result == null)
          result = caseStringExpression(singleQuotedString);
        if(result == null)
          result = caseIQuotedString(singleQuotedString);
View Full Code Here


  @Test
  public void test_ValidateExpressionTitles_Ok() {

    { // -- literal string
      SingleQuotedString titleExpr = pf.createSingleQuotedString();
      titleExpr.setText("test");
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- name
      LiteralNameOrReference titleExpr = pf.createLiteralNameOrReference();
      titleExpr.setValue("test");
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- variable
      VariableExpression titleExpr = pf.createVariableExpression();
      titleExpr.setVarName("$test");
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- literal list
      LiteralList titleExpr = pf.createLiteralList();
      titleExpr.getElements().add(this.createNameOrReference("a"));
      titleExpr.getElements().add(this.createNameOrReference("b"));
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- hasharray access
      AtExpression titleExpr = pf.createAtExpression();
      titleExpr.setLeftExpr(createNameOrReference("Foo"));
      titleExpr.getParameters().add(createNameOrReference("a"));
      subTestValidateExpressionTitles(titleExpr);
    }
    { // -- selector
      SelectorExpression titleExpr = pf.createSelectorExpression();
      SelectorEntry entry = pf.createSelectorEntry();
      titleExpr.getParameters().add(entry);

      SingleQuotedString slhs = pf.createSingleQuotedString();
      slhs.setText("\'x\'");
      LiteralName entrylhs = pf.createLiteralName();
      entrylhs.setValue("a");

      titleExpr.setLeftExpr(slhs);
      entry.setLeftExpr(entrylhs);
View Full Code Here

  @Test
  public void test_Validate_SingleQuotedString_NotOk() {

    { // -- unescaped single quote
      SingleQuotedString ls = pf.createSingleQuotedString();
      ls.setText("I have an unprotected single quote ' in me.");
      tester.validator().checkSingleQuotedString(ls);
      tester.diagnose().assertError(IPPDiagnostics.ISSUE__NOT_STRING);
    }
    // TODO: Test DQ string
    // {
View Full Code Here

    // }
  }

  @Test
  public void test_Validate_SingleQuotedString_Ok() {
    SingleQuotedString ls = pf.createSingleQuotedString();
    ls.setText("I am a single quoted string with a tab \\t char");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    // -- control char
    ls.setText("I am a single quoted string with a tab \t");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    // -- new line
    ls.setText("I am a single quoted string with a nl \n");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    // -- TODO: test NBSP

    // Unicode escapes are not supported as specific escapes as any
    // escaped character is the character itself - \u1234 is simply u1234
    // Should not produce an error or warning for sq string

    // -- unicode escape \\u [hexdigit]{4,4}
    ls.setText("\\u1a2b");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    // -- hex escape \x[hexdigit]{2,3} is not supported
    ls.setText("\\x1a");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    // -- octal escape \[0-7]{3,3}
    ls.setText("\\777");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    // -- meta escape \M-[sourcecharexceptNL]
    ls.setText("\\M-A");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    // -- control escape \c[sourcecharexceptNL] or \C-[sourcecharexceptNL]
    ls.setText("\\C-J");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    ls.setText("\\cJ");
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    // -- escaped backslash and quotes as well as any escaped character
    ls.setText("\\\\"); // i.e. '\\'
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    ls.setText("\\'"); // i.e. '\''
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();

    ls.setText("\\p"); // i.e. '\p'
    tester.validator().checkSingleQuotedString(ls);
    tester.diagnose().assertOK();
  }
View Full Code Here

      if(!(keyValPairs[i] instanceof String))
        throw new IllegalArgumentException("Bad test spec, key not a String");
      ao.setKey((String) (keyValPairs[i++]));

      if(keyValPairs[i] instanceof String) {
        SingleQuotedString valueExpr = pf.createSingleQuotedString();
        valueExpr.setText((String) (keyValPairs[i]));
        ao.setValue(valueExpr);
      }
      else if(keyValPairs[i] instanceof Expression)
        ao.setValue((Expression) keyValPairs[i]);
      else
View Full Code Here

      rb.setAttributes(aos);
    return rb;
  }

  protected ResourceBody createResourceBody(boolean additive, String title, Object... keyValPairs) {
    SingleQuotedString titleExpr = null;
    if(title != null) {
      titleExpr = pf.createSingleQuotedString();
      titleExpr.setText(title);
    }
    return createResourceBody(additive, titleExpr, keyValPairs);
  }
View Full Code Here

    return re;
  }

  protected ResourceExpression createResourceExpression(boolean exported, boolean virtual, boolean additive,
      String type, String title, Object... keyValPairs) {
    SingleQuotedString titleExpr = null;
    if(title != null) {
      titleExpr = pf.createSingleQuotedString();
      titleExpr.setText(title);
    }
    return createResourceExpression(exported, virtual, additive, type, titleExpr, keyValPairs);
  }
View Full Code Here

  protected ResourceExpression createResourceExpression(String type, String title, Object... keyValPairs) {
    return createResourceExpression(false, type, title, keyValPairs);
  }

  protected SingleQuotedString createSqString(String text) {
    SingleQuotedString s = pf.createSingleQuotedString();
    s.setText(text);
    return s;
  }
View Full Code Here

    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);
 
View Full Code Here

TOP

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

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.