Test project for 'as' and 'is' operators in FlexJS.

Note: the HTML file needs valid references to both 'goog.base' and 
'org.apache.flex.utils.Language' for it to work. This file is included as 
reference more than a functional test.
Signed-off-by: Erik de Bruin <e...@ixsoftware.nl>


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/8b36845a
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/8b36845a
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/8b36845a

Branch: refs/heads/develop
Commit: 8b36845a6781f0e211d0a1d3e3911eb6b097eab6
Parents: 896b91b
Author: Erik de Bruin <e...@ixsoftware.nl>
Authored: Fri Nov 1 09:57:02 2013 +0100
Committer: Erik de Bruin <e...@ixsoftware.nl>
Committed: Fri Nov 1 12:32:58 2013 +0100

----------------------------------------------------------------------
 .../flexjs/projects/interfaces/Test.as          | 14 +++++
 .../flexjs/projects/interfaces/Test_result.js   | 21 +++++++
 .../flexjs/projects/interfaces/classes/A.as     | 10 ++++
 .../projects/interfaces/classes/A_result.js     | 12 ++++
 .../flexjs/projects/interfaces/classes/B.as     |  7 +++
 .../projects/interfaces/classes/B_result.js     |  8 +++
 .../flexjs/projects/interfaces/classes/C.as     |  7 +++
 .../projects/interfaces/classes/C_result.js     |  8 +++
 .../flexjs/projects/interfaces/interfaces/IA.as |  4 ++
 .../projects/interfaces/interfaces/IA_result.js | 13 +++++
 .../flexjs/projects/interfaces/interfaces/IB.as |  4 ++
 .../projects/interfaces/interfaces/IB_result.js |  7 +++
 .../flexjs/projects/interfaces/interfaces/IC.as |  4 ++
 .../projects/interfaces/interfaces/IC_result.js | 13 +++++
 .../flexjs/projects/interfaces/interfaces/ID.as |  4 ++
 .../projects/interfaces/interfaces/ID_result.js |  8 +++
 .../flexjs/projects/interfaces/interfaces/IE.as |  4 ++
 .../projects/interfaces/interfaces/IE_result.js |  8 +++
 .../flexjs/projects/interfaces/testTest.html    | 58 ++++++++++++++++++++
 19 files changed, 214 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test.as
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test.as
new file mode 100644
index 0000000..4715e4c
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test.as
@@ -0,0 +1,14 @@
+package
+{
+       import classes.A;
+       import interfaces.IA;
+       import interfaces.IE;
+
+  public class Test extends A implements IA, IE
+  {
+    public function Test()
+    {
+      super();
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js
new file mode 100644
index 0000000..40ac8e7
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/Test_result.js
@@ -0,0 +1,21 @@
+goog.provide('Test');
+
+goog.require('classes.A');
+
+goog.require('org.apache.flex.utils.Language');
+
+/**
+ * @constructor
+ * @extends {classes.A}
+ * @implements {interfaces.IA}
+ * @implements {interfaces.IE}
+ */
+Test = function() {
+       goog.base(this);
+}
+goog.inherits(Test, classes.A);
+
+/**
+ * @const
+ */
+Test.prototype.AFJS_INTERFACES = [interfaces.IA, interfaces.IE];

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A.as
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A.as
new file mode 100644
index 0000000..d610c70
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A.as
@@ -0,0 +1,10 @@
+package classes
+{
+  public class A extends C
+  {
+    public function A()
+    {
+      super();
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js
new file mode 100644
index 0000000..48c2497
--- /dev/null
+++ 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/A_result.js
@@ -0,0 +1,12 @@
+goog.provide('classes.A');
+
+goog.require('classes.C');
+
+/**
+ * @constructor
+ * @extends {classes.C}
+ */
+classes.A = function() {
+       goog.base(this);
+}
+goog.inherits(classes.A, classes.C);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B.as
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B.as
new file mode 100644
index 0000000..8f5748a
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B.as
@@ -0,0 +1,7 @@
+package classes
+{
+    public class B
+    {
+        public function B() {}
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js
new file mode 100644
index 0000000..d1fe335
--- /dev/null
+++ 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/B_result.js
@@ -0,0 +1,8 @@
+goog.provide('classes.B');
+
+
+/**
+ * @constructor
+ */
+classes.B = function() {
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C.as
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C.as
new file mode 100644
index 0000000..953c9f1
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C.as
@@ -0,0 +1,7 @@
+package classes
+{
+    public class C
+    {
+        public function C() {}
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js
new file mode 100644
index 0000000..7aa37e6
--- /dev/null
+++ 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/classes/C_result.js
@@ -0,0 +1,8 @@
+goog.provide('classes.C');
+
+
+/**
+ * @constructor
+ */
+classes.C = function() {
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA.as
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA.as
new file mode 100644
index 0000000..b288321
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA.as
@@ -0,0 +1,4 @@
+package interfaces
+{
+  public interface IA extends IC {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js
 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js
new file mode 100644
index 0000000..e052dfc
--- /dev/null
+++ 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IA_result.js
@@ -0,0 +1,13 @@
+goog.provide('interfaces.IA');
+
+/**
+ * @interface
+ * @extends {interfaces.IC}
+ */
+interfaces.IA = function() {
+};
+
+/**
+ * @const
+ */
+interfaces.IA.AFJS_INTERFACES = [interfaces.IC];

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB.as
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB.as
new file mode 100644
index 0000000..b6f8925
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB.as
@@ -0,0 +1,4 @@
+package interfaces
+{
+    public interface IB {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js
 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js
new file mode 100644
index 0000000..e50057d
--- /dev/null
+++ 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IB_result.js
@@ -0,0 +1,7 @@
+goog.provide('interfaces.IB');
+
+/**
+ * @interface
+ */
+interfaces.IB = function() {
+};

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC.as
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC.as
new file mode 100644
index 0000000..9fcdd56
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC.as
@@ -0,0 +1,4 @@
+package interfaces
+{
+  public interface IC extends ID {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js
 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js
new file mode 100644
index 0000000..5e57530
--- /dev/null
+++ 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IC_result.js
@@ -0,0 +1,13 @@
+goog.provide('interfaces.IC');
+
+/**
+ * @interface
+ * @extends {interfaces.ID}
+ */
+interfaces.IC = function() {
+};
+
+/**
+ * @const
+ */
+interfaces.IC.AFJS_INTERFACES = [interfaces.ID];

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID.as
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID.as
new file mode 100644
index 0000000..1bae05b
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID.as
@@ -0,0 +1,4 @@
+package interfaces
+{
+    public interface ID {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js
 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js
new file mode 100644
index 0000000..d25c4a4
--- /dev/null
+++ 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/ID_result.js
@@ -0,0 +1,8 @@
+goog.provide('interfaces.ID');
+
+
+/**
+ * @interface
+ */
+interfaces.ID = function() {
+};

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE.as
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE.as 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE.as
new file mode 100644
index 0000000..b40e49e
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE.as
@@ -0,0 +1,4 @@
+package interfaces
+{
+    public interface IE {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js
 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js
new file mode 100644
index 0000000..bb526de
--- /dev/null
+++ 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/interfaces/IE_result.js
@@ -0,0 +1,8 @@
+goog.provide('interfaces.IE');
+
+
+/**
+ * @interface
+ */
+interfaces.IE = function() {
+};

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8b36845a/compiler.jx.tests/test-files/flexjs/projects/interfaces/testTest.html
----------------------------------------------------------------------
diff --git 
a/compiler.jx.tests/test-files/flexjs/projects/interfaces/testTest.html 
b/compiler.jx.tests/test-files/flexjs/projects/interfaces/testTest.html
new file mode 100644
index 0000000..6031301
--- /dev/null
+++ b/compiler.jx.tests/test-files/flexjs/projects/interfaces/testTest.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+       <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+       <script type="text/javascript" 
src="./library/closure/goog/base.js"></script>
+       <script type="text/javascript" src="./classes/C_result.js"></script>
+       <script type="text/javascript" src="./classes/B_result.js"></script>
+       <script type="text/javascript" src="./classes/A_result.js"></script>
+       <script type="text/javascript" src="./interfaces/IE_result.js"></script>
+       <script type="text/javascript" src="./interfaces/ID_result.js"></script>
+       <script type="text/javascript" src="./interfaces/IC_result.js"></script>
+       <script type="text/javascript" src="./interfaces/IB_result.js"></script>
+       <script type="text/javascript" src="./interfaces/IA_result.js"></script>
+       <script type="text/javascript" 
src="./org/apache/flex/utils/Language.js"></script>
+       <script type="text/javascript" src="./Test_result.js"></script>
+       <script type="text/javascript">
+               goog.require('Test');
+       </script>
+</head>
+<body>
+       <script type="text/javascript">
+               
+               var test = new Test();
+
+               org.apache.flex.utils.Language.trace('test instanceof classes.A 
- true: ' + (test instanceof classes.A).toString());
+               org.apache.flex.utils.Language.trace('test instanceof classes.B 
- false: ' + (test instanceof classes.B).toString());
+               org.apache.flex.utils.Language.trace('test instanceof classes.C 
- true: ' + (test instanceof classes.C).toString());
+           org.apache.flex.utils.Language.trace('test instanceof interfaces.IA 
- false: ' + (test instanceof interfaces.IA).toString());
+           org.apache.flex.utils.Language.trace('test instanceof interfaces.IB 
- false: ' + (test instanceof interfaces.IB).toString());
+           org.apache.flex.utils.Language.trace('test instanceof interfaces.IC 
- false: ' + (test instanceof interfaces.IC).toString());
+           org.apache.flex.utils.Language.trace('test instanceof interfaces.ID 
- false: ' + (test instanceof interfaces.ID).toString());
+           org.apache.flex.utils.Language.trace('test instanceof interfaces.IE 
- false: ' + (test instanceof interfaces.IE).toString());
+       
+           org.apache.flex.utils.Language.trace('test is(test, classes.A) - 
true: ' + (org.apache.flex.utils.Language.is(test, classes.A)).toString());
+           org.apache.flex.utils.Language.trace('test is(test, classes.B) - 
false: ' + (org.apache.flex.utils.Language.is(test, classes.B)).toString());
+           org.apache.flex.utils.Language.trace('test is(test, classes.C) - 
true: ' + (org.apache.flex.utils.Language.is(test, classes.C)).toString());
+           org.apache.flex.utils.Language.trace('test is(test, interfaces.IA) 
- true: ' + (org.apache.flex.utils.Language.is(test, 
interfaces.IA)).toString());
+           org.apache.flex.utils.Language.trace('test is(test, interfaces.IB) 
- false: ' + (org.apache.flex.utils.Language.is(test, 
interfaces.IB)).toString());
+           org.apache.flex.utils.Language.trace('test is(test, interfaces.IC) 
- true: ' + (org.apache.flex.utils.Language.is(test, 
interfaces.IC)).toString());
+           org.apache.flex.utils.Language.trace('test is(test, interfaces.ID) 
- true: ' + (org.apache.flex.utils.Language.is(test, 
interfaces.ID)).toString());
+           org.apache.flex.utils.Language.trace('test is(test, interfaces.IE) 
- true: ' + (org.apache.flex.utils.Language.is(test, 
interfaces.IE)).toString());
+           org.apache.flex.utils.Language.trace('test is(test, function() {}) 
- false: ' + (org.apache.flex.utils.Language.is(test, function() 
{})).toString());
+       
+           org.apache.flex.utils.Language.trace('test as(test, classes.A) - 
[object Object]: ' + org.apache.flex.utils.Language.as(test, classes.A));
+           org.apache.flex.utils.Language.trace('test as(test, classes.B) - 
null: ' + org.apache.flex.utils.Language.as(test, classes.B));
+           org.apache.flex.utils.Language.trace('test as(test, classes.C) - 
[object Object]: ' + org.apache.flex.utils.Language.as(test, classes.C));
+           org.apache.flex.utils.Language.trace('test as(test, interfaces.IA) 
- [object Object]: ' + org.apache.flex.utils.Language.as(test, interfaces.IA));
+           org.apache.flex.utils.Language.trace('test as(test, interfaces.IB) 
- null: ' + org.apache.flex.utils.Language.as(test, interfaces.IB));
+           org.apache.flex.utils.Language.trace('test as(test, interfaces.IC) 
- [object Object]: ' + org.apache.flex.utils.Language.as(test, interfaces.IC));
+           org.apache.flex.utils.Language.trace('test as(test, interfaces.ID) 
- [object Object]: ' + org.apache.flex.utils.Language.as(test, interfaces.ID));
+           org.apache.flex.utils.Language.trace('test as(test, interfaces.IE) 
- [object Object]: ' + org.apache.flex.utils.Language.as(test, interfaces.IE));
+           org.apache.flex.utils.Language.trace('test as(test, function() {}) 
- null: ' + org.apache.flex.utils.Language.as(test, function() {}));
+
+       </script>
+</body>
+</html>
\ No newline at end of file

Reply via email to