flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gordonsm...@apache.org
Subject svn commit: r1432304 - in /flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml: MXMLComponentNodeTests.java MXMLDeclarationsNodeTests.java MXMLDefinitionNodeTests.java MXMLLibraryNodeTests.java
Date Fri, 11 Jan 2013 21:58:27 GMT
Author: gordonsmith
Date: Fri Jan 11 21:58:27 2013
New Revision: 1432304

URL: http://svn.apache.org/viewvc?rev=1432304&view=rev
Log:
Falcon: Added parsing unit tests for MXMLDeclarationsNode (which represents a <Declarations>
tag) and MXMLLibraryNode (which represents a <Library> tag).

Added:
    flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDeclarationsNodeTests.java
  (with props)
    flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java
  (with props)
Modified:
    flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLComponentNodeTests.java
    flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDefinitionNodeTests.java

Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLComponentNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLComponentNodeTests.java?rev=1432304&r1=1432303&r2=1432304&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLComponentNodeTests.java
(original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLComponentNodeTests.java
Fri Jan 11 21:58:27 2013
@@ -145,6 +145,5 @@ public class MXMLComponentNodeTests exte
 		assertThat("getContainedClassDefinitionNode", node.getContainedClassDefinitionNode(), is(node.getChild(0)));
 		assertThat("getContainedClassDefinition", node.getContainedClassDefinition().isInstanceOf("flash.display.Sprite",
project), is(true));
 		assertThat("getContainedClassDefinitionNode.getChildCount", node.getContainedClassDefinitionNode().getChildCount(),
is(2));
-
 	}
 }

Added: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDeclarationsNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDeclarationsNodeTests.java?rev=1432304&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDeclarationsNodeTests.java
(added)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDeclarationsNodeTests.java
Fri Jan 11 21:58:27 2013
@@ -0,0 +1,114 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.tree.mxml;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.core.Is.is;
+
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.mxml.IMXMLDeclarationsNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link MXMLDeclarationsNode}.
+ * 
+ * @author Gordon Smith
+ */
+public class MXMLDeclarationsNodeTests extends MXMLNodeBaseTests
+{	
+	private static String EOL = "\n\t";
+
+	protected String getPrefix()
+	{
+		return "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'
xmlns:s='library://ns.adobe.com/flex/spark' xmlns:mx='library://ns.adobe.com/flex/mx'>\n"
+
+		       "    ";
+	}
+			
+    protected String getPostfix()
+    {
+    	return "\n" +
+		       "</d:Sprite>";
+    }
+    
+    @Override
+    protected IMXMLFileNode getMXMLFileNode(String code)
+    {
+    	code = getPrefix() + code + getPostfix();
+    	return super.getMXMLFileNode(code);
+    }
+    
+	private IMXMLDeclarationsNode getMXMLDeclarationsNode(String code)
+	{
+		IMXMLFileNode fileNode = getMXMLFileNode(code);
+		IMXMLDeclarationsNode node = (IMXMLDeclarationsNode)findFirstDescendantOfType(fileNode,
IMXMLDeclarationsNode.class);
+		assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLDeclarationsID));
+		assertThat("getName", node.getName(), is("Declarations"));
+		return node;
+	}
+	
+	@Test
+	public void MXMLDeclarationsNode_empty1()
+	{
+		String code = "<fx:Declarations/>";
+		IMXMLDeclarationsNode node = getMXMLDeclarationsNode(code);
+		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getDeclarationInstanceNodes", node.getDeclarationInstanceNodes().length, is(0));
+	}
+	
+	@Test
+	public void MXMLDeclarationsNode_empty2()
+	{
+		String code =
+		    "<fx:Declarations>" + EOL +
+		    "</fx:Declarations>";
+		IMXMLDeclarationsNode node = getMXMLDeclarationsNode(code);
+		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getDeclarationInstanceNodes", node.getDeclarationInstanceNodes().length, is(0));
+	}
+	
+	@Test
+	public void MXMLDeclarationsNode_one()
+	{
+		String code =
+		    "<fx:Declarations>" + EOL +
+		    "    <fx:int/>" + EOL +
+		    "</fx:Declarations>";
+		IMXMLDeclarationsNode node = getMXMLDeclarationsNode(code);
+		assertThat("getChildCount", node.getChildCount(), is(1));
+		assertThat("getDeclarationInstanceNodes", node.getDeclarationInstanceNodes().length, is(1));
+		assertThat("getDeclarationInstanceNodes[0]", node.getDeclarationInstanceNodes()[0].getName(),
is("int"));
+	}
+	
+	@Test
+	public void MXMLDeclarationsNode_two()
+	{
+		String code =
+		    "<fx:Declarations className='MySprite'>" + EOL +
+		    "    <fx:int/>" + EOL +
+		    "    <fx:uint/>" + EOL +
+		    "</fx:Declarations>";
+		IMXMLDeclarationsNode node = getMXMLDeclarationsNode(code);
+		assertThat("getChildCount", node.getChildCount(), is(2));
+		assertThat("getDeclarationInstanceNodes", node.getDeclarationInstanceNodes().length, is(2));
+		assertThat("getDeclarationInstanceNodes[0]", node.getDeclarationInstanceNodes()[0].getName(),
is("int"));
+		assertThat("getDeclarationInstanceNodes[1]", node.getDeclarationInstanceNodes()[1].getName(),
is("uint"));
+	}
+}

Propchange: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDeclarationsNodeTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDefinitionNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDefinitionNodeTests.java?rev=1432304&r1=1432303&r2=1432304&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDefinitionNodeTests.java
(original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDefinitionNodeTests.java
Fri Jan 11 21:58:27 2013
@@ -67,10 +67,6 @@ public class MXMLDefinitionNodeTests ext
 		return node;
 	}
 	
-	// Note: getDefinitionName() always returns null for an IMXMLDefinitionNode.
-	// It is non-null in the case of an IFactoryNode that gets created
-	// for the value of a property of type IFactory.
-	
 	@Test
 	public void MXMLDefinitionNode_empty1()
 	{
@@ -138,6 +134,5 @@ public class MXMLDefinitionNodeTests ext
 		assertThat("getContainedClassDefinitionNode", node.getContainedClassDefinitionNode(), is(node.getChild(0)));
 		assertThat("getContainedClassDefinition", node.getContainedClassDefinition().isInstanceOf("flash.display.Sprite",
project), is(true));
 		assertThat("getContainedClassDefinitionNode.getChildCount", node.getContainedClassDefinitionNode().getChildCount(),
is(2));
-
 	}
 }

Added: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java?rev=1432304&view=auto
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java
(added)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java
Fri Jan 11 21:58:27 2013
@@ -0,0 +1,120 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.tree.mxml;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.core.Is.is;
+
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.mxml.IMXMLLibraryNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link MXMLLibraryNode}.
+ * 
+ * @author Gordon Smith
+ */
+public class MXMLLibraryNodeTests extends MXMLNodeBaseTests
+{	
+	private static String EOL = "\n\t";
+
+	protected String getPrefix()
+	{
+		return "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'
xmlns:s='library://ns.adobe.com/flex/spark' xmlns:mx='library://ns.adobe.com/flex/mx'>\n"
+
+		       "    ";
+	}
+			
+    protected String getPostfix()
+    {
+    	return "\n" +
+		       "</d:Sprite>";
+    }
+    
+    @Override
+    protected IMXMLFileNode getMXMLFileNode(String code)
+    {
+    	code = getPrefix() + code + getPostfix();
+    	return super.getMXMLFileNode(code);
+    }
+    
+	private IMXMLLibraryNode getMXMLLibraryNode(String code)
+	{
+		IMXMLFileNode fileNode = getMXMLFileNode(code);
+		IMXMLLibraryNode node = (IMXMLLibraryNode)findFirstDescendantOfType(fileNode, IMXMLLibraryNode.class);
+		assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLLibraryID));
+		assertThat("getName", node.getName(), is("Library"));
+		return node;
+	}
+	
+	@Test
+	public void MXMLLibraryNode_empty1()
+	{
+		String code = "<fx:Library/>";
+		IMXMLLibraryNode node = getMXMLLibraryNode(code);
+		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getDefinitionNodes", node.getDefinitionNodes().length, is(0));
+	}
+	
+	@Test
+	public void MXMLLibraryNode_empty2()
+	{
+		String code =
+		    "<fx:Library>" + EOL +
+		    "</fx:Library>";
+		IMXMLLibraryNode node = getMXMLLibraryNode(code);
+		assertThat("getChildCount", node.getChildCount(), is(0));
+		assertThat("getDefinitionNodes", node.getDefinitionNodes().length, is(0));
+	}
+	
+	@Test
+	public void MXMLLibraryNode_one()
+	{
+		String code =
+		    "<fx:Library>" + EOL +
+		    "    <fx:Definition name='MySprite1'>" + EOL +
+		    "        <d:Sprite/>" + EOL +
+		    "    </fx:Definition>" + EOL +
+		    "</fx:Library>";
+		IMXMLLibraryNode node = getMXMLLibraryNode(code);
+		assertThat("getChildCount", node.getChildCount(), is(1));
+		assertThat("getDefinitionNodes", node.getDefinitionNodes().length, is(1));
+		assertThat("getDefinitionNodes[0]", node.getDefinitionNodes()[0].getDefinitionName(), is("MySprite1"));
+	}
+	
+	@Test
+	public void MXMLLibraryNode_two()
+	{
+		String code =
+		    "<fx:Library className='MySprite'>" + EOL +
+		    "    <fx:Definition name='MySprite1'>" + EOL +
+		    "        <d:Sprite/>" + EOL +
+		    "    </fx:Definition>" + EOL +
+		    "    <fx:Definition name='MySprite2'>" + EOL +
+		    "        <d:Sprite/>" + EOL +
+		    "    </fx:Definition>" + EOL +
+		    "</fx:Library>";
+		IMXMLLibraryNode node = getMXMLLibraryNode(code);
+		assertThat("getChildCount", node.getChildCount(), is(2));
+		assertThat("getDeclarationInstanceNodes", node.getDefinitionNodes().length, is(2));
+		assertThat("getDefinitionNodes[0]", node.getDefinitionNodes()[0].getDefinitionName(), is("MySprite1"));
+		assertThat("getDefinitionNodes[1]", node.getDefinitionNodes()[1].getDefinitionName(), is("MySprite2"));
+	}
+}

Propchange: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message