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 2013/01/21 21:10:32 UTC
svn commit: r1436586 [1/2] -
/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/
Author: gordonsmith
Date: Mon Jan 21 20:10:31 2013
New Revision: 1436586
URL: http://svn.apache.org/viewvc?rev=1436586&view=rev
Log:
Falcon: The unit tests now use the same templating approach as the feature tests to build up the MXML to be parsed.
Modified:
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLBooleanNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLClassNodeTests.java
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/MXMLDeclarationsNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDefinitionNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLEventSpecifierNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLExpressionNodeBaseTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLFunctionNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLIntNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLModelNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNumberNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRegExpNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLScriptNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStateNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStringNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStyleNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLUintNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLVectorNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLWebServiceNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLXMLListNodeTests.java
flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLXMLNodeTests.java
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNodeTests.java Mon Jan 21 20:10:31 2013
@@ -37,9 +37,7 @@ import org.junit.Test;
*/
public class MXMLArrayNodeTests extends MXMLInstanceNodeTests
{
- private static String EOL = "\n\t\t";
-
- private IMXMLArrayNode getMXMLArrayNode(String code)
+ private IMXMLArrayNode getMXMLArrayNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLArrayNode node = (IMXMLArrayNode)findFirstDescendantOfType(fileNode, IMXMLArrayNode.class);
@@ -51,7 +49,10 @@ public class MXMLArrayNodeTests extends
@Test
public void MXMLArrayNode_empty1()
{
- String code = "<fx:Array/>";
+ String[] code = new String[]
+ {
+ "<fx:Array/>"
+ };
IMXMLArrayNode node = getMXMLArrayNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -59,7 +60,10 @@ public class MXMLArrayNodeTests extends
@Test
public void MXMLArrayNode_empty2()
{
- String code = "<fx:Array></fx:Array>";
+ String[] code = new String[]
+ {
+ "<fx:Array></fx:Array>"
+ };
IMXMLArrayNode node = getMXMLArrayNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -67,7 +71,10 @@ public class MXMLArrayNodeTests extends
@Test
public void MXMLArrayNode_empty3()
{
- String code = "<fx:Array> \t\r\n</fx:Array>";
+ String[] code = new String[]
+ {
+ "<fx:Array> \t\r\n</fx:Array>"
+ };
IMXMLArrayNode node = getMXMLArrayNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -75,12 +82,14 @@ public class MXMLArrayNodeTests extends
@Test
public void MXMLArrayNode_three_inhomogenous_elements()
{
- String code =
- "<fx:Array>" + EOL +
- " <fx:Boolean>true</fx:Boolean>" + EOL +
- " <fx:int>123</fx:int>" + EOL +
- " <fx:String>abc</fx:String>" + EOL +
- "</fx:Array>";
+ String[] code = new String[]
+ {
+ "<fx:Array>",
+ " <fx:Boolean>true</fx:Boolean>",
+ " <fx:int>123</fx:int>",
+ " <fx:String>abc</fx:String>",
+ "</fx:Array>"
+ };
IMXMLArrayNode node = getMXMLArrayNode(code);
assertThat("getChildCount", node.getChildCount(), is(3));
assertThat("[0]", ((IMXMLBooleanNode)node.getChild(0)).getValue(), is(true));
@@ -91,17 +100,19 @@ public class MXMLArrayNodeTests extends
@Test
public void MXMLArrayNode_nested_arrays()
{
- String code =
- "<fx:Array>" + EOL +
- " <fx:Array>" + EOL +
- " <fx:int>1</fx:int>" + EOL +
- " <fx:int>2</fx:int>" + EOL +
- " </fx:Array>" + EOL +
- " <fx:Array>" + EOL +
- " <fx:int>3</fx:int>" + EOL +
- " <fx:int>4</fx:int>" + EOL +
- " </fx:Array>" + EOL +
- "</fx:Array>";
+ String[] code = new String[]
+ {
+ "<fx:Array>",
+ " <fx:Array>",
+ " <fx:int>1</fx:int>",
+ " <fx:int>2</fx:int>",
+ " </fx:Array>",
+ " <fx:Array>",
+ " <fx:int>3</fx:int>",
+ " <fx:int>4</fx:int>",
+ " </fx:Array>",
+ "</fx:Array>"
+ };
IMXMLArrayNode node = getMXMLArrayNode(code);
assertThat("getChildCount", node.getChildCount(), is(2));
assertThat("[0].getChildCount", ((IMXMLArrayNode)node.getChild(0)).getChildCount(), is(2));
@@ -115,7 +126,10 @@ public class MXMLArrayNodeTests extends
@Test
public void MXMLArrayNode_with_databinding()
{
- String code = "<fx:Array>{a.b}</fx:Array>";
+ String[] code = new String[]
+ {
+ "<fx:Array>{a.b}</fx:Array>"
+ };
IMXMLArrayNode node = getMXMLArrayNode(code);
assertThat("databinding node", node.getChild(0).getNodeID(), is(ASTNodeID.MXMLDataBindingID));
assertThat("databinding node child count", node.getChild(0).getChildCount(), is(1));
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLBooleanNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLBooleanNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLBooleanNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLBooleanNodeTests.java Mon Jan 21 20:10:31 2013
@@ -36,7 +36,7 @@ import org.junit.Test;
*/
public class MXMLBooleanNodeTests extends MXMLExpressionNodeBaseTests
{
- private IMXMLBooleanNode getMXMLBooleanNode(String code)
+ private IMXMLBooleanNode getMXMLBooleanNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLBooleanNode node = (IMXMLBooleanNode)findFirstDescendantOfType(fileNode, IMXMLBooleanNode.class);
@@ -48,7 +48,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_empty1()
{
- String code = "<fx:Boolean/>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean/>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(false));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -57,7 +60,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_empty2()
{
- String code = "<fx:Boolean></fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean></fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(false));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -66,7 +72,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_empty3()
{
- String code = "<fx:Boolean> \t\r\n</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean> \t\r\n</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(false));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -75,7 +84,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_false()
{
- String code = "<fx:Boolean>false</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>false</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(false));
testExpressionLocation(node, 12, 17);
@@ -84,7 +96,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_true()
{
- String code = "<fx:Boolean>true</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>true</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
testExpressionLocation(node, 12, 16);
@@ -93,7 +108,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_false_caseinsensitive()
{
- String code = "<fx:Boolean>FaLsE</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>FaLsE</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(false));
testExpressionLocation(node, 12, 17);
@@ -102,7 +120,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_true_caseinsensitive()
{
- String code = "<fx:Boolean>TruE</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>TruE</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
testExpressionLocation(node, 12, 16);
@@ -111,7 +132,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_false_with_whitespace()
{
- String code = "<fx:Boolean> false </fx:Boolean>";
+ String[] code = new String []
+ {
+ "<fx:Boolean> false </fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(false));
//testExpressionLocation(node, 13, 18); // location of the MXMLLiteralNode should not include the whitespace
@@ -120,7 +144,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_true_with_whitespace()
{
- String code = "<fx:Boolean> true </fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean> true </fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
//testExpressionLocation(node, 13, 17); // location of the MXMLLiteralNode should not include the whitespace
@@ -129,7 +156,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_with_comments()
{
- String code = "<fx:Boolean>t<!-- comment -->ru<!--- comment -->e</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>t<!-- comment -->ru<!--- comment -->e</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
testExpressionLocation(node, 12, 49);
@@ -138,7 +168,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_with_entities()
{
- String code = "<fx:Boolean>true</fx:Boolean>";
+ String[] code = new String []
+ {
+ "<fx:Boolean>true</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
testExpressionLocation(node, 12, 26);
@@ -148,7 +181,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_with_cdata()
{
- String code = "<fx:Boolean>t<![CDATA[r]]>u<![CDATA[e]]></fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>t<![CDATA[r]]>u<![CDATA[e]]></fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
testExpressionLocation(node, 12, 40);
@@ -158,7 +194,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_abc()
{
- String code = "<fx:Boolean>abc</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>abc</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(false));
assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -167,7 +206,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_with_xmlns_attribute()
{
- String code = "<fx:Boolean xmlns:foo='bar'>true</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean xmlns:foo='bar'>true</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
testExpressionLocation(node, 28, 32);
@@ -176,7 +218,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_with_id_attribute()
{
- String code = "<fx:Boolean id='b1'>true</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean id='b1'>true</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
testExpressionLocation(node, 20, 24);
@@ -185,7 +230,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_with_unrecognized_attribute()
{
- String code = "<fx:Boolean foo='bar'>true</fx:Boolean>";
+ String code[] = new String[]
+ {
+ "<fx:Boolean foo='bar'>true</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
testExpressionLocation(node, 22, 26);
@@ -196,7 +244,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_with_child_tag()
{
- String code = "<fx:Boolean>true<foo/></fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>true<foo/></fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("getValue", node.getValue(), is(true));
}
@@ -204,7 +255,10 @@ public class MXMLBooleanNodeTests extend
@Test
public void MXMLBooleanNode_with_databinding()
{
- String code = "<fx:Boolean>{a.b}</fx:Boolean>";
+ String[] code = new String[]
+ {
+ "<fx:Boolean>{a.b}</fx:Boolean>"
+ };
IMXMLBooleanNode node = getMXMLBooleanNode(code);
assertThat("databinding node", node.getExpressionNode().getNodeID(), is(ASTNodeID.MXMLDataBindingID));
testExpressionLocation(node, 12, 17);
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLClassNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLClassNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLClassNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLClassNodeTests.java Mon Jan 21 20:10:31 2013
@@ -36,7 +36,7 @@ import org.junit.Test;
*/
public class MXMLClassNodeTests extends MXMLExpressionNodeBaseTests
{
- private IMXMLClassNode getMXMLClassNode(String code)
+ private IMXMLClassNode getMXMLClassNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLClassNode node = (IMXMLClassNode)findFirstDescendantOfType(fileNode, IMXMLClassNode.class);
@@ -48,7 +48,10 @@ public class MXMLClassNodeTests extends
@Test
public void MXMLClassNode_empty1()
{
- String code = "<fx:Class/>";
+ String[] code = new String[]
+ {
+ "<fx:Class/>"
+ };
IMXMLClassNode node = getMXMLClassNode(code);
assertThat("getValue", node.getValue(project), is((ITypeDefinition)null));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -57,7 +60,10 @@ public class MXMLClassNodeTests extends
@Test
public void MXMLClassNode_empty2()
{
- String code = "<fx:Class></fx:Class>";
+ String[] code = new String[]
+ {
+ "<fx:Class></fx:Class>"
+ };
IMXMLClassNode node = getMXMLClassNode(code);
assertThat("getValue", node.getValue(project), is((ITypeDefinition)null));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -66,7 +72,10 @@ public class MXMLClassNodeTests extends
@Test
public void MXMLClassNode_empty3()
{
- String code = "<fx:Class> \t\r\n</fx:Class>";
+ String[] code = new String[]
+ {
+ "<fx:Class> \t\r\n</fx:Class>"
+ };
IMXMLClassNode node = getMXMLClassNode(code);
assertThat("getValue", node.getValue(project), is((ITypeDefinition)null));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -75,7 +84,10 @@ public class MXMLClassNodeTests extends
@Test
public void MXMLClassNode_flashDisplaySprite()
{
- String code = "<fx:Class>flash.display.Sprite</fx:Class>";
+ String[] code = new String[]
+ {
+ "<fx:Class>flash.display.Sprite</fx:Class>"
+ };
IMXMLClassNode node = getMXMLClassNode(code);
assertThat("getValue", node.getValue(project).getQualifiedName(), is("flash.display.Sprite"));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -85,7 +97,10 @@ public class MXMLClassNodeTests extends
@Test
public void MXMLClassNode_with_databinding()
{
- String code = "<fx:Class>{a.b}</fx:Class>";
+ String[] code = new String[]
+ {
+ "<fx:Class>{a.b}</fx:Class>"
+ };
IMXMLClassNode node = getMXMLClassNode(code);
assertThat("databinding node", node.getExpressionNode().getNodeID(), is(ASTNodeID.MXMLDataBindingID));
testExpressionLocation(node, 10, 15);
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=1436586&r1=1436585&r2=1436586&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 Mon Jan 21 20:10:31 2013
@@ -37,9 +37,7 @@ import org.junit.Test;
*/
public class MXMLComponentNodeTests extends MXMLInstanceNodeTests
{
- private static String EOL = "\n\t\t";
-
- private IMXMLComponentNode getMXMLComponentNode(String code)
+ private IMXMLComponentNode getMXMLComponentNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLComponentNode node = (IMXMLComponentNode)findFirstDescendantOfType(fileNode, IMXMLComponentNode.class);
@@ -55,7 +53,10 @@ public class MXMLComponentNodeTests exte
@Test
public void MXMLComponentNode_empty1()
{
- String code = "<fx:Component/>";
+ String[] code = new String[]
+ {
+ "<fx:Component/>"
+ };
IMXMLComponentNode node = getMXMLComponentNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getID", node.getID(), is((String)null));
@@ -68,9 +69,11 @@ public class MXMLComponentNodeTests exte
@Test
public void MXMLComponentNode_empty2()
{
- String code =
- "<fx:Component>" + EOL +
- "</fx:Component>";
+ String[] code = new String[]
+ {
+ "<fx:Component>",
+ "</fx:Component>"
+ };
IMXMLComponentNode node = getMXMLComponentNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getID", node.getID(), is((String)null));
@@ -83,10 +86,12 @@ public class MXMLComponentNodeTests exte
@Test
public void MXMLComponentNode_Sprite()
{
- String code =
- "<fx:Component>" + EOL +
- " <d:Sprite/>" + EOL +
- "</fx:Component>";
+ String[] code = new String[]
+ {
+ "<fx:Component>",
+ " <d:Sprite/>",
+ "</fx:Component>"
+ };
IMXMLComponentNode node = getMXMLComponentNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getID", node.getID(), is((String)null));
@@ -99,10 +104,12 @@ public class MXMLComponentNodeTests exte
@Test
public void MXMLComponentNode_className_Sprite()
{
- String code =
- "<fx:Component className='MySprite'>" + EOL +
- " <d:Sprite/>" + EOL +
- "</fx:Component>";
+ String[] code = new String[]
+ {
+ "<fx:Component className='MySprite'>",
+ " <d:Sprite/>",
+ "</fx:Component>"
+ };
IMXMLComponentNode node = getMXMLComponentNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getID", node.getID(), is((String)null));
@@ -115,10 +122,12 @@ public class MXMLComponentNodeTests exte
@Test
public void MXMLComponentNode_id_Sprite()
{
- String code =
- "<fx:Component id='c1'>" + EOL +
- " <d:Sprite/>" + EOL +
- "</fx:Component>";
+ String[] code = new String[]
+ {
+ "<fx:Component id='c1'>",
+ " <d:Sprite/>",
+ "</fx:Component>"
+ };
IMXMLComponentNode node = getMXMLComponentNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getID", node.getID(), is("c1"));
@@ -131,12 +140,14 @@ public class MXMLComponentNodeTests exte
@Test
public void MXMLComponentNode_className_id_Sprite_width_height()
{
- String code =
- "<fx:Component id='c1' className='MySprite'>" + EOL +
- " <d:Sprite width='100'>" + EOL +
- " <d:height>100</d:height>" + EOL +
- " </d:Sprite>" + EOL +
- "</fx:Component>";
+ String[] code = new String[]
+ {
+ "<fx:Component id='c1' className='MySprite'>",
+ " <d:Sprite width='100'>",
+ " <d:height>100</d:height>",
+ " </d:Sprite>",
+ "</fx:Component>"
+ };
IMXMLComponentNode node = getMXMLComponentNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getID", node.getID(), is("c1"));
Modified: 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=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDeclarationsNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDeclarationsNodeTests.java Mon Jan 21 20:10:31 2013
@@ -34,28 +34,7 @@ import org.junit.Test;
*/
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)
+ private IMXMLDeclarationsNode getMXMLDeclarationsNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLDeclarationsNode node = (IMXMLDeclarationsNode)findFirstDescendantOfType(fileNode, IMXMLDeclarationsNode.class);
@@ -67,7 +46,10 @@ public class MXMLDeclarationsNodeTests e
@Test
public void MXMLDeclarationsNode_empty1()
{
- String code = "<fx:Declarations/>";
+ String[] code = new String[]
+ {
+ "<fx:Declarations/>"
+ };
IMXMLDeclarationsNode node = getMXMLDeclarationsNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getDeclarationInstanceNodes", node.getDeclarationInstanceNodes().length, is(0));
@@ -76,9 +58,11 @@ public class MXMLDeclarationsNodeTests e
@Test
public void MXMLDeclarationsNode_empty2()
{
- String code =
- "<fx:Declarations>" + EOL +
- "</fx:Declarations>";
+ String[] code = new String[]
+ {
+ "<fx:Declarations>",
+ "</fx:Declarations>"
+ };
IMXMLDeclarationsNode node = getMXMLDeclarationsNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getDeclarationInstanceNodes", node.getDeclarationInstanceNodes().length, is(0));
@@ -87,10 +71,12 @@ public class MXMLDeclarationsNodeTests e
@Test
public void MXMLDeclarationsNode_one()
{
- String code =
- "<fx:Declarations>" + EOL +
- " <fx:int/>" + EOL +
- "</fx:Declarations>";
+ String[] code = new String[]
+ {
+ "<fx:Declarations>",
+ " <fx:int/>",
+ "</fx:Declarations>"
+ };
IMXMLDeclarationsNode node = getMXMLDeclarationsNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getDeclarationInstanceNodes", node.getDeclarationInstanceNodes().length, is(1));
@@ -100,11 +86,13 @@ public class MXMLDeclarationsNodeTests e
@Test
public void MXMLDeclarationsNode_two()
{
- String code =
- "<fx:Declarations className='MySprite'>" + EOL +
- " <fx:int/>" + EOL +
- " <fx:uint/>" + EOL +
- "</fx:Declarations>";
+ String[] code = new String[]
+ {
+ "<fx:Declarations className='MySprite'>",
+ " <fx:int/>",
+ " <fx:uint/>",
+ "</fx:Declarations>"
+ };
IMXMLDeclarationsNode node = getMXMLDeclarationsNode(code);
assertThat("getChildCount", node.getChildCount(), is(2));
assertThat("getDeclarationInstanceNodes", node.getDeclarationInstanceNodes().length, is(2));
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=1436586&r1=1436585&r2=1436586&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 Mon Jan 21 20:10:31 2013
@@ -27,6 +27,7 @@ import org.apache.flex.compiler.tree.AST
import org.apache.flex.compiler.tree.mxml.IMXMLClassDefinitionNode;
import org.apache.flex.compiler.tree.mxml.IMXMLDefinitionNode;
import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.utils.StringUtils;
import org.junit.Test;
/**
@@ -36,29 +37,33 @@ import org.junit.Test;
*/
public class MXMLDefinitionNodeTests extends MXMLNodeBaseTests
{
- private static String EOL = "\n\t\t";
-
- protected String getPrefix()
+ @Override
+ protected String[] getTemplate()
{
- 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" +
- " <fx:Library>\n" +
- " ";
+ // Tests of MXMLDefinitionNodes are done by parsing <Definition> tags
+ // inside this document template.
+ return new String[]
+ {
+ "<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'>",
+ " <fx:Library>",
+ " %1",
+ " </fx:Library>",
+ "</d:Sprite>"
+ };
}
-
- protected String getPostfix()
- {
- return "\n" +
- " </fx:Library>\n" +
- "</d:Sprite>";
- }
-
- @Override
- protected IMXMLFileNode getMXMLFileNode(String code)
+
+ @Override
+ protected String getMXML(String[] code)
{
- return super.getMXMLFileNode(getPrefix() + code + getPostfix());
+ String mxml = StringUtils.join(getTemplate(), "\n");
+ mxml = mxml.replace("%1", StringUtils.join(code, "\n "));
+ return mxml;
}
-
- private IMXMLDefinitionNode getMXMLDefinitionNode(String code)
+
+ private IMXMLDefinitionNode getMXMLDefinitionNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLDefinitionNode node = (IMXMLDefinitionNode)findFirstDescendantOfType(fileNode, IMXMLDefinitionNode.class);
@@ -70,7 +75,10 @@ public class MXMLDefinitionNodeTests ext
@Test
public void MXMLDefinitionNode_empty1()
{
- String code = "<fx:Definition/>";
+ String[] code = new String[]
+ {
+ "<fx:Definition/>"
+ };
IMXMLDefinitionNode node = getMXMLDefinitionNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getName", node.getDefinitionName(), is((String)null));
@@ -81,9 +89,11 @@ public class MXMLDefinitionNodeTests ext
@Test
public void MXMLDefinitionNode_empty2()
{
- String code =
- "<fx:Definition>" + EOL +
- "</fx:Definition>";
+ String[] code = new String[]
+ {
+ "<fx:Definition>",
+ "</fx:Definition>"
+ };
IMXMLDefinitionNode node = getMXMLDefinitionNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getDefinitionName", node.getDefinitionName(), is((String)null));
@@ -94,10 +104,12 @@ public class MXMLDefinitionNodeTests ext
@Test
public void MXMLDefinitionNode_Sprite()
{
- String code =
- "<fx:Definition>" + EOL +
- " <d:Sprite/>" + EOL +
- "</fx:Definition>";
+ String[] code = new String[]
+ {
+ "<fx:Definition>",
+ " <d:Sprite/>",
+ "</fx:Definition>"
+ };
IMXMLDefinitionNode node = getMXMLDefinitionNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getDefinitionName", node.getDefinitionName(), is((String)null));
@@ -108,10 +120,12 @@ public class MXMLDefinitionNodeTests ext
@Test
public void MXMLDefinitionNode_name_Sprite()
{
- String code =
- "<fx:Definition name='MySprite'>" + EOL +
- " <d:Sprite/>" + EOL +
- "</fx:Definition>";
+ String[] code = new String[]
+ {
+ "<fx:Definition name='MySprite'>",
+ " <d:Sprite/>",
+ "</fx:Definition>"
+ };
IMXMLDefinitionNode node = getMXMLDefinitionNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getDefinitionName", node.getDefinitionName(), is("MySprite"));
@@ -122,12 +136,14 @@ public class MXMLDefinitionNodeTests ext
@Test
public void MXMLDefinitionNode_name_Sprite_width_height()
{
- String code =
- "<fx:Definition name='MySprite'>" + EOL +
- " <d:Sprite width='100'>" + EOL +
- " <d:height>100</d:height>" + EOL +
- " </d:Sprite>" + EOL +
- "</fx:Definition>";
+ String[] code = new String[]
+ {
+ "<fx:Definition name='MySprite'>",
+ " <d:Sprite width='100'>",
+ " <d:height>100</d:height>",
+ " </d:Sprite>",
+ "</fx:Definition>"
+ };
IMXMLDefinitionNode node = getMXMLDefinitionNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getDefinitionName", node.getDefinitionName(), is("MySprite"));
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLEventSpecifierNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLEventSpecifierNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLEventSpecifierNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLEventSpecifierNodeTests.java Mon Jan 21 20:10:31 2013
@@ -27,6 +27,7 @@ import org.apache.flex.compiler.tree.AST
import org.apache.flex.compiler.tree.as.IASNode;
import org.apache.flex.compiler.tree.mxml.IMXMLEventSpecifierNode;
import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.utils.StringUtils;
import org.junit.Test;
/**
@@ -36,7 +37,21 @@ import org.junit.Test;
*/
public class MXMLEventSpecifierNodeTests extends MXMLSpecifierNodeBaseTests
{
- private IMXMLEventSpecifierNode getMXMLEventSpecifierNode(String code)
+ @Override
+ protected String[] getTemplate()
+ {
+ return new String[]
+ {
+ };
+ }
+
+ @Override
+ protected String getMXML(String[] code)
+ {
+ return StringUtils.join(code, "\n");
+ }
+
+ private IMXMLEventSpecifierNode getMXMLEventSpecifierNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLEventSpecifierNode node = (IMXMLEventSpecifierNode)findFirstDescendantOfType(fileNode, IMXMLEventSpecifierNode.class);
@@ -52,7 +67,10 @@ public class MXMLEventSpecifierNodeTests
@Test
public void MXMLEventSpecifierNode_emptyEventAttribute1()
{
- String code = "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' click=''/>";
+ String[] code = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' click=''/>"
+ };
IMXMLEventSpecifierNode node = getMXMLEventSpecifierNode(code);
assertThat("getName", node.getName(), is("click"));
assertThat("getSuffix", node.getSuffix(), is(""));
@@ -64,7 +82,10 @@ public class MXMLEventSpecifierNodeTests
@Test
public void MXMLEventSpecifierNode_emptyEventAttribute2()
{
- String code = "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' click=' '/>";
+ String[] code = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' click=' '/>"
+ };
IMXMLEventSpecifierNode node = getMXMLEventSpecifierNode(code);
assertThat("getName", node.getName(), is("click"));
assertThat("getSuffix", node.getSuffix(), is(""));
@@ -76,7 +97,10 @@ public class MXMLEventSpecifierNodeTests
@Test
public void MXMLEventSpecifierNode_emptyEventAttribute3()
{
- String code = "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' click=' \t\r\n'/>";
+ String[] code = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' click=' \t\r\n'/>"
+ };
IMXMLEventSpecifierNode node = getMXMLEventSpecifierNode(code);
assertThat("getName", node.getName(), is("click"));
assertThat("getSuffix", node.getSuffix(), is(""));
@@ -88,7 +112,10 @@ public class MXMLEventSpecifierNodeTests
@Test
public void MXMLEventSpecifierNode_eventAttribute_twoFunctionCalls()
{
- String code = "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' click='trace(1); trace(2)'/>";
+ String[] code = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*' click='trace(1); trace(2)'/>"
+ };
IMXMLEventSpecifierNode node = getMXMLEventSpecifierNode(code);
assertThat("getName", node.getName(), is("click"));
assertThat("getSuffix", node.getSuffix(), is(""));
@@ -102,10 +129,12 @@ public class MXMLEventSpecifierNodeTests
@Test
public void MXMLEventSpecifierNode_emptyEventTag1()
{
- String code =
- "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>\n" +
- " <d:click/>\n" +
- "</d:Sprite>";
+ String[] code = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>",
+ " <d:click/>",
+ "</d:Sprite>"
+ };
IMXMLEventSpecifierNode node = getMXMLEventSpecifierNode(code);
assertThat("getName", node.getName(), is("click"));
assertThat("getSuffix", node.getSuffix(), is(""));
@@ -117,10 +146,12 @@ public class MXMLEventSpecifierNodeTests
@Test
public void MXMLEventSpecifierNode_emptyEventTag2()
{
- String code =
- "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>\n" +
- " <d:click></d:click>\n" +
- "</d:Sprite>";
+ String[] code = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>",
+ " <d:click></d:click>",
+ "</d:Sprite>"
+ };
IMXMLEventSpecifierNode node = getMXMLEventSpecifierNode(code);
assertThat("getName", node.getName(), is("click"));
assertThat("getSuffix", node.getSuffix(), is(""));
@@ -132,10 +163,12 @@ public class MXMLEventSpecifierNodeTests
@Test
public void MXMLEventSpecifierNode_emptyEventTag3()
{
- String code =
- "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>\n" +
- " <d:click> \t\r\n</d:click>\n" +
- "</d:Sprite>";
+ String[] code = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>",
+ " <d:click> \t\r\n</d:click>",
+ "</d:Sprite>"
+ };
IMXMLEventSpecifierNode node = getMXMLEventSpecifierNode(code);
assertThat("getName", node.getName(), is("click"));
assertThat("getSuffix", node.getSuffix(), is(""));
@@ -147,13 +180,15 @@ public class MXMLEventSpecifierNodeTests
@Test
public void MXMLEventSpecifierNode_eventTag_twoFunctionCalls()
{
- String code =
- "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>\n" +
- " <d:click>\n" +
- " trace(1);\n" +
- " trace(2);\n" +
- " </d:click>\n" +
- "</d:Sprite/>";
+ String[] code = new String[]
+ {
+ "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>",
+ " <d:click>",
+ " trace(1);",
+ " trace(2);",
+ " </d:click>",
+ "</d:Sprite/>"
+ };
IMXMLEventSpecifierNode node = getMXMLEventSpecifierNode(code);
assertThat("getName", node.getName(), is("click"));
assertThat("getSuffix", node.getSuffix(), is(""));
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLExpressionNodeBaseTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLExpressionNodeBaseTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLExpressionNodeBaseTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLExpressionNodeBaseTests.java Mon Jan 21 20:10:31 2013
@@ -37,7 +37,7 @@ public class MXMLExpressionNodeBaseTests
protected void testExpressionLocation(IMXMLExpressionNode node, int expectedStart, int expectedEnd)
{
IASNode expressionNode = node.getExpressionNode();
- int prefixLength = getPrefix().length();
+ int prefixLength = getOffset("%1");
assertThat(expressionNode.getStart(), is(prefixLength + expectedStart));
assertThat(expressionNode.getEnd(), is(prefixLength + expectedEnd));
}
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLFunctionNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLFunctionNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLFunctionNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLFunctionNodeTests.java Mon Jan 21 20:10:31 2013
@@ -37,7 +37,7 @@ import org.junit.Test;
*/
public class MXMLFunctionNodeTests extends MXMLExpressionNodeBaseTests
{
- private IMXMLFunctionNode getMXMLFunctionNode(String code)
+ private IMXMLFunctionNode getMXMLFunctionNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLFunctionNode node = (IMXMLFunctionNode)findFirstDescendantOfType(fileNode, IMXMLFunctionNode.class);
@@ -49,7 +49,10 @@ public class MXMLFunctionNodeTests exten
@Test
public void MXMLFunctionNode_empty1()
{
- String code = "<fx:Function/>";
+ String[] code = new String[]
+ {
+ "<fx:Function/>"
+ };
IMXMLFunctionNode node = getMXMLFunctionNode(code);
assertThat("getValue", node.getValue(project), is((IFunctionDefinition)null));
assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -58,7 +61,10 @@ public class MXMLFunctionNodeTests exten
@Test
public void MXMLFunctionNode_empty2()
{
- String code = "<fx:Function></fx:Function>";
+ String[] code = new String[]
+ {
+ "<fx:Function></fx:Function>"
+ };
IMXMLFunctionNode node = getMXMLFunctionNode(code);
assertThat("getValue", node.getValue(project), is((IFunctionDefinition)null));
assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -67,7 +73,10 @@ public class MXMLFunctionNodeTests exten
@Test
public void MXMLFunctionNode_empty3()
{
- String code = "<fx:Function> \t\r\n</fx:Function>";
+ String[] code = new String[]
+ {
+ "<fx:Function> \t\r\n</fx:Function>"
+ };
IMXMLFunctionNode node = getMXMLFunctionNode(code);
assertThat("getValue", node.getValue(project), is((IFunctionDefinition)null));
assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -76,7 +85,10 @@ public class MXMLFunctionNodeTests exten
@Test
public void MXMLFunctionNode_trace()
{
- String code = "<fx:Function>trace</fx:Function>";
+ String[] code = new String[]
+ {
+ "<fx:Function>trace</fx:Function>"
+ };
IMXMLFunctionNode node = getMXMLFunctionNode(code);
assertThat("getValue", node.getValue(project).getQualifiedName(), is("trace"));
testExpressionLocation(node, 13, 18);
@@ -86,7 +98,10 @@ public class MXMLFunctionNodeTests exten
@Test
public void MXMLFunctionNode_flash_utils_getQualifiedClassName()
{
- String code = "<fx:Function>flash.utils.getQualifiedClassName</fx:Function>";
+ String[] code = new String[]
+ {
+ "<fx:Function>flash.utils.getQualifiedClassName</fx:Function>"
+ };
IMXMLFunctionNode node = getMXMLFunctionNode(code);
assertThat("getValue", node.getValue(project).getQualifiedName(), is("flash.utils.getQualifiedClassName"));
testExpressionLocation(node, 13, 41);
@@ -96,7 +111,10 @@ public class MXMLFunctionNodeTests exten
@Test
public void MXMLFunctionNode_with_databinding()
{
- String code = "<fx:Function>{a.b}</fx:Function>";
+ String[] code = new String[]
+ {
+ "<fx:Function>{a.b}</fx:Function>"
+ };
IMXMLFunctionNode node = getMXMLFunctionNode(code);
assertThat("databinding node", node.getExpressionNode().getNodeID(), is(ASTNodeID.MXMLDataBindingID));
testExpressionLocation(node, 13, 18);
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java Mon Jan 21 20:10:31 2013
@@ -36,9 +36,7 @@ import org.junit.Test;
*/
public class MXMLHTTPServiceNodeTests extends MXMLInstanceNodeTests
{
- private static String EOL = "\n\t\t";
-
- private IMXMLHTTPServiceNode getMXMLHTTPServiceNode(String code)
+ private IMXMLHTTPServiceNode getMXMLHTTPServiceNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLHTTPServiceNode node = (IMXMLHTTPServiceNode)findFirstDescendantOfType(fileNode, IMXMLHTTPServiceNode.class);
@@ -50,13 +48,15 @@ public class MXMLHTTPServiceNodeTests ex
@Test
public void MXMLHTTPServiceNode_postRequest()
{
- String code =
- "<mx:HTTPService id='userRequest' url='http://whatever' method='POST'>" + EOL +
- " <mx:request xmlns=''>" + EOL +
- " <username>{username.text}</username>" + EOL +
- " <emailaddress>{emailaddress.text}</emailaddress>" + EOL +
- " </mx:request>" + EOL +
- "</mx:HTTPService>";
+ String[] code = new String[]
+ {
+ "<mx:HTTPService id='userRequest' url='http://whatever' method='POST'>",
+ " <mx:request xmlns=''>",
+ " <username>{username.text}</username>",
+ " <emailaddress>{emailaddress.text}</emailaddress>",
+ " </mx:request>",
+ "</mx:HTTPService>"
+ };
IMXMLHTTPServiceNode node = getMXMLHTTPServiceNode(code);
assertThat("getChildCount", node.getChildCount(), is(3));
IMXMLPropertySpecifierNode urlNode = (IMXMLPropertySpecifierNode)node.getChild(0);
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLInstanceNodeTests.java Mon Jan 21 20:10:31 2013
@@ -19,7 +19,7 @@
package org.apache.flex.compiler.internal.tree.mxml;
-import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.utils.StringUtils;
import org.junit.Ignore;
/**
@@ -30,23 +30,35 @@ import org.junit.Ignore;
@Ignore
public class MXMLInstanceNodeTests extends MXMLClassReferenceNodeTests
{
- protected String getPrefix()
+ @Override
+ protected String[] getTemplate()
{
- 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" +
- " <fx:Declarations>\n" +
- " ";
+ // Tests of instance nodes are done by parsing instance tags
+ // inside a <Declarations> tag, using this template.
+ return new String[]
+ {
+ "<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'>",
+ " <fx:Declarations>",
+ " %1",
+ " </fx:Declarations>",
+ "</d:Sprite>"
+ };
}
-
- protected String getPostfix()
+
+ @Override
+ protected String getMXML(String[] code)
{
- return "\n" +
- " </fx:Declarations>\n" +
- "</d:Sprite>";
- }
-
- @Override
- protected IMXMLFileNode getMXMLFileNode(String code)
- {
- return super.getMXMLFileNode(getPrefix() + code + getPostfix());
+ String mxml = StringUtils.join(getTemplate(), "\n");
+ mxml = mxml.replace("%1", StringUtils.join(code, "\n "));
+ return mxml;
}
+
+ protected int getOffset(String placeholder)
+ {
+ String templateString = StringUtils.join(getTemplate(), "\n");
+ return templateString.indexOf(placeholder);
+ }
}
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLIntNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLIntNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLIntNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLIntNodeTests.java Mon Jan 21 20:10:31 2013
@@ -36,7 +36,7 @@ import org.junit.Test;
*/
public class MXMLIntNodeTests extends MXMLExpressionNodeBaseTests
{
- private IMXMLIntNode getMXMLIntNode(String code)
+ private IMXMLIntNode getMXMLIntNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLIntNode node = (IMXMLIntNode)findFirstDescendantOfType(fileNode, IMXMLIntNode.class);
@@ -48,7 +48,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_empty1()
{
- String code = "<fx:int/>";
+ String[] code = new String[]
+ {
+ "<fx:int/>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(0));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -57,7 +60,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_empty2()
{
- String code = "<fx:int></fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int></fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(0));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -66,7 +72,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_empty3()
{
- String code = "<fx:int> \t\r\n</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int> \t\r\n</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(0));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -75,7 +84,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_zero()
{
- String code = "<fx:int>0</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>0</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(0));
testExpressionLocation(node, 8, 9);
@@ -84,7 +96,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_minusZero()
{
- String code = "<fx:int>-0</fx:int>";
+ String code[] = new String[]
+ {
+ "<fx:int>-0</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(0));
testExpressionLocation(node, 8, 10);
@@ -93,7 +108,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_one()
{
- String code = "<fx:int>1</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>1</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(1));
testExpressionLocation(node, 8, 9);
@@ -102,7 +120,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_minusOne()
{
- String code = "<fx:int>-1</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>-1</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(-1));
testExpressionLocation(node, 8, 10);
@@ -111,7 +132,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_maxInt()
{
- String code = "<fx:int>2147483647</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>2147483647</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(2147483647));
testExpressionLocation(node, 8, 18);
@@ -120,7 +144,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_minInt()
{
- String code = "<fx:int>-2147483648</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>-2147483648</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(-2147483648));
testExpressionLocation(node, 8, 19);
@@ -129,7 +156,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_hex_short_zero()
{
- String code = "<fx:int>0x0</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>0x0</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(0));
testExpressionLocation(node, 8, 11);
@@ -138,7 +168,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_hex_max()
{
- String code = "<fx:int>0x7FFFffff</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>0x7FFFffff</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(2147483647));
testExpressionLocation(node, 8, 18);
@@ -147,7 +180,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_hex_min()
{
- String code = "<fx:int>-0X80000000</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>-0X80000000</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(-2147483648));
testExpressionLocation(node, 8, 19);
@@ -156,7 +192,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_hash_short_zero()
{
- String code = "<fx:int>#0</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>#0</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(0));
testExpressionLocation(node, 8, 10);
@@ -165,7 +204,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_hash_max()
{
- String code = "<fx:int>#7FFFFFFF</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>#7FFFFFFF</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(2147483647));
testExpressionLocation(node, 8, 17);
@@ -174,7 +216,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_hash_min()
{
- String code = "<fx:int>-#80000000</fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int>-#80000000</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(-2147483648));
testExpressionLocation(node, 8, 18);
@@ -183,7 +228,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_withWhitespace()
{
- String code = "<fx:int> -123 </fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int> -123 </fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(-123));
//testExpressionLocation(node, 9, 13); // location of the MXMLLiteralNode should not include the whitespace
@@ -193,7 +241,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_nonnumeric()
{
- String code = "<fx:int> abc </fx:int>";
+ String[] code = new String[]
+ {
+ "<fx:int> abc </fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("getValue", node.getValue(), is(0));
assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -202,7 +253,10 @@ public class MXMLIntNodeTests extends MX
@Test
public void MXMLIntNode_with_databinding()
{
- String code = "<fx:int>{a.b}</fx:int>";
+ String code[] = new String[]
+ {
+ "<fx:int>{a.b}</fx:int>"
+ };
IMXMLIntNode node = getMXMLIntNode(code);
assertThat("databinding node", node.getExpressionNode().getNodeID(), is(ASTNodeID.MXMLDataBindingID));
testExpressionLocation(node, 8, 13);
Modified: 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=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLLibraryNodeTests.java Mon Jan 21 20:10:31 2013
@@ -34,28 +34,7 @@ import org.junit.Test;
*/
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)
+ private IMXMLLibraryNode getMXMLLibraryNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLLibraryNode node = (IMXMLLibraryNode)findFirstDescendantOfType(fileNode, IMXMLLibraryNode.class);
@@ -67,7 +46,10 @@ public class MXMLLibraryNodeTests extend
@Test
public void MXMLLibraryNode_empty1()
{
- String code = "<fx:Library/>";
+ String[] code = new String[]
+ {
+ "<fx:Library/>"
+ };
IMXMLLibraryNode node = getMXMLLibraryNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getDefinitionNodes", node.getDefinitionNodes().length, is(0));
@@ -76,9 +58,11 @@ public class MXMLLibraryNodeTests extend
@Test
public void MXMLLibraryNode_empty2()
{
- String code =
- "<fx:Library>" + EOL +
- "</fx:Library>";
+ String[] code = new String[]
+ {
+ "<fx:Library>",
+ "</fx:Library>"
+ };
IMXMLLibraryNode node = getMXMLLibraryNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getDefinitionNodes", node.getDefinitionNodes().length, is(0));
@@ -87,12 +71,14 @@ public class MXMLLibraryNodeTests extend
@Test
public void MXMLLibraryNode_one()
{
- String code =
- "<fx:Library>" + EOL +
- " <fx:Definition name='MySprite1'>" + EOL +
- " <d:Sprite/>" + EOL +
- " </fx:Definition>" + EOL +
- "</fx:Library>";
+ String[] code = new String[]
+ {
+ "<fx:Library>",
+ " <fx:Definition name='MySprite1'>",
+ " <d:Sprite/>",
+ " </fx:Definition>",
+ "</fx:Library>"
+ };
IMXMLLibraryNode node = getMXMLLibraryNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
assertThat("getDefinitionNodes", node.getDefinitionNodes().length, is(1));
@@ -102,15 +88,17 @@ public class MXMLLibraryNodeTests extend
@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>";
+ String[] code = new String[]
+ {
+ "<fx:Library className='MySprite'>",
+ " <fx:Definition name='MySprite1'>",
+ " <d:Sprite/>",
+ " </fx:Definition>",
+ " <fx:Definition name='MySprite2'>",
+ " <d:Sprite/>",
+ " </fx:Definition>",
+ "</fx:Library>"
+ };
IMXMLLibraryNode node = getMXMLLibraryNode(code);
assertThat("getChildCount", node.getChildCount(), is(2));
assertThat("getDeclarationInstanceNodes", node.getDefinitionNodes().length, is(2));
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java Mon Jan 21 20:10:31 2013
@@ -36,21 +36,7 @@ import org.junit.Test;
*/
public class MXMLMetadataNodeTests extends MXMLNodeBaseTests
{
- private static String PREFIX =
- "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009' xmlns:d='flash.display.*'>\n\t";
-
- private static String POSTFIX =
- "\n</d:Sprite>";
-
- private static String EOL = "\n\t";
-
- @Override
- protected IMXMLFileNode getMXMLFileNode(String code)
- {
- return super.getMXMLFileNode(PREFIX + code + POSTFIX);
- }
-
- private IMXMLMetadataNode getMXMLMetadataNode(String code)
+ private IMXMLMetadataNode getMXMLMetadataNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLMetadataNode node = (IMXMLMetadataNode)findFirstDescendantOfType(fileNode, IMXMLMetadataNode.class);
@@ -62,7 +48,10 @@ public class MXMLMetadataNodeTests exten
@Test
public void MXMLMetadataNode_empty1()
{
- String code = "<fx:Metadata/>";
+ String[] code = new String[]
+ {
+ "<fx:Metadata/>"
+ };
IMXMLMetadataNode node = getMXMLMetadataNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -70,7 +59,10 @@ public class MXMLMetadataNodeTests exten
@Test
public void MXMLMetadataNode_empty2()
{
- String code = "<fx:Metadata></fx:Metadata>";
+ String[] code = new String[]
+ {
+ "<fx:Metadata></fx:Metadata>"
+ };
IMXMLMetadataNode node = getMXMLMetadataNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -78,7 +70,10 @@ public class MXMLMetadataNodeTests exten
@Test
public void MXMLMetadataNode_empty3()
{
- String code = "<fx:Metadata/> \t\r\n<fx:Metadata/>";
+ String[] code = new String[]
+ {
+ "<fx:Metadata/> \t\r\n<fx:Metadata/>"
+ };
IMXMLMetadataNode node = getMXMLMetadataNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -86,11 +81,13 @@ public class MXMLMetadataNodeTests exten
@Test
public void MXMLMetadataNode_two_events()
{
- String code =
- "<fx:Metadata>" + EOL +
- " [Event(name='mouseDown', type='mx.events.MouseEvent')]" + EOL +
- " [Event(name='mouseUp', type='mx.events.MouseEvent')]" + EOL +
- "</fx:Metadata>";
+ String[] code = new String[]
+ {
+ "<fx:Metadata>",
+ " [Event(name='mouseDown', type='mx.events.MouseEvent')]",
+ " [Event(name='mouseUp', type='mx.events.MouseEvent')]",
+ "</fx:Metadata>"
+ };
IMXMLMetadataNode node = getMXMLMetadataNode(code);
assertThat("getChildCount", node.getChildCount(), is(2));
IMetaTagNode[] metaTagNodes = node.getMetaTagNodes();
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLModelNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLModelNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLModelNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLModelNodeTests.java Mon Jan 21 20:10:31 2013
@@ -36,9 +36,7 @@ import org.junit.Test;
*/
public class MXMLModelNodeTests extends MXMLExpressionNodeBaseTests
{
- private static String EOL = "\n\t\t";
-
- private IMXMLModelNode getMXMLModelNode(String code)
+ private IMXMLModelNode getMXMLModelNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLModelNode node = (IMXMLModelNode)findFirstDescendantOfType(fileNode, IMXMLModelNode.class);
@@ -50,7 +48,10 @@ public class MXMLModelNodeTests extends
@Test
public void MXMLModelNode_empty1()
{
- String code = "<fx:Model/>";
+ String[] code = new String[]
+ {
+ "<fx:Model/>"
+ };
IMXMLModelNode node = getMXMLModelNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getRootNode", node.getRootNode(), is((IMXMLModelRootNode)null));
@@ -59,7 +60,10 @@ public class MXMLModelNodeTests extends
@Test
public void MXMLModelNode_empty2()
{
- String code = "<fx:Model></fx:Model>";
+ String[] code = new String[]
+ {
+ "<fx:Model></fx:Model>"
+ };
IMXMLModelNode node = getMXMLModelNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getRootNode", node.getRootNode(), is((IMXMLModelRootNode)null));
@@ -68,7 +72,10 @@ public class MXMLModelNodeTests extends
@Test
public void MXMLModelNode_empty3()
{
- String code = "<fx:Model> \t\r\n</fx:Model>";
+ String[] code = new String[]
+ {
+ "<fx:Model> \t\r\n</fx:Model>"
+ };
IMXMLModelNode node = getMXMLModelNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
assertThat("getRootNode", node.getRootNode(), is((IMXMLModelRootNode)null));
@@ -77,10 +84,12 @@ public class MXMLModelNodeTests extends
@Test
public void MXMLModelNode_emptyRoot()
{
- String code =
- "<fx:Model>" + EOL +
- " <root/>" + EOL +
- "</fx:Model>";
+ String[] code = new String[]
+ {
+ "<fx:Model>",
+ " <root/>",
+ "</fx:Model>"
+ };
IMXMLModelNode node = getMXMLModelNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
IMXMLModelRootNode rootNode = node.getRootNode();
@@ -91,12 +100,14 @@ public class MXMLModelNodeTests extends
@Test
public void MXMLModelNode_oneTag()
{
- String code =
- "<fx:Model>" + EOL +
- " <root>" + EOL +
- " <a/>" + EOL +
- " </root>" + EOL +
- "</fx:Model>";
+ String[] code = new String[]
+ {
+ "<fx:Model>",
+ " <root>",
+ " <a/>",
+ " </root>",
+ "</fx:Model>"
+ };
IMXMLModelNode node = getMXMLModelNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
IMXMLModelRootNode rootNode = node.getRootNode();
@@ -108,15 +119,17 @@ public class MXMLModelNodeTests extends
@Test
public void MXMLModelNode_fourTags()
{
- String code =
- "<fx:Model>" + EOL +
- " <root>" + EOL +
- " <a/>" + EOL +
- " <b/>" + EOL +
- " <a/>" + EOL +
- " <b/>" + EOL +
- " </root>" + EOL +
- "</fx:Model>";
+ String[] code = new String[]
+ {
+ "<fx:Model>",
+ " <root>",
+ " <a/>",
+ " <b/>",
+ " <a/>",
+ " <b/>",
+ " </root>",
+ "</fx:Model>"
+ };
IMXMLModelNode node = getMXMLModelNode(code);
assertThat("getChildCount", node.getChildCount(), is(1));
IMXMLModelRootNode rootNode = node.getRootNode();
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java Mon Jan 21 20:10:31 2013
@@ -40,6 +40,7 @@ import org.apache.flex.compiler.tree.mxm
import org.apache.flex.compiler.units.ICompilationUnit;
import org.apache.flex.utils.EnvProperties;
import org.apache.flex.utils.FilenameNormalization;
+import org.apache.flex.utils.StringUtils;
import org.junit.Ignore;
/**
@@ -56,24 +57,37 @@ public class MXMLNodeBaseTests
protected FlexProject project;
- protected IASNode findFirstDescendantOfType(IASNode node, Class<? extends IASNode> nodeType)
+ protected String[] getTemplate()
{
- int n = node.getChildCount();
- for (int i = 0; i < n; i++)
+ // Tests of nodes for class-definition-level tags like <Declarations>,
+ // <Library>, <Metadata>, <Script>, and <Style> use this document template.
+ // Tests for nodes produced by tags that appear at other locations
+ // override getTemplate() and getMXML().
+ return new String[]
{
- IASNode child = node.getChild(i);
- if (nodeType.isInstance(child))
- return child;
-
- IASNode found = findFirstDescendantOfType(child, nodeType);
- if (found != null)
- return found;
- }
-
- return null;
- }
+ "<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'>",
+ " %1",
+ "</d:Sprite>"
+ };
+ };
- protected IMXMLFileNode getMXMLFileNode(String code)
+ protected String getMXML(String[] code)
+ {
+ String mxml = StringUtils.join(getTemplate(), "\n");
+ mxml = mxml.replace("%1", StringUtils.join(code, "\n "));
+ return mxml;
+ }
+
+ protected IMXMLFileNode getMXMLFileNode(String[] code)
+ {
+ String mxml = getMXML(code);
+ return getMXMLFileNode(mxml);
+ }
+
+ protected IMXMLFileNode getMXMLFileNode(String mxml)
{
assertNotNull("Environment variable FLEX_HOME is not set", env.SDK);
assertNotNull("Environment variable PLAYERGLOBAL_HOME is not set", env.FPSDK);
@@ -90,7 +104,7 @@ public class MXMLNodeBaseTests
tempMXMLFile.deleteOnExit();
BufferedWriter out = new BufferedWriter(new FileWriter(tempMXMLFile));
- out.write(code);
+ out.write(mxml);
out.close();
}
catch (IOException e1)
@@ -145,4 +159,21 @@ public class MXMLNodeBaseTests
return fileNode;
}
+
+ protected IASNode findFirstDescendantOfType(IASNode node, Class<? extends IASNode> nodeType)
+ {
+ int n = node.getChildCount();
+ for (int i = 0; i < n; i++)
+ {
+ IASNode child = node.getChild(i);
+ if (nodeType.isInstance(child))
+ return child;
+
+ IASNode found = findFirstDescendantOfType(child, nodeType);
+ if (found != null)
+ return found;
+ }
+
+ return null;
+ }
}
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNumberNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNumberNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNumberNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNumberNodeTests.java Mon Jan 21 20:10:31 2013
@@ -34,7 +34,7 @@ import org.junit.Test;
*/
public class MXMLNumberNodeTests extends MXMLExpressionNodeBaseTests
{
- private IMXMLNumberNode getMXMLNumberNode(String code)
+ private IMXMLNumberNode getMXMLNumberNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLNumberNode node = (IMXMLNumberNode)findFirstDescendantOfType(fileNode, IMXMLNumberNode.class);
@@ -46,7 +46,10 @@ public class MXMLNumberNodeTests extends
@Test
public void MXMLNumberNode_empty1()
{
- String code = "<fx:Number/>";
+ String[] code = new String[]
+ {
+ "<fx:Number/>"
+ };
IMXMLNumberNode node = getMXMLNumberNode(code);
assertThat("getValue", node.getValue(), is(Double.NaN));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -55,7 +58,10 @@ public class MXMLNumberNodeTests extends
@Test
public void MXMLNumberNode_empty2()
{
- String code = "<fx:Number></fx:Number>";
+ String[] code = new String[]
+ {
+ "<fx:Number></fx:Number>"
+ };
IMXMLNumberNode node = getMXMLNumberNode(code);
assertThat("getValue", node.getValue(), is(Double.NaN));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -64,7 +70,10 @@ public class MXMLNumberNodeTests extends
@Test
public void MXMLNumberNode_empty3()
{
- String code = "<fx:Number> \t\r\n</fx:Number>";
+ String[] code = new String[]
+ {
+ "<fx:Number> \t\r\n</fx:Number>"
+ };
IMXMLNumberNode node = getMXMLNumberNode(code);
assertThat("getValue", node.getValue(), is(Double.NaN));
//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
@@ -73,7 +82,10 @@ public class MXMLNumberNodeTests extends
@Test
public void MXMLNumberNode_with_databinding()
{
- String code = "<fx:Number>{a.b}</fx:Number>";
+ String[] code = new String[]
+ {
+ "<fx:Number>{a.b}</fx:Number>"
+ };
IMXMLNumberNode node = getMXMLNumberNode(code);
assertThat("databinding node", node.getExpressionNode().getNodeID(), is(ASTNodeID.MXMLDataBindingID));
testExpressionLocation(node, 11, 16);
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLObjectNodeTests.java Mon Jan 21 20:10:31 2013
@@ -37,9 +37,7 @@ import org.junit.Test;
*/
public class MXMLObjectNodeTests extends MXMLInstanceNodeTests
{
- private static String EOL = "\n\t\t";
-
- private IMXMLObjectNode getMXMLObjectNode(String code)
+ private IMXMLObjectNode getMXMLObjectNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLObjectNode node = (IMXMLObjectNode)findFirstDescendantOfType(fileNode, IMXMLObjectNode.class);
@@ -51,7 +49,10 @@ public class MXMLObjectNodeTests extends
@Test
public void MXMLObjectNode_empty1()
{
- String code = "<fx:Object/>";
+ String[] code = new String[]
+ {
+ "<fx:Object/>"
+ };
IMXMLObjectNode node = getMXMLObjectNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -59,7 +60,10 @@ public class MXMLObjectNodeTests extends
@Test
public void MXMLObjectNode_empty2()
{
- String code = "<fx:Object></fx:Object>";
+ String[] code = new String[]
+ {
+ "<fx:Object></fx:Object>"
+ };
IMXMLObjectNode node = getMXMLObjectNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -67,7 +71,10 @@ public class MXMLObjectNodeTests extends
@Test
public void MXMLObjectNode_empty3()
{
- String code = "<fx:Object> \t\r\n</fx:Object>";
+ String[] code = new String[]
+ {
+ "<fx:Object> \t\r\n</fx:Object>"
+ };
IMXMLObjectNode node = getMXMLObjectNode(code);
assertThat("getChildCount", node.getChildCount(), is(0));
}
@@ -75,15 +82,17 @@ public class MXMLObjectNodeTests extends
@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>";
+ String[] code = new String[]
+ {
+ "<fx:Object>",
+ " <fx:a>",
+ " <fx:String>xxx</fx:String>",
+ " </fx:a>",
+ " <fx:b>",
+ " <fx:String>yyy</fx:String>",
+ " </fx:b>",
+ "</fx:Object>"
+ };
IMXMLObjectNode node = getMXMLObjectNode(code);
assertThat("getChildCount", node.getChildCount(), is(2));
IMXMLPropertySpecifierNode child0 = (IMXMLPropertySpecifierNode)node.getChild(0);
@@ -97,11 +106,13 @@ public class MXMLObjectNodeTests extends
@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>";
+ String[] code = new String[]
+ {
+ "<fx:Object>",
+ " <fx:a>xxx</fx:a>",
+ " <fx:b>yyy</fx:b>",
+ "</fx:Object>"
+ };
IMXMLObjectNode node = getMXMLObjectNode(code);
assertThat("getChildCount", node.getChildCount(), is(2));
IMXMLPropertySpecifierNode child0 = (IMXMLPropertySpecifierNode)node.getChild(0);
@@ -115,7 +126,10 @@ public class MXMLObjectNodeTests extends
@Test
public void MXMLArrayNode_two_string_properties3()
{
- String code = "<fx:Object a='xxx' b='yyy'/>";
+ String code[] = new String[]
+ {
+ "<fx:Object a='xxx' b='yyy'/>"
+ };
IMXMLObjectNode node = getMXMLObjectNode(code);
assertThat("getChildCount", node.getChildCount(), is(2));
IMXMLPropertySpecifierNode child0 = (IMXMLPropertySpecifierNode)node.getChild(0);
@@ -130,7 +144,10 @@ public class MXMLObjectNodeTests extends
@Test
public void MXMLObjectNode_with_databinding()
{
- String code = "<fx:Object>{a.b}</fx:Object>";
+ String[] code = new String[]
+ {
+ "<fx:Object>{a.b}</fx:Object>"
+ };
IMXMLObjectNode node = getMXMLObjectNode(code);
assertThat("databinding node", node.getChild(0).getNodeID(), is(ASTNodeID.MXMLDataBindingID));
assertThat("databinding node child count", node.getChild(0).getChildCount(), is(1));
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNodeTests.java Mon Jan 21 20:10:31 2013
@@ -34,15 +34,15 @@ import org.junit.Ignore;
* @author Gordon Smith
*/
@Ignore
-public class MXMLPropertySpecifierNodeTests extends MXMLSpecifierNodeBaseTests
+public abstract class MXMLPropertySpecifierNodeTests extends MXMLSpecifierNodeBaseTests
{
- /**
- * Property-node tests set properties on a <MyComp> tag which has a property named p of some type.
- * This method combines various code snippets to make a complete one-file MXML Sprite-based application.
- */
- protected String getMXML(String propertyType, String[] code)
+ @Override
+ protected String[] getTemplate()
{
- String[] template = new String[]
+ // Property-node tests use this template, which declares a component
+ // with a property of a particular type. The tests then set the
+ // property on a <MyComp> tag inside the <Declarations> tag.
+ return new String[]
{
"<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009'",
" xmlns:d='flash.display.*'",
@@ -59,16 +59,22 @@ public class MXMLPropertySpecifierNodeTe
" </fx:Declarations>",
"</d:Sprite>"
};
- String mxml = StringUtils.join(template, "\n");
- mxml = mxml.replace("%1", propertyType);
+ }
+
+ @Override
+ protected String getMXML(String[] code)
+ {
+ String mxml = StringUtils.join(getTemplate(), "\n");
+ mxml = mxml.replace("%1", getPropertyType());
mxml = mxml.replace("%2", StringUtils.join(code, "\n "));
return mxml;
}
+
+ abstract protected String getPropertyType();
protected IMXMLPropertySpecifierNode getMXMLPropertySpecifierNode(String[] code)
{
- String propertyType = getPropertyType();
- String mxml = getMXML(propertyType, code);
+ String mxml = getMXML(code);
IMXMLFileNode fileNode = getMXMLFileNode(mxml);
IMXMLPropertySpecifierNode node = (IMXMLPropertySpecifierNode)findFirstDescendantOfType(fileNode, IMXMLPropertySpecifierNode.class);
assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLPropertySpecifierID));
@@ -77,9 +83,4 @@ public class MXMLPropertySpecifierNodeTe
assertThat("getInstanceNode", node.getInstanceNode(), is(node.getChild(0)));
return node;
}
-
- protected String getPropertyType()
- {
- return "";
- }
}
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRegExpNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRegExpNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRegExpNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRegExpNodeTests.java Mon Jan 21 20:10:31 2013
@@ -36,7 +36,7 @@ import org.junit.Test;
*/
public class MXMLRegExpNodeTests extends MXMLExpressionNodeBaseTests
{
- private IMXMLRegExpNode getMXMLRegExpNode(String code)
+ private IMXMLRegExpNode getMXMLRegExpNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLRegExpNode node = (IMXMLRegExpNode)findFirstDescendantOfType(fileNode, IMXMLRegExpNode.class);
@@ -48,7 +48,10 @@ public class MXMLRegExpNodeTests extends
@Test
public void MXMLRegExpNode_empty1()
{
- String code = "<fx:RegExp/>";
+ String[] code = new String[]
+ {
+ "<fx:RegExp/>"
+ };
IMXMLRegExpNode node = getMXMLRegExpNode(code);
assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
}
@@ -56,7 +59,10 @@ public class MXMLRegExpNodeTests extends
@Test
public void MXMLRegExpNode_empty2()
{
- String code = "<fx:RegExp></fx:RegExp>";
+ String[] code = new String[]
+ {
+ "<fx:RegExp></fx:RegExp>"
+ };
IMXMLRegExpNode node = getMXMLRegExpNode(code);
assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
}
@@ -64,7 +70,10 @@ public class MXMLRegExpNodeTests extends
@Test
public void MXMLRegExpNode_empty3()
{
- String code = "<fx:RegExp> \t\r\n</fx:RegExp>";
+ String[] code = new String[]
+ {
+ "<fx:RegExp> \t\r\n</fx:RegExp>"
+ };
IMXMLRegExpNode node = getMXMLRegExpNode(code);
assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
}
@@ -73,7 +82,10 @@ public class MXMLRegExpNodeTests extends
@Test
public void MXMLRegExpNode_with_databinding()
{
- String code = "<fx:RegExp>{a.b}</fx:RegExp>";
+ String[] code = new String[]
+ {
+ "<fx:RegExp>{a.b}</fx:RegExp>"
+ };
IMXMLRegExpNode node = getMXMLRegExpNode(code);
assertThat("databinding node", node.getExpressionNode().getNodeID(), is(ASTNodeID.MXMLDataBindingID));
testExpressionLocation(node, 11, 16);
Modified: flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java?rev=1436586&r1=1436585&r2=1436586&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java (original)
+++ flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java Mon Jan 21 20:10:31 2013
@@ -36,9 +36,7 @@ import org.junit.Test;
*/
public class MXMLRemoteObjectNodeTests extends MXMLInstanceNodeTests
{
- private static String EOL = "\n\t\t";
-
- private IMXMLRemoteObjectNode getMXMLRemoteObjectNode(String code)
+ private IMXMLRemoteObjectNode getMXMLRemoteObjectNode(String[] code)
{
IMXMLFileNode fileNode = getMXMLFileNode(code);
IMXMLRemoteObjectNode node = (IMXMLRemoteObjectNode)findFirstDescendantOfType(fileNode, IMXMLRemoteObjectNode.class);
@@ -50,14 +48,16 @@ public class MXMLRemoteObjectNodeTests e
@Test
public void MXMLRemoteObjectNode_postRequest()
{
- String code =
- "<mx:RemoteObject id='userRequest' destination='Whatever'>" + EOL +
- " <mx:method name='GetQuote'>" + EOL +
- " <mx:arguments>" + EOL +
- " <symbol>{stockSymbol.text}</symbol>" + EOL +
- " </mx:arguments>" + EOL +
- " </mx:method>" + EOL +
- "</mx:RemoteObject>";
+ String[] code = new String[]
+ {
+ "<mx:RemoteObject id='userRequest' destination='Whatever'>",
+ " <mx:method name='GetQuote'>",
+ " <mx:arguments>",
+ " <symbol>{stockSymbol.text}</symbol>",
+ " </mx:arguments>",
+ " </mx:method>",
+ "</mx:RemoteObject>"
+ };
IMXMLRemoteObjectNode node = getMXMLRemoteObjectNode(code);
assertThat("getChildCount", node.getChildCount(), is(2));
IMXMLPropertySpecifierNode destinationNode = (IMXMLPropertySpecifierNode)node.getChild(0);