incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gordonsm...@apache.org
Subject svn commit: r1405179 - /incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLXMLNodeTests.java
Date Fri, 02 Nov 2012 22:01:16 GMT
Author: gordonsmith
Date: Fri Nov  2 22:01:16 2012
New Revision: 1405179

URL: http://svn.apache.org/viewvc?rev=1405179&view=rev
Log:
Falcon: Added three nontrivial tests for parsing <XML> tag.

Modified:
    incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLXMLNodeTests.java

Modified: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLXMLNodeTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLXMLNodeTests.java?rev=1405179&r1=1405178&r2=1405179&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLXMLNodeTests.java
(original)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLXMLNodeTests.java
Fri Nov  2 22:01:16 2012
@@ -34,6 +34,8 @@ import org.junit.Test;
  */
 public class MXMLXMLNodeTests extends MXMLInstanceNodeTests
 {
+	private static String EOL = "\n\t\t";
+	
 	private IMXMLXMLNode getMXMLXMLNode(String code)
 	{
 		IMXMLFileNode fileNode = getMXMLFileNode(code);
@@ -48,7 +50,9 @@ public class MXMLXMLNodeTests extends MX
 	{
 		String code = "<fx:XML/>";
 		IMXMLXMLNode node = getMXMLXMLNode(code);
+		assertThat("getXMLType", node.getXMLType(), is(IMXMLXMLNode.XML_TYPE.E4X));
 		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getXMLString", node.getXMLString(), is(""));
 	}
 	
 	@Test
@@ -56,7 +60,9 @@ public class MXMLXMLNodeTests extends MX
 	{
 		String code = "<fx:XML></fx:XML>";
 		IMXMLXMLNode node = getMXMLXMLNode(code);
+		assertThat("getXMLType", node.getXMLType(), is(IMXMLXMLNode.XML_TYPE.E4X));
 		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getXMLString", node.getXMLString(), is(""));
 	}
 	
 	@Test
@@ -64,6 +70,51 @@ public class MXMLXMLNodeTests extends MX
 	{
 		String code = "<fx:XML> \t\r\n</fx:XML>";
 		IMXMLXMLNode node = getMXMLXMLNode(code);
+		assertThat("getXMLType", node.getXMLType(), is(IMXMLXMLNode.XML_TYPE.E4X));
+		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getXMLString", node.getXMLString(), is(""));
+	}
+	
+	@Test
+	public void MXMLXMLNode_empty_root()
+	{
+		String code =
+			"<fx:XML>" + EOL +
+		    "    <root/>" + EOL +
+			"</fx:XML>";
+		IMXMLXMLNode node = getMXMLXMLNode(code);
+		assertThat("getXMLType", node.getXMLType(), is(IMXMLXMLNode.XML_TYPE.E4X));
+		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getXMLString", node.getXMLString(), is("<root/>"));
+	}
+	
+	@Test
+	public void MXMLXMLNode_root_with_one_child_with_text()
+	{
+		String code =
+			"<fx:XML>" + EOL +
+		    "    <root>" + EOL +
+		    "        <a>xxx</a>" + EOL +
+		    "    </root>" + EOL +
+			"</fx:XML>";
+		IMXMLXMLNode node = getMXMLXMLNode(code);
+		assertThat("getXMLType", node.getXMLType(), is(IMXMLXMLNode.XML_TYPE.E4X));
+		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getXMLString", node.getXMLString(), is("<root><a>xxx</a></root>"));
+	}
+	
+	@Test
+	public void MXMLXMLNode_root_with_one_child_with_attribute()
+	{
+		String code =
+			"<fx:XML>" + EOL +
+		    "    <root>" + EOL +
+		    "        <a b='xxx'>" + EOL +
+		    "    </root>" + EOL +
+			"</fx:XML>";
+		IMXMLXMLNode node = getMXMLXMLNode(code);
+		assertThat("getXMLType", node.getXMLType(), is(IMXMLXMLNode.XML_TYPE.E4X));
 		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getXMLString", node.getXMLString(), is("<root><a b=\"xxx\"></root>"));
// should single quote come back as double quote?
 	}
 }



Mime
View raw message