Examples of XtextResource


Examples of org.eclipse.xtext.resource.XtextResource

  public void test_Serialize_DoubleQuotedString_1() throws Exception {
    String original = "before${var}/after${1+2}$$${$var}";
    String formatted = doubleQuote("before${var}/after${1 + 2}$$${$var}");
    formatted += "\n";
    String code = doubleQuote(original);
    XtextResource r = getResourceFromString(code);
    EObject result = r.getContents().get(0);
    assertTrue("Should be a PuppetManifest", result instanceof PuppetManifest);
    result = ((PuppetManifest) result).getStatements().get(0);
    assertTrue("Should be a DoubleQuotedString", result instanceof DoubleQuotedString);

    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("Serialization of interpolated string should produce same result", formatted, s);
  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

  public void test_Serialize_DoubleQuotedString_2() throws Exception {
    String original = "before${var}/after${1+2}$$${$var}";
    String code = "$a = " + doubleQuote(original);
    String formatted = "$a = " + doubleQuote("before${var}/after${1 + 2}$$${$var}");
    formatted += "\n";
    XtextResource r = getResourceFromString(code);
    EObject result = r.getContents().get(0);
    assertTrue("Should be a PuppetManifest", result instanceof PuppetManifest);

    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("Serialization of interpolated string should produce same result", formatted, s);
  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

   */
  @Test
  public void test_Serialize_DqStringInterpolation() throws Exception {
    String code = "$a = \"a${1}b\"\nclass a {\n}\n";
    String fmt = "$a = \"a${1}b\"\n\nclass a {\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    // System.out.println(NodeModelUtils.compactDump(r.getParseResult().getRootNode(), false));
    assertEquals("serialization should produce specified result", fmt, s);
  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

   */
  @Test
  public void test_Serialize_DqStringNoInterpolation() throws Exception {
    String code = "$a = \"ab\"\nclass a {\n}\n";
    String fmt = "$a = \"ab\"\n\nclass a {\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    // System.out.println(NodeModelUtils.compactDump(r.getParseResult().getRootNode(), false));

    assertEquals("serialization should produce specified result", fmt, s);
  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

  }

  @Test
  public void test_serializeSimpleDqString() throws Exception {
    String code = "$x = \"a${var}\"";
    XtextResource r = getResourceFromString(code);
    EObject result = r.getContents().get(0);
    String s = serializeFormatted(result);

    assertEquals("Serialization of interpolated string should produce same result", "$x = \"a${var}\"\n", s);

  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

   * @see PPFormatter#assignmentExpressionConfiguration(FormattingConfig c)
   */
  @Test
  public void test_Format_AssignmentExpression() throws Exception {
    String code = "$a = 1\n$b = 2\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce specified result", code, s);
  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

  }

  @Test
  public void test_Parse_MatchingExpression() throws Exception {
    String code = "$a =~ /[a-z]*/\n";
    XtextResource r = getResourceFromString(code);
    String s = serialize(r.getContents().get(0));
    assertEquals("serialization should produce same result", code, s);
  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

  }

  @Test
  public void test_ParseCallWithEndComma() throws Exception {
    String code = "$a = shellquote(1,2,3,)";
    XtextResource r = getResourceFromString(code);
    tester.validate(r.getContents().get(0)).assertOK();
  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

   */
  @Test
  public void test_Serialize_CallAndDefine() throws Exception {
    String code = "class a {\n}\n$a = include('a')\ndefine b {\n}\n";
    String fmt = "class a {\n}\n$a = include('a')\n\ndefine b {\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce specified result", fmt, s);
  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

  @Test
  public void test_Serialize_CaseExpression() throws Exception {
    String code = "case $a {present : { $x=1 $y=2 } absent,foo: {$x=2 $y=2}}";
    String fmt = "case $a {\n  present     : {\n    $x = 1\n    $y = 2\n  }\n  absent, foo : {\n    $x = 2\n    $y = 2\n  }\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce specified result", fmt, s);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.