Examples of XtextResource


Examples of org.eclipse.xtext.resource.XtextResource

  @Test
  public void test_Serialize_Definition() throws Exception {
    String code = "define a {$a=10 $b=20}";
    String fmt = "define a {\n  $a = 10\n  $b = 20\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_DoubleQuotedString_1() throws Exception {
    String original = "before${var}/after${1 + 2}$$${$var}";
    String code = doubleQuote(original) + "\n";
    XtextResource r = getResourceFromString(code);
    EObject result = r.getContents().get(0);
    assertTrue("Should be a PuppetManifest", result instanceof PuppetManifest);
    result = ((PuppetManifest) result).getStatements().get(0);

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

Examples of org.eclipse.xtext.resource.XtextResource

   */
  @Test
  public void test_Serialize_DqStringFollowedByDefine() throws Exception {
    String code = "import \"foo\"\ndefine b {\n  $a = 1\n}\n";
    String fmt = "import \"foo\"\n\ndefine b {\n  $a = 1\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_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_Serialize_HostClassDefinition() throws Exception {
    String code = "class a {$a=1 $b=2}";
    String fmt = "class a {\n  $a = 1\n  $b = 2\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_IfExpression2() throws Exception {
    String code = "if$a==1{true}else{ false }if$a==1{true}elsif$b< -3{false}else{true}";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce specified result", Sample_If, s);

  }
View Full Code Here

Examples of org.eclipse.xtext.resource.XtextResource

  @Test
  public void test_Serialize_IfExpression3() throws Exception {
    String code = "if$a==1{$x=1 $y=2}elsif $a==2 {$x=3 $y=4}else{ $x=5 $y=6 }";
    String fmt = "if $a == 1 {\n  $x = 1\n  $y = 2\n} elsif $a == 2 {\n  $x = 3\n  $y = 4\n} else {\n  $x = 5\n  $y = 6\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

   * @see #test_Serialize_ImportExpression2() - for different failing result
   */
  @Test
  public void test_Serialize_ImportExpression1() throws Exception {
    String code = "import \"a\"\nimport \"b\"\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

   * @see #test_Serialize_ImportExpression1() - for different failing result
   */
  @Test
  public void test_Serialize_ImportExpression2() throws Exception {
    String code = "import 'a'\nimport 'b'\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce specified result", code, 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.