This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 09997e4703a898c30bcfaadbd78bc596403cf02e
Author: Josh Tynjala <[email protected]>
AuthorDate: Thu Sep 4 13:29:05 2025 -0700

    compiler: fx:Function tests for SWF
---
 .../test/java/mxml/tags/MXMLFunctionTagTests.java  |  47 ++++++++
 .../MXMLPropertySpecifierNodeFunctionTests.java    | 118 +++++++++++++++++++++
 .../java/properties/MXMLPropertyFunctionTests.java |  98 +++++++++++++++++
 compiler/src/test/royale/custom/TestInstance.as    |   3 +
 4 files changed, 266 insertions(+)

diff --git a/compiler/src/test/java/mxml/tags/MXMLFunctionTagTests.java 
b/compiler/src/test/java/mxml/tags/MXMLFunctionTagTests.java
new file mode 100644
index 000000000..cdbbc06b6
--- /dev/null
+++ b/compiler/src/test/java/mxml/tags/MXMLFunctionTagTests.java
@@ -0,0 +1,47 @@
+/*
+ *
+ *  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 mxml.tags;
+
+import org.junit.Test;
+
+/**
+ * Feature tests for the MXML {@code <Function>} tag.
+ */
+public class MXMLFunctionTagTests extends MXMLInstanceTagTestsBase
+{
+    @Test
+    public void MXMLFunctionTag_basic()
+    {
+        String[] declarations = new String[]
+        {
+            "<fx:Function id='f1'>myFunction</fx:Function>"
+        };
+        String[] scripts = new String[]
+        {
+            "private function myFunction():void {}",
+        };
+        String[] asserts = new String[]
+        {
+            "assertEqual('f1', f1, myFunction);",
+        };
+        String mxml = getMXML(declarations, scripts, asserts);
+        compileAndRun(mxml);
+    }
+}
diff --git 
a/compiler/src/test/java/org/apache/royale/compiler/internal/tree/mxml/MXMLPropertySpecifierNodeFunctionTests.java
 
b/compiler/src/test/java/org/apache/royale/compiler/internal/tree/mxml/MXMLPropertySpecifierNodeFunctionTests.java
new file mode 100644
index 000000000..f3ccfce6d
--- /dev/null
+++ 
b/compiler/src/test/java/org/apache/royale/compiler/internal/tree/mxml/MXMLPropertySpecifierNodeFunctionTests.java
@@ -0,0 +1,118 @@
+/*
+ *
+ *  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.royale.compiler.internal.tree.mxml;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.core.Is.is;
+
+import org.apache.royale.compiler.tree.ASTNodeID;
+import org.apache.royale.compiler.tree.mxml.IMXMLClassNode;
+import org.apache.royale.compiler.tree.mxml.IMXMLFunctionNode;
+import org.apache.royale.compiler.tree.mxml.IMXMLPropertySpecifierNode;
+import org.junit.Test;
+
+/**
+ * JUnit tests for {@link MXMLPropertyNode} for a property of type 
<code>Function</code>.
+ */
+public class MXMLPropertySpecifierNodeFunctionTests extends 
MXMLPropertySpecifierNodeTests
+{        
+       @Override
+       protected String getPropertyType()
+       {
+               return "Function";
+       }
+       
+       protected IMXMLPropertySpecifierNode 
testMXMLPropertySpecifierNode(String[] code, String functionBaseName, String 
parentQname)
+       {
+               IMXMLPropertySpecifierNode node = 
getMXMLPropertySpecifierNode(code);
+               assertThat("getInstanceNode.getNodeID", 
node.getInstanceNode().getNodeID(), is(ASTNodeID.MXMLFunctionID));
+               assertThat("getInstanceNode.getValue.getBaseName", 
((IMXMLFunctionNode)node.getInstanceNode()).getValue(project).getBaseName(), 
is(functionBaseName));
+               
assertThat("getInstanceNode.getValue.getParent.getQualifiedName", 
((IMXMLFunctionNode)node.getInstanceNode()).getValue(project).getParent().getQualifiedName(),
 is(parentQname));
+               return node;
+       }
+    
+       @Test
+       public void MXMLPropertySpecifierNode_Function_shortName_attribute()
+       {
+               String[] code = new String[]
+               {
+                   "<MyComp p=' TestInstance.anotherFunction '/>"
+               };
+               testMXMLPropertySpecifierNode(code, "anotherFunction", 
"custom.TestInstance");
+       }
+       
+       @Test
+       public void MXMLPropertySpecifierNode_Function_shortName_tag_text()
+       {
+               String[] code = new String[]
+               {
+                       "<MyComp>",
+                       "    <p> TestInstance.anotherFunction </p>",
+                       "</MyComp>"
+               };
+               testMXMLPropertySpecifierNode(code, "anotherFunction", 
"custom.TestInstance");
+       }
+       
+       @Test
+       public void MXMLPropertySpecifierNode_Function_shortName_tag_tag()
+       {
+               String[] code = new String[]
+               {
+                       "<MyComp>",
+                       "    <p><fx:Function> TestInstance.anotherFunction 
</fx:Function></p>",
+                       "</MyComp>"
+               };
+               testMXMLPropertySpecifierNode(code, "anotherFunction", 
"custom.TestInstance");
+       }
+       
+       @Test
+       public void MXMLPropertySpecifierNode_Function_qualifiedName_attribute()
+       {
+               String[] code = new String[]
+               {
+                   "<MyComp p=' custom.TestInstance.anotherFunction '/>"
+               };
+               testMXMLPropertySpecifierNode(code, "anotherFunction", 
"custom.TestInstance");
+       }
+       
+       @Test
+       public void MXMLPropertySpecifierNode_Function_qualifiedName_tag_text()
+       {
+               String[] code = new String[]
+               {
+                       "<MyComp>",
+                       "    <p> custom.TestInstance.anotherFunction </p>",
+                       "</MyComp>"
+               };
+               testMXMLPropertySpecifierNode(code, "anotherFunction", 
"custom.TestInstance");
+       }
+       
+       @Test
+       public void MXMLPropertySpecifierNode_Function_qualifiedName_tag_tag()
+       {
+               String[] code = new String[]
+               {
+                       "<MyComp>",
+                       "    <p><fx:Function> 
custom.TestInstance.anotherFunction </fx:Function></p>",
+                       "</MyComp>"
+               };
+               testMXMLPropertySpecifierNode(code, "anotherFunction", 
"custom.TestInstance");
+       }
+}
diff --git a/compiler/src/test/java/properties/MXMLPropertyFunctionTests.java 
b/compiler/src/test/java/properties/MXMLPropertyFunctionTests.java
new file mode 100644
index 000000000..ab2479fed
--- /dev/null
+++ b/compiler/src/test/java/properties/MXMLPropertyFunctionTests.java
@@ -0,0 +1,98 @@
+/*
+ *
+ *  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 properties;
+
+import org.junit.Test;
+
+/**
+ * Feature tests for MXML property tags and attributes of type {@code 
<Function>}.
+ */
+public class MXMLPropertyFunctionTests extends MXMLPropertyTestsBase
+{
+    @Override
+    protected String getPropertyType()
+    {
+        return "Function";
+    }
+    
+    @Test
+    public void MXMLPropertyFunctionTests_default()
+    {
+        String[] declarations = new String[]
+        {
+            "<MyComp id='mc1'/>"
+        };
+        String[] asserts = new String[]
+        {
+            "assertEqual('mc1.p', mc1.p, null);"   
+        };
+        String mxml = getMXML(declarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+    
+    @Test
+    public void MXMLPropertyFunctionTests_attribute()
+    {
+        String[] declarations = new String[]
+        {
+            "<MyComp id='mc1' p=' flash.net.navigateToURL '/>"
+        };
+        String[] asserts = new String[]
+        {
+            "assertEqual('mc1.p', mc1.p, flash.net.navigateToURL);"  
+        };
+        String mxml = getMXML(declarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+    
+    @Test
+    public void MXMLPropertyFunctionTests_tag_text()
+    {
+        String[] declarations = new String[]
+        {
+            "<MyComp id='mc1'>",
+            "    <p> flash.net.navigateToURL </p>",
+            "</MyComp>"
+        };
+        String[] asserts = new String[]
+        {
+            "assertEqual('mc1.p', mc1.p, flash.net.navigateToURL);"  
+        };
+        String mxml = getMXML(declarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+    
+    @Test
+    public void MXMLPropertyFunctionTests_tag_tag()
+    {
+        String[] declarations = new String[]
+        {
+            "<MyComp id='mc1'>",
+            "    <p><fx:Function> flash.net.navigateToURL </fx:Function></p>",
+            "</MyComp>"
+        };
+        String[] asserts = new String[]
+        {
+            "assertEqual('mc1.p', mc1.p, flash.net.navigateToURL);"  
+        };
+        String mxml = getMXML(declarations, asserts);
+        compileAndRun(mxml, true, false, false, null);
+    }
+}
diff --git a/compiler/src/test/royale/custom/TestInstance.as 
b/compiler/src/test/royale/custom/TestInstance.as
index 3c7c294c5..6cb48b2f0 100644
--- a/compiler/src/test/royale/custom/TestInstance.as
+++ b/compiler/src/test/royale/custom/TestInstance.as
@@ -57,5 +57,8 @@ public class TestInstance {
     
     public function someFunction():void {
     }
+
+    public static function anotherFunction():void {
+    }
 }
 }

Reply via email to