You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by go...@apache.org on 2012/11/02 22:35:52 UTC
svn commit: r1405174 - in /incubator/flex/falcon/trunk:
compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java
compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
Author: gordonsmith
Date: Fri Nov 2 21:35:51 2012
New Revision: 1405174
URL: http://svn.apache.org/viewvc?rev=1405174&view=rev
Log:
Falcon: Added three nontrivial tests for parsing <Object> tag, and fixed an NPE that was causing two of them to fail.
Modified:
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
Modified: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java?rev=1405174&r1=1405173&r2=1405174&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java (original)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java Fri Nov 2 21:35:51 2012
@@ -25,6 +25,8 @@ import static org.junit.Assert.assertTha
import org.apache.flex.compiler.tree.ASTNodeID;
import org.apache.flex.compiler.tree.mxml.IMXMLObjectNode;
import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLStringNode;
import org.junit.Test;
/**
@@ -34,6 +36,8 @@ import org.junit.Test;
*/
public class MXMLObjectNodeTests extends MXMLInstanceNodeTests
{
+ private static String EOL = "\n\t\t";
+
private IMXMLObjectNode getMXMLObjectNode(String code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
@@ -66,4 +70,58 @@ public class MXMLObjectNodeTests extends
IMXMLObjectNode node = getMXMLObjectNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
+
+ @Test
+ public void MXMLArrayNode_two_string_properties1()
+ {
+ String code =
+ "<fx:Object>" + EOL +
+ " <fx:a>" + EOL +
+ " <fx:String>xxx</fx:String>" + EOL +
+ " </fx:a>" + EOL +
+ " <fx:b>" + EOL +
+ " <fx:String>yyy</fx:String>" + EOL +
+ " </fx:b>" + EOL +
+ "</fx:Object>";
+ IMXMLObjectNode node = getMXMLObjectNode(code);
+ assertThat("getChildCount", node.getChildCount(), is(2));
+ IMXMLPropertySpecifierNode child0 = (IMXMLPropertySpecifierNode)node.getChild(0);
+ assertThat("[0]name", child0.getName(), is("a"));
+ assertThat("[0]value", ((IMXMLStringNode)child0.getInstanceNode()).getValue(), is("xxx"));
+ IMXMLPropertySpecifierNode child1 = (IMXMLPropertySpecifierNode)node.getChild(1);
+ assertThat("[1]name", child1.getName(), is("b"));
+ assertThat("[1]value", ((IMXMLStringNode)child1.getInstanceNode()).getValue(), is("yyy"));
+ }
+
+ @Test
+ public void MXMLArrayNode_two_string_properties2()
+ {
+ String code =
+ "<fx:Object>" + EOL +
+ " <fx:a>xxx</fx:a>" + EOL +
+ " <fx:b>yyy</fx:b>" + EOL +
+ "</fx:Object>";
+ IMXMLObjectNode node = getMXMLObjectNode(code);
+ assertThat("getChildCount", node.getChildCount(), is(2));
+ IMXMLPropertySpecifierNode child0 = (IMXMLPropertySpecifierNode)node.getChild(0);
+ assertThat("[0]name", child0.getName(), is("a"));
+ assertThat("[0]value", ((IMXMLStringNode)child0.getInstanceNode()).getValue(), is("xxx"));
+ IMXMLPropertySpecifierNode child1 = (IMXMLPropertySpecifierNode)node.getChild(1);
+ assertThat("[1]name", child1.getName(), is("b"));
+ assertThat("[1]value", ((IMXMLStringNode)child1.getInstanceNode()).getValue(), is("yyy"));
+ }
+
+ @Test
+ public void MXMLArrayNode_two_string_properties3()
+ {
+ String code = "<fx:Object a='xxx' b='yyy'/>";
+ IMXMLObjectNode node = getMXMLObjectNode(code);
+ assertThat("getChildCount", node.getChildCount(), is(2));
+ IMXMLPropertySpecifierNode child0 = (IMXMLPropertySpecifierNode)node.getChild(0);
+ assertThat("[0]name", child0.getName(), is("a"));
+ assertThat("[0]value", ((IMXMLStringNode)child0.getInstanceNode()).getValue(), is("xxx"));
+ IMXMLPropertySpecifierNode child1 = (IMXMLPropertySpecifierNode)node.getChild(1);
+ assertThat("[1]name", child1.getName(), is("b"));
+ assertThat("[1]value", ((IMXMLStringNode)child1.getInstanceNode()).getValue(), is("yyy"));
+ }
}
Modified: incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java?rev=1405174&r1=1405173&r2=1405174&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java (original)
+++ incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java Fri Nov 2 21:35:51 2012
@@ -995,7 +995,7 @@ public class FlexProject extends ASProje
public Integer getNamedColor(String colorName)
{
- return namedColors.get(colorName);
+ return namedColors != null ? namedColors.get(colorName) : null;
}
public void setNamedColors(Map<String, Integer> namedColors)