You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2019/05/04 08:51:06 UTC
[royale-asjs] 01/03: Squashed commit of cumulative work on Language
improvements
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch improvements/Language
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 146fd8c828911a2c2f0a2d41cf633f75f29978fb
Author: greg-dove <gr...@gmail.com>
AuthorDate: Sat May 4 18:24:37 2019 +1200
Squashed commit of cumulative work on Language improvements
---
.../AceJS/src/main/config/compile-js-config.xml | 4 +
.../BasicJS/src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../ChartsJS/src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../CoreJS/src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../FlatJS/src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../HTML5JS/src/main/config/compile-js-config.xml | 4 +
.../HTMLJS/src/main/config/compile-js-config.xml | 4 +
.../IconsJS/src/main/config/compile-js-config.xml | 4 +
.../JQueryJS/src/main/config/compile-js-config.xml | 4 +
.../JewelJS/src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../MobileJS/src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../src/main/config/compile-js-config.xml | 4 +
.../TLFJS/src/main/config/compile-js-config.xml | 4 +
.../TextJS/src/main/config/compile-js-config.xml | 4 +
.../XMLJS/src/main/config/compile-js-config.xml | 4 +
frameworks/projects/Ace/pom.xml | 2 +-
frameworks/projects/Basic/pom.xml | 2 +-
frameworks/projects/Binding/pom.xml | 2 +-
frameworks/projects/Charts/pom.xml | 2 +-
frameworks/projects/Collections/pom.xml | 2 +-
frameworks/projects/Core/pom.xml | 2 +-
.../projects/Core/src/main/royale/Vector.as | 44 +-
frameworks/projects/CreateJS/pom.xml | 2 +-
frameworks/projects/DragDrop/pom.xml | 2 +-
frameworks/projects/Effects/pom.xml | 2 +-
frameworks/projects/Express/pom.xml | 2 +-
frameworks/projects/Flat/pom.xml | 2 +-
frameworks/projects/FontAwesome/pom.xml | 2 +-
frameworks/projects/Formatters/pom.xml | 2 +-
frameworks/projects/GoogleMaps/pom.xml | 2 +-
frameworks/projects/Graphics/pom.xml | 2 +-
frameworks/projects/HTML/pom.xml | 2 +-
frameworks/projects/HTML5/pom.xml | 2 +-
frameworks/projects/Icons/pom.xml | 2 +-
frameworks/projects/JQuery/pom.xml | 2 +-
frameworks/projects/Jewel/pom.xml | 2 +-
frameworks/projects/Language/pom.xml | 2 +-
.../royale/org/apache/royale/utils/Language.as | 1192 ++++++++++++++-----
frameworks/projects/MXRoyale/pom.xml | 2 +-
frameworks/projects/MaterialDesignLite/pom.xml | 2 +-
frameworks/projects/Mobile/pom.xml | 2 +-
frameworks/projects/Network/pom.xml | 2 +-
frameworks/projects/Reflection/pom.xml | 2 +-
frameworks/projects/RoyaleSite/pom.xml | 2 +-
frameworks/projects/RoyaleUnit/pom.xml | 2 +-
frameworks/projects/SparkRoyale/pom.xml | 2 +-
frameworks/projects/Storage/pom.xml | 2 +-
frameworks/projects/TLF/pom.xml | 2 +-
frameworks/projects/Text/pom.xml | 2 +-
frameworks/projects/XML/src/main/royale/XML.as | 269 ++---
frameworks/projects/pom.xml | 2 +-
manualtests/UnitTests/pom.xml | 20 +-
.../UnitTests/src/main/royale/TestClasses.as | 1 +
.../src/main/royale/flexUnitTests/CoreTester.as | 15 +-
.../royale/flexUnitTests/GithubIssuesTester.as | 16 +-
.../{ReflectionTester.as => LanguageTester.as} | 24 +-
.../src/main/royale/flexUnitTests/NetworkTester.as | 11 +-
.../royale/flexUnitTests/ObservedBugsTester.as | 8 +-
.../main/royale/flexUnitTests/ReflectionTester.as | 13 +-
.../{NetworkTester.as => XMLTester.as} | 20 +-
.../royale/flexUnitTests/core/ArrayTesterTest.as | 162 +++
.../flexUnitTests/core/BinaryDataTesterTest.as | 1206 ++++++++++----------
.../src/main/royale/flexUnitTests/core/MD5Test.as | 10 +-
.../royale/flexUnitTests/core/StrandTesterTest.as | 6 +-
.../language/LanguageTesterIntUint.as | 168 +++
.../flexUnitTests/language/LanguageTesterTestIs.as | 249 ++++
.../language/LanguageTesterTestVector.as | 1150 +++++++++++++++++++
.../support/ITestInterface.as} | 13 +-
.../support/ITestInterface2.as} | 14 +-
.../support/ITestInterface3.as | 14 +-
.../support/ITestInterface4.as} | 14 +-
.../support/TestClass1.as} | 19 +-
.../support/TestClass2.as} | 19 +-
.../support/TestClass3.as} | 11 +-
.../support/TestClass4.as} | 20 +-
.../network/AMFBinaryDataTesterTest.as | 995 ++++++++--------
.../network/support/DynamicPropertyWriter.as | 74 +-
.../network/support/DynamicTestClass.as | 28 +-
.../network/support/DynamicTestClass2.as | 28 +-
.../flexUnitTests/network/support/TestClass1.as | 26 +-
.../flexUnitTests/network/support/TestClass2.as | 33 +-
.../flexUnitTests/network/support/TestClass3.as | 63 +-
.../flexUnitTests/network/support/TestClass4.as | 24 +-
.../flexUnitTests/observedbugs/ObservedBugTests.as | 62 +-
.../reflection/ReflectionTesterTest.as | 415 +++----
.../reflection/ReflectionTesterTestAlias.as | 55 +-
.../reflection/ReflectionTesterTestDynamic.as | 320 +++---
.../reflection/ReflectionTesterTestUseCache.as | 60 +-
.../reflection/support/DynamicTestClass.as | 146 +--
.../reflection/support/DynamicTestClass2.as | 82 +-
.../reflection/support/DynamicTestClass3.as | 31 +-
.../reflection/support/ITestInterface.as | 12 +-
.../reflection/support/ITestInterface2.as | 16 +-
.../reflection/support/ITestInterface3.as | 12 +-
.../reflection/support/ITestInterface4.as | 16 +-
.../flexUnitTests/reflection/support/TestClass1.as | 153 +--
.../flexUnitTests/reflection/support/TestClass2.as | 181 +--
.../flexUnitTests/reflection/support/TestClass3.as | 39 +-
.../flexUnitTests/reflection/support/TestClass4.as | 165 +--
.../flexUnitTests/reflection/support/TestClass5.as | 132 ++-
.../flexUnitTests/xml/XMLTesterGeneralTest.as | 278 +++++
.../XMLTesterStringifyTest.as} | 75 +-
.../src/main/royale/flexunit/framework/Assert.as | 3 +-
.../main/royale/testshim/RoyaleUnitTestRunner.as | 416 ++++---
.../src/main/royale/testshim/TestResult.as | 78 +-
manualtests/UnitTests/testsview/index.html | 8 +-
124 files changed, 6005 insertions(+), 2927 deletions(-)
diff --git a/frameworks/js/projects/AceJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/AceJS/src/main/config/compile-js-config.xml
index 01a5460..1c613c7 100644
--- a/frameworks/js/projects/AceJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/AceJS/src/main/config/compile-js-config.xml
@@ -96,6 +96,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/BasicJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/BasicJS/src/main/config/compile-js-config.xml
index 328c1e5..a65cc34 100644
--- a/frameworks/js/projects/BasicJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/BasicJS/src/main/config/compile-js-config.xml
@@ -102,6 +102,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/BindingJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/BindingJS/src/main/config/compile-js-config.xml
index ae639b5..8bee64a 100644
--- a/frameworks/js/projects/BindingJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/BindingJS/src/main/config/compile-js-config.xml
@@ -89,6 +89,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/ChartsJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/ChartsJS/src/main/config/compile-js-config.xml
index 2a1286a..ab2f79d 100644
--- a/frameworks/js/projects/ChartsJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/ChartsJS/src/main/config/compile-js-config.xml
@@ -94,6 +94,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/CollectionsJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/CollectionsJS/src/main/config/compile-js-config.xml
index cdd072e..4792e2b 100644
--- a/frameworks/js/projects/CollectionsJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/CollectionsJS/src/main/config/compile-js-config.xml
@@ -87,5 +87,9 @@
<js-default-initializers>false</js-default-initializers>
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
+
</royale-config>
diff --git a/frameworks/js/projects/CoreJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/CoreJS/src/main/config/compile-js-config.xml
index bdc495e..fb39ccb 100644
--- a/frameworks/js/projects/CoreJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/CoreJS/src/main/config/compile-js-config.xml
@@ -91,6 +91,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/CreateJSJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/CreateJSJS/src/main/config/compile-js-config.xml
index 3d24375..c613ba8 100644
--- a/frameworks/js/projects/CreateJSJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/CreateJSJS/src/main/config/compile-js-config.xml
@@ -95,6 +95,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/DragDropJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/DragDropJS/src/main/config/compile-js-config.xml
index d51cc16..c87342e 100644
--- a/frameworks/js/projects/DragDropJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/DragDropJS/src/main/config/compile-js-config.xml
@@ -90,6 +90,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/EffectsJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/EffectsJS/src/main/config/compile-js-config.xml
index ba94edf..fcce0f2 100644
--- a/frameworks/js/projects/EffectsJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/EffectsJS/src/main/config/compile-js-config.xml
@@ -90,6 +90,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/ExpressJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/ExpressJS/src/main/config/compile-js-config.xml
index 66caac0..c813fae 100644
--- a/frameworks/js/projects/ExpressJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/ExpressJS/src/main/config/compile-js-config.xml
@@ -99,6 +99,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/FlatJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/FlatJS/src/main/config/compile-js-config.xml
index a49a245..a7c72b8 100644
--- a/frameworks/js/projects/FlatJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/FlatJS/src/main/config/compile-js-config.xml
@@ -92,6 +92,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/FontAwesomeJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/FontAwesomeJS/src/main/config/compile-js-config.xml
index 762c916..1048f85 100644
--- a/frameworks/js/projects/FontAwesomeJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/FontAwesomeJS/src/main/config/compile-js-config.xml
@@ -92,6 +92,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/FormattersJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/FormattersJS/src/main/config/compile-js-config.xml
index a3d8289..de62888 100644
--- a/frameworks/js/projects/FormattersJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/FormattersJS/src/main/config/compile-js-config.xml
@@ -90,6 +90,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/GoogleMapsJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/GoogleMapsJS/src/main/config/compile-js-config.xml
index 6164ca4..7f756a6 100644
--- a/frameworks/js/projects/GoogleMapsJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/GoogleMapsJS/src/main/config/compile-js-config.xml
@@ -97,6 +97,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/GraphicsJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/GraphicsJS/src/main/config/compile-js-config.xml
index 298c16d..4002495 100644
--- a/frameworks/js/projects/GraphicsJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/GraphicsJS/src/main/config/compile-js-config.xml
@@ -99,6 +99,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/HTML5JS/src/main/config/compile-js-config.xml b/frameworks/js/projects/HTML5JS/src/main/config/compile-js-config.xml
index f0e5e37..f13a804 100644
--- a/frameworks/js/projects/HTML5JS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/HTML5JS/src/main/config/compile-js-config.xml
@@ -92,6 +92,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/HTMLJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/HTMLJS/src/main/config/compile-js-config.xml
index bc2981f..968a403 100644
--- a/frameworks/js/projects/HTMLJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/HTMLJS/src/main/config/compile-js-config.xml
@@ -103,6 +103,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/IconsJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/IconsJS/src/main/config/compile-js-config.xml
index 8d47e0f..cd79d6d 100644
--- a/frameworks/js/projects/IconsJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/IconsJS/src/main/config/compile-js-config.xml
@@ -93,6 +93,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/JQueryJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/JQueryJS/src/main/config/compile-js-config.xml
index 0631a82..4111731 100644
--- a/frameworks/js/projects/JQueryJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/JQueryJS/src/main/config/compile-js-config.xml
@@ -98,6 +98,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/JewelJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/JewelJS/src/main/config/compile-js-config.xml
index 56f584b..96d7109 100644
--- a/frameworks/js/projects/JewelJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/JewelJS/src/main/config/compile-js-config.xml
@@ -100,6 +100,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/LanguageJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/LanguageJS/src/main/config/compile-js-config.xml
index dd01e07..c0010f2 100644
--- a/frameworks/js/projects/LanguageJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/LanguageJS/src/main/config/compile-js-config.xml
@@ -80,6 +80,10 @@
</include-classes>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/MXRoyaleJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/MXRoyaleJS/src/main/config/compile-js-config.xml
index 4545499..b8ec141 100644
--- a/frameworks/js/projects/MXRoyaleJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/MXRoyaleJS/src/main/config/compile-js-config.xml
@@ -112,6 +112,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/MaterialDesignLiteJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/MaterialDesignLiteJS/src/main/config/compile-js-config.xml
index f60dcb0..1ab0e91 100644
--- a/frameworks/js/projects/MaterialDesignLiteJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/MaterialDesignLiteJS/src/main/config/compile-js-config.xml
@@ -79,4 +79,8 @@
<uri>library://ns.apache.org/royale/mdl</uri>
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/MobileJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/MobileJS/src/main/config/compile-js-config.xml
index 3b6cc29..9707978 100644
--- a/frameworks/js/projects/MobileJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/MobileJS/src/main/config/compile-js-config.xml
@@ -106,6 +106,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/NetworkJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/NetworkJS/src/main/config/compile-js-config.xml
index b274f50..f358ae4 100644
--- a/frameworks/js/projects/NetworkJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/NetworkJS/src/main/config/compile-js-config.xml
@@ -95,6 +95,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/ReflectionJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/ReflectionJS/src/main/config/compile-js-config.xml
index 2087d41..66ef3f9 100644
--- a/frameworks/js/projects/ReflectionJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/ReflectionJS/src/main/config/compile-js-config.xml
@@ -92,6 +92,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/RoyaleSiteJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/RoyaleSiteJS/src/main/config/compile-js-config.xml
index 41a1e16..15d45cb 100644
--- a/frameworks/js/projects/RoyaleSiteJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/RoyaleSiteJS/src/main/config/compile-js-config.xml
@@ -93,6 +93,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/RoyaleUnitJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/RoyaleUnitJS/src/main/config/compile-js-config.xml
index e42a5af..1475dca 100644
--- a/frameworks/js/projects/RoyaleUnitJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/RoyaleUnitJS/src/main/config/compile-js-config.xml
@@ -86,4 +86,8 @@
</include-classes>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/SparkRoyaleJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/SparkRoyaleJS/src/main/config/compile-js-config.xml
index 664783a..32ae345 100644
--- a/frameworks/js/projects/SparkRoyaleJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/SparkRoyaleJS/src/main/config/compile-js-config.xml
@@ -111,6 +111,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/StorageJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/StorageJS/src/main/config/compile-js-config.xml
index 527fd7a..23683ad 100644
--- a/frameworks/js/projects/StorageJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/StorageJS/src/main/config/compile-js-config.xml
@@ -98,6 +98,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/TLFJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/TLFJS/src/main/config/compile-js-config.xml
index 88e3959..d6004ad 100644
--- a/frameworks/js/projects/TLFJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/TLFJS/src/main/config/compile-js-config.xml
@@ -105,6 +105,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/TextJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/TextJS/src/main/config/compile-js-config.xml
index d3392e9..c1bb580 100644
--- a/frameworks/js/projects/TextJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/TextJS/src/main/config/compile-js-config.xml
@@ -99,6 +99,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/js/projects/XMLJS/src/main/config/compile-js-config.xml b/frameworks/js/projects/XMLJS/src/main/config/compile-js-config.xml
index d2e3429..43f7b3d 100644
--- a/frameworks/js/projects/XMLJS/src/main/config/compile-js-config.xml
+++ b/frameworks/js/projects/XMLJS/src/main/config/compile-js-config.xml
@@ -92,6 +92,10 @@
</include-namespaces>
<js-default-initializers>false</js-default-initializers>
+
+ <js-no-complex-implicit-coercions>true</js-no-complex-implicit-coercions>
+ <js-no-resolve-uncertain>true</js-no-resolve-uncertain>
+ <js-no-vector-index-checks>true</js-no-vector-index-checks>
</royale-config>
diff --git a/frameworks/projects/Ace/pom.xml b/frameworks/projects/Ace/pom.xml
index 6591532..91adf5a 100644
--- a/frameworks/projects/Ace/pom.xml
+++ b/frameworks/projects/Ace/pom.xml
@@ -58,7 +58,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Basic/pom.xml b/frameworks/projects/Basic/pom.xml
index d366c0c..f44d62c 100644
--- a/frameworks/projects/Basic/pom.xml
+++ b/frameworks/projects/Basic/pom.xml
@@ -68,7 +68,7 @@
<allowSubclassOverrides>true</allowSubclassOverrides>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true;-compiler.fxg-base-class=flash.display.Sprite</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true;-compiler.fxg-base-class=flash.display.Sprite</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Binding/pom.xml b/frameworks/projects/Binding/pom.xml
index 3458ef7..01a8c8d 100644
--- a/frameworks/projects/Binding/pom.xml
+++ b/frameworks/projects/Binding/pom.xml
@@ -50,7 +50,7 @@
<includeSources>true</includeSources>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Charts/pom.xml b/frameworks/projects/Charts/pom.xml
index e12c88e..c4f7d9e 100644
--- a/frameworks/projects/Charts/pom.xml
+++ b/frameworks/projects/Charts/pom.xml
@@ -58,7 +58,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Collections/pom.xml b/frameworks/projects/Collections/pom.xml
index 4a9c0cc..1fa03f0 100644
--- a/frameworks/projects/Collections/pom.xml
+++ b/frameworks/projects/Collections/pom.xml
@@ -52,7 +52,7 @@
</includeClasses>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Core/pom.xml b/frameworks/projects/Core/pom.xml
index 44d3302..dc3dae3 100644
--- a/frameworks/projects/Core/pom.xml
+++ b/frameworks/projects/Core/pom.xml
@@ -53,7 +53,7 @@
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
<allowSubclassOverrides>true</allowSubclassOverrides>
- <additionalCompilerOptions>-allow-abstract-classes;-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-allow-abstract-classes;-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
<!-- As a test, add asdoc generation to the compile step -->
<executions>
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass3.as b/frameworks/projects/Core/src/main/royale/Vector.as
similarity index 67%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass3.as
copy to frameworks/projects/Core/src/main/royale/Vector.as
index 8244aa5..8e307c7 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass3.as
+++ b/frameworks/projects/Core/src/main/royale/Vector.as
@@ -16,24 +16,40 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests.reflection.support
-{
-
-
-
- public class TestClass3 extends TestClass1 implements ITestInterface2, ITestInterface3
- {
+package {
+ public class Vector extends Array{
- public var something:String;
+ private static var _staticInit:Boolean;
-
- public function someMethod2(compulsoryArg:int, optArg:String=null):TestClass1
- {
- return null;
+ private static function _init():void{
+
+ var proto:Object = {
+
+ }
+
+ Vector['prototype'] = Array['protoype'];
+ _staticInit = true;
}
- public function get someValue2():Boolean {
- return false;
+ public function Vector(initialValues:Array, type:String, fixed:Boolean) {
+ if (!_staticInit) _init();
}
+
+ }
+
+
+ /*class Vector$Int extends Vector {
+
+
+ }
+
+ class Vector$Uint extends Vector {
+
+
}
+
+ class Vector$Number extends Vector {
+
+
+ }*/
}
diff --git a/frameworks/projects/CreateJS/pom.xml b/frameworks/projects/CreateJS/pom.xml
index 9ba653d..38897d0 100644
--- a/frameworks/projects/CreateJS/pom.xml
+++ b/frameworks/projects/CreateJS/pom.xml
@@ -58,7 +58,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/DragDrop/pom.xml b/frameworks/projects/DragDrop/pom.xml
index ba2c12e..2d77d33 100644
--- a/frameworks/projects/DragDrop/pom.xml
+++ b/frameworks/projects/DragDrop/pom.xml
@@ -52,7 +52,7 @@
</includeClasses>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Effects/pom.xml b/frameworks/projects/Effects/pom.xml
index 0967b0f..4e12f0f 100644
--- a/frameworks/projects/Effects/pom.xml
+++ b/frameworks/projects/Effects/pom.xml
@@ -52,7 +52,7 @@
</includeClasses>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Express/pom.xml b/frameworks/projects/Express/pom.xml
index e5d0bc1..e11c7d6 100644
--- a/frameworks/projects/Express/pom.xml
+++ b/frameworks/projects/Express/pom.xml
@@ -63,7 +63,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true;-include-lookup-only</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true;-include-lookup-only</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Flat/pom.xml b/frameworks/projects/Flat/pom.xml
index 0f8b8de..1d6bbad 100644
--- a/frameworks/projects/Flat/pom.xml
+++ b/frameworks/projects/Flat/pom.xml
@@ -64,7 +64,7 @@
<includeLookupOnly>true</includeLookupOnly>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/FontAwesome/pom.xml b/frameworks/projects/FontAwesome/pom.xml
index 342ca7b..680b1a6 100644
--- a/frameworks/projects/FontAwesome/pom.xml
+++ b/frameworks/projects/FontAwesome/pom.xml
@@ -64,7 +64,7 @@
<includeLookupOnly>true</includeLookupOnly>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Formatters/pom.xml b/frameworks/projects/Formatters/pom.xml
index 9f443ac..492fc97 100644
--- a/frameworks/projects/Formatters/pom.xml
+++ b/frameworks/projects/Formatters/pom.xml
@@ -52,7 +52,7 @@
</includeClasses>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/GoogleMaps/pom.xml b/frameworks/projects/GoogleMaps/pom.xml
index c35421a..2538813 100644
--- a/frameworks/projects/GoogleMaps/pom.xml
+++ b/frameworks/projects/GoogleMaps/pom.xml
@@ -59,7 +59,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Graphics/pom.xml b/frameworks/projects/Graphics/pom.xml
index acdd0f2..bf9a001 100644
--- a/frameworks/projects/Graphics/pom.xml
+++ b/frameworks/projects/Graphics/pom.xml
@@ -111,7 +111,7 @@
</includeClasses>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true;-compiler.byte-array-embed-class=org.apache.royale.core.ByteArrayAsset</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true;-compiler.byte-array-embed-class=org.apache.royale.core.ByteArrayAsset</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/HTML/pom.xml b/frameworks/projects/HTML/pom.xml
index a8b540b..3e7c318 100644
--- a/frameworks/projects/HTML/pom.xml
+++ b/frameworks/projects/HTML/pom.xml
@@ -62,7 +62,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true;-js-output-optimization=skipAsCoercions</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true;-js-output-optimization=skipAsCoercions</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/HTML5/pom.xml b/frameworks/projects/HTML5/pom.xml
index 645ed81..70f6d4d 100644
--- a/frameworks/projects/HTML5/pom.xml
+++ b/frameworks/projects/HTML5/pom.xml
@@ -58,7 +58,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Icons/pom.xml b/frameworks/projects/Icons/pom.xml
index 2926f9e..101a6da 100644
--- a/frameworks/projects/Icons/pom.xml
+++ b/frameworks/projects/Icons/pom.xml
@@ -66,7 +66,7 @@
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
<!--<additionalCompilerOptions>-compiler.fxg-base-class=flash.display.Sprite</additionalCompilerOptions>-->
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
diff --git a/frameworks/projects/JQuery/pom.xml b/frameworks/projects/JQuery/pom.xml
index b03fa6f..8218504 100644
--- a/frameworks/projects/JQuery/pom.xml
+++ b/frameworks/projects/JQuery/pom.xml
@@ -58,7 +58,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Jewel/pom.xml b/frameworks/projects/Jewel/pom.xml
index 6cf4a3e..2126dbf 100644
--- a/frameworks/projects/Jewel/pom.xml
+++ b/frameworks/projects/Jewel/pom.xml
@@ -65,7 +65,7 @@
<!--<allowSubclassOverrides>true</allowSubclassOverrides>-->
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
<plugin>
diff --git a/frameworks/projects/Language/pom.xml b/frameworks/projects/Language/pom.xml
index b39a33d..f040805 100644
--- a/frameworks/projects/Language/pom.xml
+++ b/frameworks/projects/Language/pom.xml
@@ -46,7 +46,7 @@
</includeClasses>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true;-warn-instance-of-changes=false</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as b/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
index 5800347..8f2298b 100644
--- a/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
+++ b/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
@@ -19,14 +19,18 @@
package org.apache.royale.utils
{
- [ExcludeClass]
- COMPILE::SWF
- public class Language {}
-
+
+ [ExcludeClass]
+ COMPILE::SWF
+ public class Language
+ {
+ }
+
COMPILE::JS
{
import goog.bind;
import goog.global;
+ import goog.DEBUG;
}
/**
@@ -34,164 +38,172 @@ package org.apache.royale.utils
* @royaleignoreimport goog.global
*/
COMPILE::JS
- public class Language
- {
-
- //--------------------------------------
- // Static Property
- //--------------------------------------
-
-
- /**
- * Helper var for sortOn
- */
- static private var sortNames:Array;
- static private var sortNamesOne:Array = [];
- static private var muler:Number;
- static private var zeroStr:String = String.fromCharCode(0);
-
- //--------------------------------------
- // Static Function
- //--------------------------------------
-
- /**
- * as()
- *
- * @param leftOperand The lefthand operand of the
- * binary as operator in AS3.
- * @param rightOperand The righthand operand of the
- * binary operator in AS3.
- * @param coercion The cast is a coercion,
- * throw exception if it fails.
- * @return Returns the lefthand operand if it is of the
- * type of the righthand operand, otherwise null.
- */
- static public function as(leftOperand:Object, rightOperand:Object, coercion:* = null):Object
- {
- var error:Error, itIs:Boolean, message:String;
-
- coercion = (coercion !== undefined) ? coercion : false;
-
- itIs = Language.is(leftOperand, rightOperand);
-
- if (!itIs && coercion && leftOperand)
- {
- message = 'Type Coercion failed';
-
- if (TypeError)
- {
- error = new TypeError(message);
- }
- else
- {
- error = new Error(message);
- }
- throw error;
- }
-
- return (itIs) ? leftOperand : null;
- }
-
-
- /**
- * int()
- *
- * @param value The value to be cast.
- * @return {number}
- */
- static public function _int(value:Number):Number
- {
- return value >> 0;
- }
-
- /**
- * string()
- * @param value The value to be cast.
- * @return {string}
- */
- static public function string(value:*):String
- {
- if(value == null)
- {
- return null;
- }
- //toString() leads the compiler to emit type coercion,
- //and concatenation is generally faster than String()
- return "" + value;
- }
-
- /**
- * is()
- *
- * @param leftOperand The lefthand operand of the
- * binary as operator in AS3.
- * @param rightOperand The righthand operand of the
- * binary operator in AS3.
- * @return {boolean}
- */
- static public function is(leftOperand:Object, rightOperand:Object):Boolean
- {
- var superClass:Object;
-
- if (leftOperand == null || rightOperand == null)
- return false;
-
+ public class Language
+ {
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public static var runtimeVectorSafety:Boolean = goog.DEBUG || true;
+
+ //--------------------------------------
+ // Static Property
+ //--------------------------------------
+
+
+ /**
+ * Helper var for sortOn
+ */
+ static private var sortNames:Array;
+ static private var sortNamesOne:Array = [];
+ static private var muler:Number;
+ static private var zeroStr:String = String.fromCharCode(0);
+
+ //--------------------------------------
+ // Static Function
+ //--------------------------------------
+
+ /**
+ * as()
+ *
+ * @param leftOperand The lefthand operand of the
+ * binary as operator in AS3.
+ * @param rightOperand The righthand operand of the
+ * binary operator in AS3.
+ * @param coercion The cast is a coercion,
+ * throw exception if it fails.
+ * @return Returns the lefthand operand if it is of the
+ * type of the righthand operand, otherwise null.
+ */
+ static public function as(leftOperand: Object, rightOperand: Object, coercion:* ):Object
+ {
+ const itIs:Boolean = Language.is(leftOperand, rightOperand);
+
+ if (!itIs && !!coercion){
+ if (rightOperand.constructor === _synthType) {
+ return rightOperand['coerce'](leftOperand)
+ }
+ else if ([Boolean,Number,String].indexOf(rightOperand) != -1) {
+ return rightOperand(leftOperand);
+ }
+ else if (Object === rightOperand) {
+ return rightOperand(leftOperand).valueOf();
+ }
+ if (leftOperand == null) {
+ return null;
+ }
+ const leftType:String = leftOperand.ROYALE_CLASS_INFO ? leftOperand.ROYALE_CLASS_INFO.names[0].qName : String(leftOperand);
+ const rightType:String = rightOperand.prototype && rightOperand.prototype.ROYALE_CLASS_INFO ? rightOperand.prototype.ROYALE_CLASS_INFO.names[0].qName: String(rightOperand);
+ throw new TypeError('Error #1034: Type Coercion failed: cannot convert ' + leftType + ' to ' + rightType);
+ }
+
+ return itIs ? leftOperand : null;
+ }
+
+ /**
+ * int()
+ *
+ * @param value The value to be cast.
+ * @return {number}
+ */
+ static public function _int(value:Number):Number
+ {
+ return value >> 0;
+ }
+
+ /**
+ * string()
+ * @param value The value to be cast.
+ * @return {string}
+ */
+ static public function string(value:*):String
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ //toString() leads the compiler to emit type coercion,
+ //and concatenation is generally faster than String()
+ return "" + value;
+ }
+
+ /**
+ * is()
+ *
+ * @param leftOperand The lefthand operand of the
+ * binary as operator in AS3.
+ * @param rightOperand The righthand operand of the
+ * binary operator in AS3.
+ * @return {boolean}
+ */
+ static public function is(leftOperand:Object, rightOperand: Object):Boolean
+ {
+ var superClass:Object;
+
+ if (leftOperand == null || rightOperand == null)
+ return false;
+
+ //Distinguish between Array and synthetic Vectors ('implemented' as Array-ish)
+ if (rightOperand === Array) {
+ return (Array.isArray(leftOperand) && !(SYNTH_TAG_FIELD in leftOperand));
+ }
+
if (leftOperand instanceof rightOperand)
return true;
+
if (rightOperand === Object)
return true; // every value is an Object in ActionScript except null and undefined (caught above)
// A little faster to only call typeof once
- var theType:String = typeof leftOperand;
- //TODO This is actually incorrect for 'constructed' strings
- // The correct way is using Object.prototype.toString.call(leftOperand) == '[object String]'
- // But this is about 50 times slower than typeof
- // "is String" should probably be pulled out into a separate function
- // which is called directly by the compiler to deal with it in the most performant manner.
- // Another (possibly better) option would be to have the compiler throw an error
- // if new is used with String, Number or Boolean. If 'new' is not allowed, the typeof check is enough.
- if (theType === 'string')
- return rightOperand === String;
-
- if (theType === 'number')
- return rightOperand === Number;
-
+ var theType:String = typeof leftOperand;
+ //The following do not work for 'constructed' (e.g. new String('test')) Strings, Number or Booleans,
+ //but those cases are caught using the instanceof check elsewhere
+ if (theType === 'string')
+ return rightOperand === String;
+
+ if (theType === 'number')
+ {
+ if (rightOperand === Number) return true;
+ //it is possible that rightOperand could be int or uint synthTypes... allow to proceed
+ //to the _synthType check
+ }
+
if (theType === 'boolean')
return rightOperand === Boolean;
- //TODO add optimization to compiler to convert 'is Array' directly to Array.isArray
- if (rightOperand === Array)
- return Array.isArray(leftOperand);
-
- if (leftOperand.ROYALE_CLASS_INFO === undefined)
- return false; // could be a function but not an instance
-
- if (leftOperand.ROYALE_CLASS_INFO.interfaces)
- {
- if (checkInterfaces(leftOperand, rightOperand))
- {
- return true;
- }
- }
-
- superClass = leftOperand.constructor.superClass_;
-
- if (superClass)
- {
- while (superClass && superClass.ROYALE_CLASS_INFO)
- {
- if (superClass.ROYALE_CLASS_INFO.interfaces)
- {
- if (checkInterfaces(superClass, rightOperand))
- {
- return true;
- }
- }
- superClass = superClass.constructor.superClass_;
- }
- }
-
- return false;
- }
-
+
+ if (rightOperand.constructor === _synthType)
+ return rightOperand['checkIs'](leftOperand);
+
+ if (leftOperand.ROYALE_CLASS_INFO === undefined)
+ return false; // could be a function but not an instance
+
+ if (leftOperand.ROYALE_CLASS_INFO.interfaces)
+ {
+ if (checkInterfaces(leftOperand, rightOperand))
+ {
+ return true;
+ }
+ }
+
+ superClass = leftOperand.constructor.superClass_;
+
+ if (superClass)
+ {
+ while (superClass && superClass.ROYALE_CLASS_INFO)
+ {
+ if (superClass.ROYALE_CLASS_INFO.interfaces)
+ {
+ if (checkInterfaces(superClass, rightOperand))
+ {
+ return true;
+ }
+ }
+ superClass = superClass.constructor.superClass_;
+ }
+ }
+
+ return false;
+ }
+
/**
* Helper function for is()
*/
@@ -200,12 +212,15 @@ package org.apache.royale.utils
var i:int, interfaces:Array;
interfaces = leftOperand.ROYALE_CLASS_INFO.interfaces;
- for (i = interfaces.length - 1; i > -1; i--) {
- if (interfaces[i] === rightOperand) {
+ for (i = interfaces.length - 1; i > -1; i--)
+ {
+ if (interfaces[i] === rightOperand)
+ {
return true;
}
- if (interfaces[i].prototype.ROYALE_CLASS_INFO.interfaces) {
+ if (interfaces[i].prototype.ROYALE_CLASS_INFO.interfaces)
+ {
var isit:Boolean = checkInterfaces(interfaces[i].prototype, rightOperand);
if (isit) return true;
}
@@ -220,10 +235,10 @@ package org.apache.royale.utils
public function isClass(classDef:*):Boolean
{
return typeof classDef === 'function'
- && classDef.prototype
- && classDef.prototype.constructor === classDef;
+ && classDef.prototype
+ && classDef.prototype.constructor === classDef;
}
-
+
/**
* Implementation of "classDef as Class"
*/
@@ -231,50 +246,49 @@ package org.apache.royale.utils
{
return isClass(classDef) ? classDef : null;
}
+
/**
- * @royaledebug
- */
- static public function trace(...rest):void
- {
- var theConsole:*;
-
- theConsole = goog.global.console;
-
- if (theConsole === undefined)
- {
- if(typeof window !== "undefined")
- {
- theConsole = window.console;
- }
- else if(typeof console !== "undefined")
- {
- theConsole = console;
- }
- }
-
- try
- {
- if (theConsole && theConsole.log)
- {
- theConsole.log.apply(theConsole, rest);
- }
- }
- catch (e:Error)
- {
- // ignore; at least we tried ;-)
- }
- }
-
- /**
- * uint()
- *
- * @param value The value to be cast.
- * @return {number}
- */
- static public function uint(value:Number):Number
- {
- return value >>> 0;
- }
+ * @royaledebug
+ */
+ static public function trace(...rest):void
+ {
+ var theConsole:*;
+
+ theConsole = goog.global.console;
+
+ if (theConsole === undefined)
+ {
+ if (typeof window !== "undefined")
+ {
+ theConsole = window.console;
+ } else if (typeof console !== "undefined")
+ {
+ theConsole = console;
+ }
+ }
+
+ try
+ {
+ if (theConsole && theConsole.log)
+ {
+ theConsole.log.apply(theConsole, rest);
+ }
+ } catch (e:Error)
+ {
+ // ignore; at least we tried ;-)
+ }
+ }
+
+ /**
+ * uint()
+ *
+ * @param value The value to be cast.
+ * @return {number}
+ */
+ static public function uint(value:Number):Number
+ {
+ return value >>> 0;
+ }
/**
* caches closures and returns the one closure
@@ -283,10 +297,14 @@ package org.apache.royale.utils
* @param object The instance.
* @param boundMethodName The name to use to cache the closure.
* @return The closure.
+ *
+ * @royaleignorecoercion Function
*/
- static public function closure(fn:Function, object:Object, boundMethodName:String):Function {
- if (object.hasOwnProperty(boundMethodName)) {
- return object[boundMethodName];
+ static public function closure(fn:Function, object:Object, boundMethodName:String):Function
+ {
+ if (object.hasOwnProperty(boundMethodName))
+ {
+ return object[boundMethodName] as Function;
}
var boundMethod:Function = goog.bind(fn, object);
Object.defineProperty(object, boundMethodName, {
@@ -294,138 +312,700 @@ package org.apache.royale.utils
});
return boundMethod;
};
-
+
/**
* @param arr
* @param names
* @param opt
+ *
+ * @royaleignorecoercion Function
*/
- public static function sort(arr:Array,...args):void{
+ public static function sort(arr:Array, ...args):void
+ {
var compareFunction:Function = null;
var opt:int = 0;
if (args.length == 1)
{
if (typeof args[0] === "function")
- compareFunction = args[0];
+ compareFunction = args[0] as Function;
else
opt = args[0];
- }
- else if (args.length == 2)
+ } else if (args.length == 2)
{
- compareFunction = args[0];
+ compareFunction = args[0] as Function;
opt = args[1];
}
-
- muler = (Array.DESCENDING & opt) > 0?-1: 1;
+
+ muler = (Array.DESCENDING & opt) > 0 ? -1 : 1;
if (compareFunction)
arr.sort(compareFunction);
- else if (opt & Array.NUMERIC){
+ else if (opt & Array.NUMERIC)
+ {
arr.sort(compareAsNumber);
- }else if (opt & Array.CASEINSENSITIVE){
+ } else if (opt & Array.CASEINSENSITIVE)
+ {
arr.sort(compareAsStringCaseinsensitive);
- }else{
+ } else
+ {
arr.sort(compareAsString);
}
}
- private static function compareAsStringCaseinsensitive(a:Object, b:Object):int{
- var v:int = (a||zeroStr).toString().toLowerCase().localeCompare((b||zeroStr).toString().toLowerCase());
- if (v != 0){
- return v*muler;
+ private static function compareAsStringCaseinsensitive(a:Object, b:Object):int
+ {
+ var v:int = (a || zeroStr).toString().toLowerCase().localeCompare((b || zeroStr).toString().toLowerCase());
+ if (v != 0)
+ {
+ return v * muler;
}
return 0;
}
- private static function compareAsString(a:Object, b:Object):int{
- var v:int = (a||zeroStr).toString().localeCompare((b||zeroStr).toString());
- if (v != 0){
- return v*muler;
+
+ private static function compareAsString(a:Object, b:Object):int
+ {
+ var v:int = (a || zeroStr).toString().localeCompare((b || zeroStr).toString());
+ if (v != 0)
+ {
+ return v * muler;
}
- return 0;
+ return 0;
}
- private static function compareAsNumber(a:Object, b:Object):int{
- if (a>b){
+ private static function compareAsNumber(a:Object, b:Object):int
+ {
+ if (a > b)
+ {
return muler;
- }else if (a<b){
+ } else if (a < b)
+ {
+ return -muler;
+ }
+ return 0;
+ }
+
+ /**
+ * @param arr
+ * @param names
+ * @param opt
+ */
+ public static function sortOn(arr:Array, names:Object, opt:Object = 0):void
+ {
+ if (names is Array)
+ {
+ sortNames = names as Array;
+ } else
+ {
+ sortNamesOne[0] = names;
+ sortNames = sortNamesOne;
+ }
+ if (opt is Array)
+ {
+ var opt2:int = 0;
+ for each(var o:int in opt)
+ {
+ opt2 = opt2 | o;
+ }
+ } else
+ {
+ opt2 = opt as int;
+ }
+ muler = (Array.DESCENDING & opt2) > 0 ? -1 : 1;
+ if (opt2 & Array.NUMERIC)
+ {
+ arr.sort(compareNumber);
+ } else if (opt2 & Array.CASEINSENSITIVE)
+ {
+ arr.sort(compareStringCaseinsensitive);
+ } else
+ {
+ arr.sort(compareString);
+ }
+ }
+
+ private static function compareStringCaseinsensitive(a:Object, b:Object):int
+ {
+ for each(var n:String in sortNames)
+ {
+ var v:int = (a[n] || zeroStr).toString().toLowerCase().localeCompare((b[n] || zeroStr).toString().toLowerCase());
+ if (v != 0)
+ {
+ return v * muler;
+ }
+ }
+ return 0;
+ }
+
+ private static function compareString(a:Object, b:Object):int
+ {
+ for each(var n:String in sortNames)
+ {
+ var v:int = (a[n] || zeroStr).toString().localeCompare((b[n] || zeroStr).toString());
+ if (v != 0)
+ {
+ return v * muler;
+ }
+ }
+ return 0;
+ }
+
+ private static function compareNumber(a:Object, b:Object):int
+ {
+ for each(var n:String in sortNames)
+ {
+ if (a[n] > b[n])
+ {
+ return muler;
+ } else if (a[n] < b[n])
+ {
return -muler;
+ }
}
return 0;
}
- /**
- * @param arr
- * @param names
- * @param opt
- */
- public static function sortOn(arr:Array,names:Object,opt:Object=0):void{
- if (names is Array){
- sortNames = names as Array;
- }else{
- sortNamesOne[0] = names;
- sortNames = sortNamesOne;
- }
- if (opt is Array){
- var opt2:int = 0;
- for each(var o:int in opt){
- opt2 = opt2 | o;
- }
- }else{
- opt2 = opt as int;
- }
- muler = (Array.DESCENDING & opt2) > 0?-1: 1;
- if(opt2&Array.NUMERIC){
- arr.sort(compareNumber);
- }else if (opt2&Array.CASEINSENSITIVE){
- arr.sort(compareStringCaseinsensitive);
- }else{
- arr.sort(compareString);
- }
- }
-
- private static function compareStringCaseinsensitive(a:Object, b:Object):int{
- for each(var n:String in sortNames){
- var v:int = (a[n]||zeroStr).toString().toLowerCase().localeCompare((b[n]||zeroStr).toString().toLowerCase());
- if (v != 0){
- return v*muler;
- }
- }
- return 0;
- }
- private static function compareString(a:Object, b:Object):int{
- for each(var n:String in sortNames){
- var v:int = (a[n]||zeroStr).toString().localeCompare((b[n]||zeroStr).toString());
- if (v != 0){
- return v*muler;
- }
- }
- return 0;
- }
-
- private static function compareNumber(a:Object, b:Object):int{
- for each(var n:String in sortNames){
- if (a[n]>b[n]){
- return muler;
- }else if (a[n]<b[n]){
- return -muler;
- }
- }
- return 0;
- }
-
- public static function Vector(size:int = 0, basetype:String = null):Array{
- var arr:Array = [];
- var defValue:Object = null;
- if (basetype == "int" || basetype == "uint" || basetype == "Number")
- {
- defValue = 0;
- }
- else if (basetype == "String")
- {
- defValue = "";
- }
- for (var i:int = 0; i < size; i++)
- arr.push(defValue);
- return arr;
- }
- }
+ public static function resolveUncertain(val:*):*
+ {
+ if (val) {
+ var c:Class = val.constructor;
+ if (c == String || c == Number || c == Boolean || c.constructor == _synthType) val = val.valueOf();
+ }
+ return val;
+ }
+
+ private static var _synthType:Class;
+ public static const SYNTH_TAG_FIELD:String = goog.DEBUG ? '_synthType' : '_s';
+ public static const CHECK_INDEX:String = goog.DEBUG ? 'chkIdx' : '_ci';
+
+ /**
+ *
+ * @royalesuppressresolveuncertain true, _synthType
+ */
+ public static function synthType(typeName:String, newDefinition:*):Class
+ {
+ if (!_synthType)
+ {
+ var rtFunc:* = Function;
+ _synthType = rtFunc('return ' + 'function(b,c,d,e,n){var f=function(){var t=this;var a=Array.prototype.slice.call(arguments);a.push(t);t.type=f.type;t.value=f.construct.apply(t,a);return f.noWrap?t.value:t};f.type=b;f.toString=function(){return b};f.construct=c;f.checkIs=d;f.coerce=e;f.noWrap=!!n;var p=f.prototype;p.valueOf=function(){return this.value};p.constructor=f;f.constructor=arguments.callee;return f}')();
+ //_synthType = rtFunc('return ' + 'function(type,construct,check,coerce,noWrap){var f=function(){var t=this;var args=Array.prototype.slice.call(arguments);args.push(t);t.type=f.type;t.value=f.construct.apply(t,args);return f.noWrap?t.value:t};f.type=type;f.construct=construct;f.checkIs=check;f.coerce=coerce;f.noWrap=!!noWrap;f.prototype.valueOf=function(){return this.value};f.prototype.constructor=f;f.constructor=arguments.callee;return f}')();
+
+ Object.defineProperties(_synthType,
+ {
+ '_types': {
+ value: {}
+ }
+ }
+ );
+ }
+ var typeStore:Object = _synthType['_types'];
+ if (newDefinition)
+ {
+ typeStore[typeName] = new _synthType(typeName, newDefinition['construct'], newDefinition['checkIs'], newDefinition['coerce'], newDefinition['noWrap']);
+ }
+
+ var snythTypeInst:Class = typeStore[typeName];
+ if (!snythTypeInst)
+ {
+ switch (typeName)
+ {
+ case 'int':
+ snythTypeInst = typeStore['int'] = new _synthType('int', Language._int, function (v:Number):Boolean
+ {
+ return v >> 0 === v.valueOf()
+ }, Language._int);
+ break;
+ case 'uint':
+ snythTypeInst = typeStore['uint'] = new _synthType('uint', Language.uint, function (v:Number):Boolean
+ {
+ return v >>> 0 === v.valueOf()
+ }, Language.uint);
+ break;
+ default:
+ throw new TypeError('unknown synthetic type:' + typeName);
+ break;
+ }
+ }
+ return snythTypeInst;
+ }
+
+ /**
+ * @royaleignorecoercion Array
+ */
+ public static function synthVector(elementType:String):Class
+ {
+ var typeName:String = 'Vector';
+ if (elementType !== null) typeName += '.<' + elementType + '>';
+ const synth:Function = synthType;
+ if (!_synthType || !_synthType['_types'][typeName])
+ {
+ VectorSupport.langSynthType = _synthType;
+ //create a new synthType representing the parameterized type
+ var type:Class = synth(typeName, {
+ 'construct': function (size:int, fixed:Boolean, instance:Object):Array
+ {
+ const a:Array = arguments;
+ var l:Number = a.length;
+ instance = a[--l];
+ fixed = l == 2 ? a[--l] : false;
+ size = l == 1 ? a[0] : 0;
+ instance[VectorSupport.ELEMENT_TYPE] = elementType;
+ instance[VectorSupport.TYPE] = typeName;
+ instance[VectorSupport.FIXED_LEN] = fixed ? size : -1;
+ return VectorSupport.arrayVector([], size, elementType, fixed, instance);
+ },
+ 'checkIs': function (v:Array):Boolean
+ {
+ return VectorSupport.checkIsVector(v, typeName);
+ },
+ 'coerce': function (source:*):Array
+ {
+ if (source && Array.isArray(source))
+ {
+ var arr:Array = source as Array;
+ return VectorSupport.checkIsVector(arr, typeName)
+ ? arr
+ : VectorSupport.arrayVector(arr.slice(), arr.length, elementType, false, null, false);
+ }
+ throw new TypeError('Error #1034: Type Coercion failed: cannot convert ' + source + ' to ' + typeName);
+ },
+ 'noWrap': true
+ });
+ VectorSupport.vectorElementCoercion(elementType, type);
+ VectorSupport.vectorElementDefault(elementType, type);
+ type.prototype = Object.create(type.prototype);
+ const baseVectorOverrides:Object = VectorSupport.getBaseOverrides();
+ const localOverrides:Object ={
+ 'length': {
+ 'get': baseVectorOverrides.get_len,
+ 'set':baseVectorOverrides.set_len
+ },
+ 'toString': { value:baseVectorOverrides.toString },
+ 'map': { value:baseVectorOverrides.map },
+ 'splice': { value:baseVectorOverrides.splice },
+ 'concat': { value:baseVectorOverrides.concat },
+ 'filter': { value:baseVectorOverrides.filter },
+ 'insertAt': { value:baseVectorOverrides.uncheckedInsertAt },
+ 'removeAt': { value:baseVectorOverrides.uncheckedRemoveAt },
+ 'constructor': { value:type }
+ };
+ localOverrides[Language.CHECK_INDEX] = {value:baseVectorOverrides[Language.CHECK_INDEX]};
+ localOverrides[VectorSupport.COERCE_ELEMENT] = { value: type[VectorSupport.COERCE_ELEMENT] };
+ localOverrides[VectorSupport.DEFAULT_VALUE] = { value: type[VectorSupport.DEFAULT_VALUE] };
+ Object.defineProperties(type.prototype, localOverrides)
+
+ }
+ return _synthType['_types'][typeName];
+ }
+
+
+ /**
+ * A light wrapper around a Vector constructor call that has an untyped return type
+ * (because the resulting type is unknown at compile time)
+ * This could be used to create and return a Vector instance
+ *
+ * @royaleignorecoercion Array
+ */
+ public static function Vector(size:int = 0, baseType:String = null, fixed:Boolean = false):*
+ {
+ var vectorClass:Class = synthVector(baseType);
+ return new vectorClass(size, fixed) as Array;
+ }
+ }
+
+}
+
+import org.apache.royale.utils.Language;
+import goog.DEBUG;
+import goog.global;
+
+COMPILE::JS
+class VectorSupport {
+
+ //Warning : code in this class is very dependent on non-generation of closures and possibly other 'quirks'
+ //If you make any changes, please verify this against Vector unit tests, across different targets
+
+ public static const fixedRangeError:String = 'Error #1126: Cannot change the length of a fixed Vector';
+ public static const nonConstructorError:String = 'Error #1007: Instantiation attempted on a non-constructor.';
+
+ public static var langSynthType:Object;
+
+ public static const COERCE_ELEMENT:String = goog.DEBUG ? 'coerceElement' : 'cE';
+ public static const DEFAULT_VALUE:String = goog.DEBUG ? 'defaultValue' : 'dV';
+ public static const ELEMENT_TYPE:String = goog.DEBUG ? 'elementType' : 'eT';
+ public static const TYPE:String = goog.DEBUG ? 'type' : 'ty';
+
+ public static const FIXED_LEN:String = goog.DEBUG ? 'fixedLen' : 'fL';
+
+ private static function indexRangerError(index:Number, limit:uint):String{
+ return 'Error #1125: The index ' + index + ' is out of range ' + limit;
+ }
+
+
+ public static function checkIsVector(v:Array, typeName:String):Boolean
+ {
+ const base:Boolean = v && Language.SYNTH_TAG_FIELD in v;
+ var ret:Boolean = base && v[Language.SYNTH_TAG_FIELD] instanceof langSynthType['_types'][typeName];
+ if (!ret && base && typeName == "Vector.<*>") {
+ // int, uint and Number Vectors do not also resolve to '*' typed Vectors, but all others do
+ const elementType:String = v[Language.SYNTH_TAG_FIELD][ELEMENT_TYPE];
+ ret = elementType != 'int' && elementType != 'uint' && elementType != 'Number';
+ }
+ return ret;
+ }
+
+ public static function vectorElementDefault(elementType:String, synthVectorClass:Object ):Object {
+ if (synthVectorClass[VectorSupport.DEFAULT_VALUE] !== undefined) return synthVectorClass[VectorSupport.DEFAULT_VALUE];
+ const standardDefaults:Object = {
+ 'int': 0,
+ 'uint': 0,
+ 'Number': 0,
+ 'String': '',
+ 'Boolean': false
+ };
+ var defaultVal:Object = null;
+ if (elementType in standardDefaults) {
+ defaultVal = standardDefaults[elementType];
+ }
+ synthVectorClass[VectorSupport.DEFAULT_VALUE] = defaultVal;
+ return defaultVal;
+ }
+
+ /**
+ *
+ * @royaleignorecoercion Function
+ * @royalesuppressvectorindexcheck
+ */
+ public static function vectorElementCoercion(elementType:String, synthVectorClass:Object ):Function{
+ if (synthVectorClass[VectorSupport.COERCE_ELEMENT]) return synthVectorClass[VectorSupport.COERCE_ELEMENT] as Function;
+ const identity:Function = function(v:*):Object{return v === undefined ? null : v};
+ const standardCoercions:Object = {
+ 'int': Language._int,
+ 'uint': Language.uint,
+ 'Number': Number,
+ 'String': String,
+ 'Boolean': Boolean,
+ "*": identity,
+ "Object": identity
+ };
+ var coercion:Function = standardCoercions[elementType] as Function;
+ if (coercion == null) {
+ if (elementType.indexOf('Vector.<') == 0) {
+ coercion = function(v:Object):Object{ if (!(v === null || Language.synthVector(elementType.slice(8,-1))['checkIs'](v))) {throw new TypeError('Error #1034: Type Coercion failed: cannot convert ' + v + ' to '+ elementType)} else return v };
+ } else {
+ var parts:Array = elementType.split('.');
+ var n:int = parts.length;
+ var o:Class = goog.global;
+ for (var i:int = 0; i < n; i++) {
+ o = o && o[parts[i]];
+ if (!o) throw new TypeError('missing dependency ' + elementType );
+ }
+ coercion = function(v:Object):Object{ return Language.as(v,o,true)};
+ }
+ }
+ synthVectorClass[VectorSupport.COERCE_ELEMENT] = coercion;
+ return coercion;
+ }
+
+ /**
+ * @royaleignorecoercion Function
+ */
+ private static function coerceElements(arr:Array, size:uint, tag:Object):Error{
+ const coercion:Function = tag[COERCE_ELEMENT] as Function;
+ var err:Error;
+ for (var i:int = 0; i < size; i++)
+ {
+ var original:* = arr[i];
+ //observed: undefined gets coerced to null even on * typed Vectors...
+ if (original === undefined) original = null;
+ try{
+ arr[i] = coercion(original);
+ } catch(e:Error) {
+ //avm does this anyway:
+ const defValue:Object = tag[DEFAULT_VALUE];
+ array_fill(arr, defValue,i);
+ err = e;
+ break;
+ }
+ }
+ return err;
+ }
+
+ /**
+ * @royaleignorecoercion Function
+ */
+ public static function arrayVector(arr:Array, size:int = 0, basetype:String = null, fixed:Boolean = false, tag:Object = null, construct:Boolean = true):Array
+ {
+ if (basetype === null)
+ {
+ throw new TypeError(nonConstructorError);
+ }
+ tagVectorArray(arr, basetype, fixed, tag);
+ if (!tag) tag = arr[Language.SYNTH_TAG_FIELD];
+ if (size)
+ {
+ if (construct)
+ {
+ arr.length = size;
+ const defValue:Object = tag[DEFAULT_VALUE];
+ array_fill(arr, defValue,0);
+ } else
+ { //coerce
+ const err:Error = coerceElements(arr, size, tag);
+ if (err) throw new (err.constructor)(err.message);
+ }
+ }
+ return arr;
+ }
+
+ public static function tagVectorArray(array:Array, elementType:String, fixed:Boolean, inst:Object):Array
+ {
+ const vectorType:String ='Vector.<' + elementType + '>';
+ const synthVectorClass:Class = inst ? inst.constructor : langSynthType['_types'][vectorType];
+ if (!inst) inst = new synthVectorClass()[Language.SYNTH_TAG_FIELD];
+ inst.value = array;
+ //IE11 does not support Object.assign
+ const blend:Function = Object.assign || function(target:Object, source:Object):Object{ for (var field:String in source) {target[field] = source[field]} return target};
+ //enumerable is false by default
+ const props:Object = {
+ 'fixed': {
+ 'get' : function():Boolean{return inst[FIXED_LEN] > -1},
+ 'set' : function(v:Boolean):void{ inst[FIXED_LEN]= (v ? array.length : -1)}
+ },
+ 'splice': {
+ value: inst.splice
+ },
+ 'concat': {
+ value: inst.concat
+ },
+ 'map': {
+ value: inst.map
+ },
+ 'filter': {
+ value: inst.filter
+ },
+ 'toString':{
+ value: inst.toString
+ },
+ 'constructor': {
+ value: inst.constructor
+ }
+ };
+ props[Language.CHECK_INDEX] = {
+ value: inst[Language.CHECK_INDEX]
+ };
+ props[Language.SYNTH_TAG_FIELD] = {
+ value: inst
+ };
+
+ if (Language.runtimeVectorSafety) {
+ blend(props, getFixedLengthOverrides())
+ } else {
+ blend(props, {
+ 'insertAt':{
+ value: inst.insertAt
+ },
+ 'removeAt':{
+ value: inst.removeAt
+ }
+ })
+ }
+
+ Object.defineProperties (array, props);
+ return array;
+ }
+
+
+ /**
+ * Fills the array from a start point (defaults to zero) to its end with the specified value
+ */
+ public static function array_fill(arr:Array, value:Object, start:uint):Array{
+ if (arr['fill']) {
+ return arr['fill'](value, start);
+ } else {
+ //IE11 support
+ var i:uint = start>>>0;
+ const l:uint = arr.length;
+ while (i<l) {
+ arr[i] = value;
+ i++;
+ }
+ }
+ return arr;
+ }
+
+ //The instance methods of this class are primarily a source for runtime patching of 'Vector-like' Arrays
+ //The class uses some indirection to avoid the royale compiler generating closures and therefore references to 'this'
+ //in the local methods can become references to the Array instance itself in its patched methods
+ //with the exception of the get_len and set_len methods where 'this' refers to the instance of the 'synthType' tag
+ //attached to the Array that is considered 'Vector-like'
+
+ private static var _instance:VectorSupport;
+ private static var _baseObject:Object;
+ public static function getBaseOverrides():Object{
+ if (_baseObject) return _baseObject;
+ _instance = new VectorSupport();
+ _baseObject = {};
+ _baseObject.toString = _instance['toString'];
+ _baseObject.map = _instance['map'];
+ _baseObject.splice = _instance['splice'];
+ _baseObject.concat = _instance['concat'];
+ _baseObject.filter = _instance['filter'];
+ _baseObject.uncheckedInsertAt = _instance['uncheckedInsertAt'];
+ _baseObject.uncheckedRemoveAt = _instance['uncheckedRemoveAt'];
+ _baseObject.get_len = _instance['get_len'];
+ _baseObject.set_len = _instance['set_len'];
+ _baseObject[Language.CHECK_INDEX] = _instance['chkIdx'];
+ return _baseObject;
+ }
+
+ private static var _fixedLenObject:Object;
+ public static function getFixedLengthOverrides():Object{
+ if (_fixedLenObject) return _fixedLenObject;
+ _fixedLenObject = {
+ 'pop': {
+ value:_instance['pop']
+ },
+ 'push': {
+ value:_instance['push']
+ },
+ 'shift': {
+ value:_instance['shift']
+ },
+ 'unshift': {
+ value:_instance['unshift']
+ },
+ 'insertAt': {
+ value:_instance['insertAt']
+ },
+ 'removeAt': {
+ value:_instance['removeAt']
+ }
+ };
+ return _fixedLenObject;
+ }
+
+ public function toString():String{
+ return Array.prototype.map.call(this, String).toString();
+ }
+ /**
+ * @royaleignorecoercion Array
+ */
+ public function map(callback:Function):* {
+ var inst:Object= this[Language.SYNTH_TAG_FIELD]; return tagVectorArray(Array.prototype.map.call(this, function(item:Object, index:int, source:*):Object{return inst[COERCE_ELEMENT](callback(item,index,source))}) as Array, inst[ELEMENT_TYPE],false,null);
+ }
+ /**
+ * @royaleignorecoercion Array
+ */
+ public function splice():* {
+ var a:Array = Array.prototype.slice.call(arguments) as Array;var inst:Object= this[Language.SYNTH_TAG_FIELD]; var ret:Array = Array.prototype.splice.apply(this, a) as Array; if (inst[FIXED_LEN] > -1) inst[FIXED_LEN] = this['length']; return arrayVector(ret, ret.length, inst[ELEMENT_TYPE], false, null, false);
+ }
+ /**
+ * @royaleignorecoercion Array
+ */
+ public function filter():* {
+ var a:Array = Array.prototype.slice.call(arguments) as Array;var inst:Object= this[Language.SYNTH_TAG_FIELD]; var ret:Array = Array.prototype.filter.apply(this, a) as Array; return arrayVector(ret, ret.length, inst[ELEMENT_TYPE], false, null, false);
+ }
+
+ /**
+ * @royaleignorecoercion Array
+ * @royaleignorecoercion String
+ */
+ public function concat():* {
+ var a:Array = Array.prototype.slice.call(arguments) as Array;var inst:Object = this[Language.SYNTH_TAG_FIELD];
+ var l:uint = a.length;
+ for (var i:int = 0; i<l; i++) {
+ var contender:Array = a[i] as Array;
+ if (!checkIsVector(contender, inst[TYPE] as String)) {
+ throw new TypeError('Error #1034: Type Coercion failed: cannot convert ' + contender[Language.SYNTH_TAG_FIELD][TYPE] + ' to ' + inst[TYPE]);
+ }
+ }
+ var ret:Array = Array.prototype.concat.apply(this, a) as Array;
+ return arrayVector(ret, ret.length, inst[ELEMENT_TYPE], false, null, false);
+ }
+
+ public function uncheckedInsertAt(index:Number,item:*):* {
+ return Array.prototype.splice.call(this, index, 0, item);
+ }
+
+ public function uncheckedRemoveAt(index:Number):* {
+ return Array.prototype.splice.call(this, index, 1)[0];
+ }
+
+ public function get_len():Number{
+ //'this' inside here is the synthType instance. It has a value property that refers to the
+ //Array instance that it 'tags'
+ return this['value'].length
+ }
+ /**
+ * @royaleignorecoercion Array
+ */
+ public function set_len(value:Number):void{
+ //'this' here is the synthType instance. It has a value property that refers to the
+ //Array instance that it 'tags'
+ if (this[FIXED_LEN] != -1) {
+ throw new RangeError(fixedRangeError)
+ } else {
+ var oldLen:Number = this['value'].length;
+ this['value'].length = value;
+ if (oldLen < value) {
+ array_fill(this['value'] as Array, this[DEFAULT_VALUE], oldLen);
+ }
+ }
+ }
+
+ //fixed-length vector-like array overrides
+ public function pop(v:*):* {
+ if (this[Language.SYNTH_TAG_FIELD][FIXED_LEN] > -1) {throw new RangeError(fixedRangeError)} else return Array.prototype.pop.call(this)
+ }
+
+ public function shift(v:*):* {
+ if (this[Language.SYNTH_TAG_FIELD][FIXED_LEN] > -1) {throw new RangeError(fixedRangeError)} else return Array.prototype.shift.call(this)
+ }
+
+ /**
+ * @royaleignorecoercion Array
+ */
+ public function push(v:*):* {
+ if (this[Language.SYNTH_TAG_FIELD][FIXED_LEN] > -1) {throw new RangeError(fixedRangeError)} else{
+ var a:Array = Array.prototype.slice.call(arguments) as Array;
+ const err:Error = coerceElements(a, a.length, this[Language.SYNTH_TAG_FIELD]);
+ var len:uint = Array.prototype.push.apply(this,a);
+ if (err) throw new (err.constructor)(err.message);
+ return len;
+ }
+ }
+ /**
+ * @royaleignorecoercion Array
+ */
+ public function unshift(v:*):* {
+ if (this[Language.SYNTH_TAG_FIELD][FIXED_LEN] > -1) {throw new RangeError(fixedRangeError)} else{
+ var a:Array = Array.prototype.slice.call(arguments) as Array;
+ const err:Error = coerceElements(a, a.length, this[Language.SYNTH_TAG_FIELD]);
+ var len:uint = Array.prototype.unshift.apply(this,a);
+ if (err) throw new (err.constructor)(err.message);
+ return len;
+ }
+ }
+
+ public function insertAt(index:int, item:*):void {
+ if (this[Language.SYNTH_TAG_FIELD][FIXED_LEN] > -1) {throw new RangeError(fixedRangeError)} else this[Language.SYNTH_TAG_FIELD]['insertAt'].call(this,index,item)
+ }
+
+ public function removeAt(index:int):Object {
+ if (this[Language.SYNTH_TAG_FIELD][FIXED_LEN] > -1) {throw new RangeError(fixedRangeError)} else {
+ const idx:int = index < 0 ? Math.max(this['length'] + index, 0) : index;
+ if (idx >= this['length']) throw new RangeError(indexRangerError(index, this['length']));
+ return this[Language.SYNTH_TAG_FIELD]['removeAt'].call(this, idx);
+ }
+ }
+
+ public function chkIdx(index:Number):Number {
+ var limit:Number = this[Language.SYNTH_TAG_FIELD][FIXED_LEN];
+ var fail:Boolean = index >>> 0 !== index; //fail if not a uint value (also covers negative value range check)
+ fail ||= ((limit == -1) ? (index > (limit = this['length'])) : (index >= limit)); //fail if not below length limit (possibly fixed)
+ if (fail) {
+ throw new RangeError(indexRangerError(index, limit));
+ }
+ return index;
+ }
+
}
diff --git a/frameworks/projects/MXRoyale/pom.xml b/frameworks/projects/MXRoyale/pom.xml
index 9399533..95c5eb6 100644
--- a/frameworks/projects/MXRoyale/pom.xml
+++ b/frameworks/projects/MXRoyale/pom.xml
@@ -73,7 +73,7 @@
</define>
</defines>
<allowSubclassOverrides>true</allowSubclassOverrides>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true;-js-compiler-define=COMPILE::JS,true;-js-compiler-define=COMPILE::SWF,false;-js-compiler-define=GOOG::DEBUG,goog.DEBUG;-js-compiler-define=ROYALE::DISPLAYOBJECT,IUIComponent;-js-compiler-define=ROYALE::PROXYVISIBILITY,public;-namespace+=http://ns.adobe.com/mxml/2009,${project.basedir}/../../mxml-2009-manifest.xml;-compiler.js-namespaces.namespace+=http://ns.adobe.com/mxml/2009,${project.basedir}/../../mx [...]
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true;-js-compiler-define=COMPILE::JS,true;-js-compiler-define=COMPILE::SWF,false;-js-compiler-define=GOOG::DEBUG,goog.DEBUG;-js-compiler-define=ROYALE::DISPLAYOBJECT,IUIComponent;-js-compiler-define=ROYALE::PROXYVISIBILITY,public;-namespace+=http://ns.adobe.com/mxml/2009,${project.basedir}/../../mxml-2009-mani [...]
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/MaterialDesignLite/pom.xml b/frameworks/projects/MaterialDesignLite/pom.xml
index ba6a839..e1a5592 100644
--- a/frameworks/projects/MaterialDesignLite/pom.xml
+++ b/frameworks/projects/MaterialDesignLite/pom.xml
@@ -64,7 +64,7 @@
<includeLookupOnly>true</includeLookupOnly>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Mobile/pom.xml b/frameworks/projects/Mobile/pom.xml
index 6f9f114..2281a68 100644
--- a/frameworks/projects/Mobile/pom.xml
+++ b/frameworks/projects/Mobile/pom.xml
@@ -62,7 +62,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Network/pom.xml b/frameworks/projects/Network/pom.xml
index 7d8691e..1a479c6 100644
--- a/frameworks/projects/Network/pom.xml
+++ b/frameworks/projects/Network/pom.xml
@@ -52,7 +52,7 @@
</includeClasses>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true;-warn-instance-of-changes=false</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true;-warn-instance-of-changes=false</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Reflection/pom.xml b/frameworks/projects/Reflection/pom.xml
index bab3bb5..b08982d 100644
--- a/frameworks/projects/Reflection/pom.xml
+++ b/frameworks/projects/Reflection/pom.xml
@@ -50,7 +50,7 @@
<includeSources>true</includeSources>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/RoyaleSite/pom.xml b/frameworks/projects/RoyaleSite/pom.xml
index f0b5394..99c06f1 100644
--- a/frameworks/projects/RoyaleSite/pom.xml
+++ b/frameworks/projects/RoyaleSite/pom.xml
@@ -55,7 +55,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/RoyaleUnit/pom.xml b/frameworks/projects/RoyaleUnit/pom.xml
index d0cb06e..079e767 100644
--- a/frameworks/projects/RoyaleUnit/pom.xml
+++ b/frameworks/projects/RoyaleUnit/pom.xml
@@ -44,7 +44,7 @@
<includeSources>true</includeSources>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/SparkRoyale/pom.xml b/frameworks/projects/SparkRoyale/pom.xml
index b8dcc72..ffc0f86 100644
--- a/frameworks/projects/SparkRoyale/pom.xml
+++ b/frameworks/projects/SparkRoyale/pom.xml
@@ -65,7 +65,7 @@
</define>
</defines>
<allowSubclassOverrides>true</allowSubclassOverrides>
- <additionalCompilerOptions>-js-default-initializers=false;-js-compiler-define=COMPILE::JS,true;-js-compiler-define=COMPILE::SWF,false;-js-compiler-define=GOOG::DEBUG,goog.DEBUG</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-js-compiler-define=COMPILE::JS,true;-js-compiler-define=COMPILE::SWF,false;-js-compiler-define=GOOG::DEBUG,goog.DEBUG</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/Storage/pom.xml b/frameworks/projects/Storage/pom.xml
index 3d4bd0d..cba2918 100644
--- a/frameworks/projects/Storage/pom.xml
+++ b/frameworks/projects/Storage/pom.xml
@@ -58,7 +58,7 @@
</includeFiles>
<skipExtern>true</skipExtern>
<skipAS>${royale.skipAS}</skipAS>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/TLF/pom.xml b/frameworks/projects/TLF/pom.xml
index 5adc916..3b9ff73 100644
--- a/frameworks/projects/TLF/pom.xml
+++ b/frameworks/projects/TLF/pom.xml
@@ -64,7 +64,7 @@
<allowSubclassOverrides>true</allowSubclassOverrides>
<skipAS>${royale.skipAS}</skipAS>
<skipExtern>true</skipExtern>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
<defines>
<define>
<name>CONFIG::debug</name>
diff --git a/frameworks/projects/Text/pom.xml b/frameworks/projects/Text/pom.xml
index 6f675ee..3508d06 100644
--- a/frameworks/projects/Text/pom.xml
+++ b/frameworks/projects/Text/pom.xml
@@ -64,7 +64,7 @@
<allowSubclassOverrides>true</allowSubclassOverrides>
<skipAS>${royale.skipAS}</skipAS>
<skipExtern>true</skipExtern>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true;-source-map=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
index a4984cd..e6ea42e 100644
--- a/frameworks/projects/XML/src/main/royale/XML.as
+++ b/frameworks/projects/XML/src/main/royale/XML.as
@@ -80,26 +80,26 @@ package
/**
* [static] Determines whether XML comments are ignored when XML objects parse the source XML data.
- *
+ *
*/
static public var ignoreComments:Boolean = true;
/**
* [static] Determines whether XML processing instructions are ignored when XML objects parse the source XML data.
- *
+ *
*/
static public var ignoreProcessingInstructions:Boolean = true;
/**
* [static] Determines whether white space characters at the beginning and end of text nodes are ignored during parsing.
- *
+ *
*/
static public var ignoreWhitespace:Boolean = true;
static private var _prettyIndent:int = 2;
/**
* [static] Determines the amount of indentation applied by the toString() and toXMLString() methods when the XML.prettyPrinting property is set to true.
- *
+ *
*/
static public function set prettyIndent(value:int):void
{
@@ -121,7 +121,7 @@ package
/**
* [static] Determines whether the toString() and toXMLString() methods normalize white space characters between some tags.
- *
+ *
*/
static public var prettyPrinting:Boolean = true;
@@ -316,8 +316,8 @@ package
/**
* [static] Returns an object with the following properties set to the default values: ignoreComments, ignoreProcessingInstructions, ignoreWhitespace, prettyIndent, and prettyPrinting.
- * @return
- *
+ * @return
+ *
*/
static public function defaultSettings():Object
{
@@ -333,7 +333,7 @@ package
/**
* [static] Sets values for the following XML properties: ignoreComments, ignoreProcessingInstructions, ignoreWhitespace, prettyIndent, and prettyPrinting.
* @param rest
- *
+ *
*/
static public function setSettings(value:Object):void
{
@@ -349,9 +349,9 @@ package
/**
* [static] Retrieves the following properties: ignoreComments, ignoreProcessingInstructions, ignoreWhitespace, prettyIndent, and prettyPrinting.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
static public function settings():Object
{
@@ -504,10 +504,10 @@ package
/**
* @private
- *
+ *
* Similar to appendChild, but accepts all XML types (text, comment, processing-instruction, attribute, or element)
*
- *
+ *
*/
public function addChild(child:XML):void
{
@@ -527,7 +527,7 @@ package
{
// don't add child
}
- else
+ else
getChildren().push(child);
}
@@ -552,8 +552,8 @@ package
* Adds a namespace to the set of in-scope namespaces for the XML object.
*
* @param ns
- * @return
- *
+ * @return
+ *
*/
public function addNamespace(ns:Namespace):XML
{
@@ -612,8 +612,8 @@ package
* Appends the given child to the end of the XML object's properties.
*
* @param child
- * @return
- *
+ * @return
+ *
*/
public function appendChild(child:*):XML
{
@@ -667,8 +667,8 @@ package
* Returns the XML value of the attribute that has the name matching the attributeName parameter.
*
* @param attributeName
- * @return
- *
+ * @return
+ *
*/
public function attribute(attributeName:*):XMLList
{
@@ -692,8 +692,8 @@ package
/**
* Returns a list of attribute values for the given XML object.
*
- * @return
- *
+ * @return
+ *
*/
public function attributes():XMLList
{
@@ -711,13 +711,13 @@ package
* Lists the children of an XML object.
*
* @param propertyName
- * @return
- *
+ * @return
+ *
*/
public function child(propertyName:Object):XMLList
{
/*
- *
+ *
When the [[Get]] method of an XML object x is called with property name P, the following steps are taken:
1. If ToString(ToUint32(P)) == P
a. Let list = ToXMLList(x)
@@ -772,8 +772,8 @@ package
/**
* Identifies the zero-indexed position of this XML object within the context of its parent.
*
- * @return
- *
+ * @return
+ *
*/
public function childIndex():int
{
@@ -786,8 +786,8 @@ package
/**
* Lists the children of the XML object in the sequence in which they appear.
*
- * @return
- *
+ * @return
+ *
*/
public function children():XMLList
{
@@ -804,8 +804,8 @@ package
/**
* Lists the properties of the XML object that contain XML comments.
*
- * @return
- *
+ * @return
+ *
*/
public function comments():XMLList
{
@@ -845,8 +845,8 @@ package
* Compares the XML object against the given value parameter.
*
* @param value
- * @return
- *
+ * @return
+ *
*/
public function contains(value:*):Boolean
{
@@ -857,9 +857,9 @@ package
/**
* Returns a copy of the given XML object.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function copy():XML
{
@@ -911,10 +911,10 @@ package
/**
* Returns all descendants (children, grandchildren, great-grandchildren, and so on) of the XML object that have the given name parameter.
- *
+ *
* @param name
- * @return
- *
+ * @return
+ *
*/
public function descendants(name:Object = "*"):XMLList
{
@@ -957,17 +957,17 @@ package
list.append(_children[i]);
list.concat(_children[i].descendants(name));
- }
+ }
}
return list;
}
/**
* Lists the elements of an XML object. (handles E4X dot notation)
- *
+ *
* @param name
- * @return
- *
+ * @return
+ *
*/
public function elements(name:Object = "*"):XMLList
{
@@ -1172,9 +1172,9 @@ package
}
/**
* Checks to see whether the XML object contains complex content.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function hasComplexContent():Boolean
{
@@ -1241,12 +1241,12 @@ package
}
return false;
}
-
+
/**
* Checks to see whether the XML object contains simple content.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function hasSimpleContent():Boolean
{
@@ -1271,9 +1271,9 @@ package
/**
* Lists the namespaces for the XML object, based on the object's parent.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function inScopeNamespaces():Array
{
@@ -1313,11 +1313,11 @@ package
}
/**
* Inserts the given child2 parameter after the child1 parameter in this XML object and returns the resulting object.
- *
+ *
* @param child1
* @param child2
- * @return
- *
+ * @return
+ *
*/
public function insertChildAfter(child1:XML, child2:XML):XML
{
@@ -1349,11 +1349,11 @@ package
/**
* Inserts the given child2 parameter before the child1 parameter in this XML object and returns the resulting object.
- *
+ *
* @param child1
* @param child2
- * @return
- *
+ * @return
+ *
*/
public function insertChildBefore(child1:XML, child2:XML):XML
{
@@ -1368,7 +1368,7 @@ package
i. If x[i] is the same object as child1
1. Call the [[Insert]] method of x with arguments ToString(i) and child2
2. Return x
- 4. Return
+ 4. Return
*/
if(_nodeKind == "text" || _nodeKind == "comment" || _nodeKind == "processing-instruction" || _nodeKind == "attribute")
return null;
@@ -1388,9 +1388,9 @@ package
/**
* For XML objects, this method always returns the integer 1.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function length():int
{
@@ -1399,9 +1399,9 @@ package
/**
* Gives the local name portion of the qualified name of the XML object.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function localName():String
{
@@ -1412,9 +1412,9 @@ package
/**
* Gives the qualified name for the XML object.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function name():QName
{
@@ -1425,10 +1425,10 @@ package
/**
* If no parameter is provided, gives the namespace associated with the qualified name of this XML object.
- *
+ *
* @param prefix
- * @return
- *
+ * @return
+ *
*/
public function namespace(prefix:String = null):*
{
@@ -1470,9 +1470,9 @@ package
/**
* Lists namespace declarations associated with the XML object in the context of its parent.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function namespaceDeclarations():Array
{
@@ -1530,8 +1530,8 @@ package
private var _nodeKind:String = "element";
/**
* Specifies the type of node: text, comment, processing-instruction, attribute, or element.
- * @return
- *
+ * @return
+ *
*/
public function nodeKind():String
{
@@ -1540,9 +1540,9 @@ package
/**
* For the XML object and all descendant XML objects, merges adjacent text nodes and eliminates empty text nodes.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function normalize():XML
{
@@ -1577,9 +1577,9 @@ package
/**
* Returns the parent of the XML object.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function parent():*
{
@@ -1604,8 +1604,8 @@ package
/**
* Inserts the provided child object into the XML element before any existing XML properties for that element.
* @param value
- * @return
- *
+ * @return
+ *
*/
public function prependChild(child:XML):XML
{
@@ -1639,10 +1639,10 @@ package
/**
* If a name parameter is provided, lists all the children of the XML object that contain processing instructions with that name.
- *
+ *
* @param name
- * @return
- *
+ * @return
+ *
*/
public function processingInstructions(name:String = "*"):XMLList
{
@@ -1660,10 +1660,10 @@ package
/**
* Removes the given chid for this object and returns the removed child.
- *
+ *
* @param child
- * @return
- *
+ * @return
+ *
*/
public function removeChild(child:XML):Boolean
{
@@ -1777,10 +1777,10 @@ package
/**
* Removes the given namespace for this object and all descendants.
- *
+ *
* @param ns
- * @return
- *
+ * @return
+ *
*/
public function removeNamespace(ns:*):XML
{
@@ -1842,11 +1842,11 @@ package
/**
* Replaces the properties specified by the propertyName parameter with the given value parameter.
- *
+ *
* @param propertyName
* @param value
- * @return
- *
+ * @return
+ *
*/
public function replace(propertyName:Object, value:*):*
{
@@ -1866,7 +1866,7 @@ package
ii. Let i = k
8. If i == undefined, return x
9. Call the [[Replace]] method of x with arguments ToString(i) and c
- 10. Return x
+ 10. Return x
*/
if(_nodeKind == "text" || _nodeKind == "comment" || _nodeKind == "processing-instruction" || _nodeKind == "attribute")
@@ -2027,16 +2027,16 @@ package
/**
* Replaces the child properties of the XML object with the specified name with the specified XML or XMLList.
* This is primarily used to support dot notation assignment of XML.
- *
+ *
* @param value
- * @return
- *
+ * @return
+ *
*/
public function setChild(elementName:*, elements:Object):Object
{
/*
- *
+ *
1. If ToString(ToUint32(P)) == P, throw a TypeError exception NOTE this operation is reserved for future versions of E4X.
2. If x.[[Class]] ∈ {"text", "comment", "processing-instruction", "attribute"}, return
3. If (Type(V) ∉ {XML, XMLList}) or (V.[[Class]] ∈ {"text", "attribute"})
@@ -2180,10 +2180,10 @@ package
/**
* Replaces the child properties of the XML object with the specified set of XML properties, provided in the value parameter.
- *
+ *
* @param value
- * @return
- *
+ * @return
+ *
*/
public function setChildren(value:Object):XML
{
@@ -2236,9 +2236,9 @@ package
/**
* Changes the local name of the XML object to the given name parameter.
- *
+ *
* @param name
- *
+ *
*/
public function setLocalName(name:String):void
{
@@ -2251,9 +2251,9 @@ package
/**
* Sets the name of the XML object to the given qualified name or attribute name.
- *
+ *
* @param name
- *
+ *
*/
public function setName(name:*):void
{
@@ -2268,9 +2268,9 @@ package
/**
* Sets the namespace associated with the XML object.
- *
+ *
* @param ns
- *
+ *
*/
public function setNamespace(ns:Object):void
{
@@ -2295,7 +2295,7 @@ package
/**
* @private
- *
+ *
*/
public function setNodeKind(value:String):void
{
@@ -2321,7 +2321,7 @@ package
/**
* @private
- *
+ *
* Allows XMLList to get the targetObject of its targetObject and not error when it gets the XML
*/
public function get targetObject():*
@@ -2331,9 +2331,9 @@ package
/**
* Returns an XMLList object of all XML properties of the XML object that represent XML text nodes.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function text():XMLList
{
@@ -2351,10 +2351,10 @@ package
/**
* Provides an overridable method for customizing the JSON encoding of values in an XML object.
- *
+ *
* @param k
- * @return
- *
+ * @return
+ *
*/
/*
override public function toJSON(k:String):String
@@ -2365,9 +2365,9 @@ package
/**
* Returns a string representation of the XML object.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function toString():String
{
@@ -2458,9 +2458,9 @@ package
/**
* Returns a string representation of the XML object.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
public function toXMLString(indentLevel:int=0,ancestors:Array=null):String
{
@@ -2541,7 +2541,7 @@ package
a. Let s be the result of concatenating s, namespace.prefix and the string ":"
26. Let s be the result of concatenating s, x.[[Name]].localName and the string ">"
27. Return s
- NOTE Implementations may also preserve insignificant whitespace (e.g., inside and between element tags) and attribute quoting conventions in ToXMLString().
+ NOTE Implementations may also preserve insignificant whitespace (e.g., inside and between element tags) and attribute quoting conventions in ToXMLString().
*/
var i:int;
var len:int;
@@ -2605,9 +2605,9 @@ package
ns.prefix = "";
declarations.push(ns);
}
- if(XML.prettyPrinting)
+ if(XML.prettyPrinting && indentLevel > 0)
{
- strArr.push(new Array(indentLevel).join(' '));
+ strArr.push(new Array(indentLevel + 1).join(_indentStr));
}
strArr.push("<");
if(ns.prefix)
@@ -2660,7 +2660,7 @@ package
var indentChildren:Boolean = len > 1 || (len == 1 && _children[0].nodeKind() != "text");
var nextIndentLevel:int;
if(XML.prettyPrinting && indentChildren)
- nextIndentLevel = indentLevel + prettyIndent;
+ nextIndentLevel = indentLevel + 1;
else
nextIndentLevel = 0;
for(i=0;i<len;i++)
@@ -2673,7 +2673,8 @@ package
if(XML.prettyPrinting && indentChildren)
{
strArr.push("\n");
- strArr.push(new Array(indentLevel + 1).join(' '));
+ if (indentLevel > 0)
+ strArr.push(new Array(indentLevel + 1).join(_indentStr));
}
strArr.push("</");
if(ns.prefix)
@@ -2689,9 +2690,9 @@ package
/**
* Returns the XML object.
- *
- * @return
- *
+ *
+ * @return
+ *
*/
override public function valueOf():*
{
@@ -2709,7 +2710,7 @@ package
///
///
/// METHODS to allow XML to behave as if it's a string or number
- ///
+ ///
///
////////////////////////////////////////////////////////////////
diff --git a/frameworks/projects/pom.xml b/frameworks/projects/pom.xml
index 6ef1fef..551866c 100644
--- a/frameworks/projects/pom.xml
+++ b/frameworks/projects/pom.xml
@@ -85,7 +85,7 @@
<configuration>
<!-- We don't want dependencies to be linked into the resulting libraries -->
<forceSwcExternalLibraryPath>true</forceSwcExternalLibraryPath>
- <additionalCompilerOptions>-js-default-initializers=false;-source-map=true</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers=false;-source-map=true;-js-no-complex-implicit-coercions=true;-js-no-vector-index-checks=true;-js-no-resolve-uncertain=true</additionalCompilerOptions>
</configuration>
</plugin>
</plugins>
diff --git a/manualtests/UnitTests/pom.xml b/manualtests/UnitTests/pom.xml
index 6baaf7a..43f0f66 100644
--- a/manualtests/UnitTests/pom.xml
+++ b/manualtests/UnitTests/pom.xml
@@ -35,7 +35,7 @@
<bgcolor>#ffffff</bgcolor>
<useBrowserHistory>--</useBrowserHistory>
<version_major>11</version_major>
- <version_minor>1</version_minor>
+ <version_minor>5</version_minor>
<version_revision>0</version_revision>
<expressInstallSwf>expressInstall.swf</expressInstallSwf>
<application>${project.artifactId}</application>
@@ -56,7 +56,7 @@
<mainClass>${project.artifactId}.mxml</mainClass>
<removeCirculars>true</removeCirculars>
<debug>true</debug>
- <additionalCompilerOptions>-js-default-initializers;-keep-as3-metadata+=Test,BeforeClass,AfterClass,Before,After,TestVariance,Event,Bindable,TestMeta;-keep-code-with-metadata=Test,BeforeClass,AfterClass,Before,After,TestVariance,TestMeta</additionalCompilerOptions>
+ <additionalCompilerOptions>-swf-version=18;-keep-as3-metadata+=Test,BeforeClass,AfterClass,Before,After,TestVariance,Event,Bindable,TestMeta</additionalCompilerOptions>
<outputDirectory>${basedir}/target/bin-debug</outputDirectory>
<flashOutputFileName>${project.artifactId}.swf</flashOutputFileName>
</configuration>
@@ -71,7 +71,7 @@
<targets>JSRoyale</targets>
<mainClass>${project.artifactId}.mxml</mainClass>
<debug>false</debug>
- <additionalCompilerOptions>-js-default-initializers;-keep-as3-metadata+=Test,BeforeClass,AfterClass,Before,After,TestVariance,Event,Bindable,TestMeta;-keep-code-with-metadata=Test,BeforeClass,AfterClass,Before,After,TestVariance,TestMeta</additionalCompilerOptions>
+ <additionalCompilerOptions>-js-default-initializers;-source-map=true;-keep-as3-metadata+=Test,BeforeClass,AfterClass,Before,After,TestVariance,Event,Bindable,TestMeta;-keep-code-with-metadata=Test,BeforeClass,AfterClass,Before,After,TestVariance,TestMeta</additionalCompilerOptions>
<outputDirectory>${basedir}/target</outputDirectory>
</configuration>
</execution>
@@ -168,6 +168,20 @@
</dependency>
<dependency>
<groupId>org.apache.royale.framework</groupId>
+ <artifactId>Network</artifactId>
+ <version>0.9.6-SNAPSHOT</version>
+ <type>swc</type>
+ <classifier>swf</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.royale.framework</groupId>
+ <artifactId>Network</artifactId>
+ <version>0.9.6-SNAPSHOT</version>
+ <type>swc</type>
+ <classifier>js</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.royale.framework</groupId>
<artifactId>XML</artifactId>
<version>0.9.6-SNAPSHOT</version>
<type>swc</type>
diff --git a/manualtests/UnitTests/src/main/royale/TestClasses.as b/manualtests/UnitTests/src/main/royale/TestClasses.as
index 61462dc..e96a3d9 100644
--- a/manualtests/UnitTests/src/main/royale/TestClasses.as
+++ b/manualtests/UnitTests/src/main/royale/TestClasses.as
@@ -27,6 +27,7 @@ package
public static function get testClasses():Array {
return [
+ LanguageTester,
CoreTester,
ReflectionTester,
ObservedBugsTester,
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/CoreTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/CoreTester.as
index 5ce4e9a..bc94b47 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/CoreTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/CoreTester.as
@@ -18,16 +18,19 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests
{
- import flexUnitTests.core.*
-
+ import flexUnitTests.core.*
+
[Suite]
[RunWith("org.flexunit.runners.Suite")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class CoreTester
{
public function CoreTester()
{
// for JS, force-link these classes in the output
- var arr:Array = [StrandTesterTest, BinaryDataTesterTest,MD5Test];
+ var arr:Array = [StrandTesterTest, BinaryDataTesterTest, MD5Test, ArrayTesterTest];
}
// in JS, using a class as a type won't include the class in
@@ -38,7 +41,9 @@ package flexUnitTests
// of tests? I would think an array of tests would wokr
// better and allow you to define order.
public var strandTesterTest:StrandTesterTest;
- public var binaryDataTesterTest:BinaryDataTesterTest;
- public var md5Test:MD5Test;
+ public var binaryDataTesterTest:BinaryDataTesterTest;
+ public var md5Test:MD5Test;
+
+ public var arrayTest:ArrayTesterTest;
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/GithubIssuesTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/GithubIssuesTester.as
index 72b5ee1..ac51fa9 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/GithubIssuesTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/GithubIssuesTester.as
@@ -18,12 +18,24 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests
{
- import flexUnitTests.github.*
-
+ import flexUnitTests.github.*
+
[Suite]
[RunWith("org.flexunit.runners.Suite")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class GithubIssuesTester
{
+ public function GithubIssuesTester()
+ {
+ // see notes in CoreTester
+ var arr:Array = [GithubIssues2018, GithubIssues2019];
+ }
+
+ public var issues2018:GithubIssues2018;
+
+ public var issues2019:GithubIssues2019;
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/ReflectionTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/LanguageTester.as
similarity index 68%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/ReflectionTester.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/LanguageTester.as
index 369e763..2f747a9 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/ReflectionTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/LanguageTester.as
@@ -18,24 +18,26 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests
{
- import flexUnitTests.reflection.*;
-
+ import flexUnitTests.language.*;
+
[Suite]
[RunWith("org.flexunit.runners.Suite")]
- public class ReflectionTester
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class LanguageTester
{
- public function ReflectionTester()
+ public function LanguageTester()
{
// see notes in CoreTester
- var arr:Array = [ReflectionTesterTest, ReflectionTesterTestUseCache, ReflectionTesterTestAlias, ReflectionTesterTestDynamic];
+ var arr:Array = [LanguageTesterTestIs, LanguageTesterIntUint, LanguageTesterTestVector];
}
- public var reflectionTesterCacheTest:ReflectionTesterTestUseCache;
- public var reflectionTesterTest:ReflectionTesterTest;
+ public var languageTestIs:LanguageTesterTestIs;
+
+ public var languageTestIntUint:LanguageTesterIntUint;
+
+ public var languageTestVector:LanguageTesterTestVector;
- public var reflectionTesterAliasTest:ReflectionTesterTestAlias;
-
-
- public var reflectionTesterDynamicTest:ReflectionTesterTestDynamic;
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/NetworkTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/NetworkTester.as
index ef8e73b..57b4c3b 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/NetworkTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/NetworkTester.as
@@ -18,10 +18,13 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests
{
- import flexUnitTests.network.*
-
+ import flexUnitTests.network.*
+
[Suite]
[RunWith("org.flexunit.runners.Suite")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class NetworkTester
{
public function NetworkTester()
@@ -37,7 +40,7 @@ package flexUnitTests
// Is there a reason to use reflection to gather the set
// of tests? I would think an array of tests would wokr
// better and allow you to define order.
- public var amfBinaryDataTesterTest:AMFBinaryDataTesterTest;
-
+ public var amfBinaryDataTesterTest:AMFBinaryDataTesterTest;
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
index 11f62e3..a4540e6 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
@@ -18,16 +18,20 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests
{
- import flexUnitTests.observedbugs.*
-
+ import flexUnitTests.observedbugs.*
+
[Suite]
[RunWith("org.flexunit.runners.Suite")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class ObservedBugsTester
{
public function ObservedBugsTester()
{
var arr:Array = [ObservedBugTests];
}
+
public var observedBugsTest1:ObservedBugTests;
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/ReflectionTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/ReflectionTester.as
index 369e763..fd94057 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/ReflectionTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/ReflectionTester.as
@@ -18,10 +18,13 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests
{
- import flexUnitTests.reflection.*;
-
+ import flexUnitTests.reflection.*;
+
[Suite]
[RunWith("org.flexunit.runners.Suite")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class ReflectionTester
{
public function ReflectionTester()
@@ -34,8 +37,8 @@ package flexUnitTests
public var reflectionTesterTest:ReflectionTesterTest;
public var reflectionTesterAliasTest:ReflectionTesterTestAlias;
-
-
- public var reflectionTesterDynamicTest:ReflectionTesterTestDynamic;
+
+
+ public var reflectionTesterDynamicTest:ReflectionTesterTestDynamic;
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/NetworkTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/XMLTester.as
similarity index 80%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/NetworkTester.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/XMLTester.as
index ef8e73b..4c1695e 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/NetworkTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/XMLTester.as
@@ -18,16 +18,19 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests
{
- import flexUnitTests.network.*
-
+ import flexUnitTests.xml.*
+
[Suite]
[RunWith("org.flexunit.runners.Suite")]
- public class NetworkTester
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class XMLTester
{
- public function NetworkTester()
+ public function XMLTester()
{
// for JS, force-link these classes in the output
- var arr:Array = [AMFBinaryDataTesterTest];
+ var arr:Array = [XMLTesterGeneralTest, XMLTesterStringifyTest];
}
// in JS, using a class as a type won't include the class in
@@ -37,7 +40,10 @@ package flexUnitTests
// Is there a reason to use reflection to gather the set
// of tests? I would think an array of tests would wokr
// better and allow you to define order.
- public var amfBinaryDataTesterTest:AMFBinaryDataTesterTest;
-
+
+ public var xmlTesterGeneralTest:XMLTesterGeneralTest;
+
+ public var xmlTesterStringifyTest:XMLTesterStringifyTest;
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/core/ArrayTesterTest.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/core/ArrayTesterTest.as
new file mode 100644
index 0000000..ca42188
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/core/ArrayTesterTest.as
@@ -0,0 +1,162 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.core
+{
+
+
+ import flexunit.framework.Assert;
+ import flexUnitTests.core.support.TestVO;
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class ArrayTesterTest
+ {
+
+ [Before]
+ public function setUp():void
+ {
+ /*items1 = [
+ new TestVO('aB', 0, 'zz'),
+ new TestVO('aA', 0, 'aa'),
+ new TestVO('aC', 1, 'zz'),
+ new TestVO('aa', 1, 'aa'),
+ new TestVO('ab', -1, 'zz'),
+ new TestVO('ac', -1, 'aa')
+ ];
+
+ items2 =
+
+ field1s = [];
+ var i:uint=0, l:uint=items.length;
+ for(;i<l;i++) {
+ field1s.push(items[i].field1);
+ }
+
+ values = [23,-93,-59,-55,41,-29,69,11,33,-71,83,87,27,-39,70,-50,-56,-61,17,-35,-60,-86,-78,-83,-10];
+*/ }
+
+ [After]
+ public function tearDown():void
+ {
+ }
+
+ [BeforeClass]
+ public static function setUpBeforeClass():void
+ {
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ }
+
+ public var items1:Array;
+
+ public var items2:Array;
+
+ public var field1s:Array;
+
+ public var values:Array;
+
+
+ private function _sort(arr:Array,args:Array):void{
+ COMPILE::SWF{
+ arr.sort.apply(arr,args);
+ }
+ COMPILE::JS{
+ import org.apache.royale.utils.Language;
+ args.unshift(arr);
+ Language.sort.apply(null, args);
+ }
+ }
+
+ [Test]
+ public function testSort():void
+ {
+ Assert.assertTrue("Parked, needs more work", true);
+
+ /*import testshim.RoyaleUnitTestRunner;
+ /!*Assert.assertEquals('unexpected starting state',
+ '23,-93,-59,-55,41,-29,69,11,33,-71,83,87,27,-39,70,-50,-56,-61,17,-35,-60,-86,-78,-83,-10',
+ values.toString());*!/
+ Assert.assertEquals('unexpected starting state',
+ 'aB,aA,aC,aa,ab,ac,zA,ZA,zA,ZA,zA,zA,AA,AA',
+ field1s.toString());
+
+ field1s.sort();
+ Assert.assertEquals('unexpected starting state',
+ 'AA,AA,ZA,ZA,aA,aB,aC,aa,ab,ac,zA,zA,zA,zA',
+ field1s.toString());
+
+ RoyaleUnitTestRunner.consoleOut('field1s ' + field1s.toString());
+
+ _sort(field1s, [Array.CASEINSENSITIVE]);
+
+ Assert.assertEquals('unexpected starting state',
+ 'aa,AA,aA,AA,ab,aB,ac,aC,ZA,ZA,zA,zA,zA,zA',
+ field1s.toString());
+
+ _sort(field1s, [Array.DESCENDING]);
+
+ Assert.assertEquals('unexpected starting state',
+ 'zA,zA,zA,zA,ac,ab,aa,aC,aB,aA,ZA,ZA,AA,AA',
+ field1s.toString());
+
+ // field1s.sort(Array.CASEINSENSITIVE);
+
+ RoyaleUnitTestRunner.consoleOut('field1s ' + field1s.toString());
+ _sort(field1s, [Array.DESCENDING|Array.CASEINSENSITIVE]);
+
+ Assert.assertEquals('unexpected starting state',
+ 'zA,zA,zA,zA,ZA,ZA,ac,aC,ab,aB,AA,aA,aa,AA',
+ field1s.toString());
+ RoyaleUnitTestRunner.consoleOut('field1s ' + field1s.toString());*/
+
+ }
+
+
+ [Test]
+ public function testSortOn():void
+ {
+
+ /* Assert.assertEquals('unexpected starting state',
+ 'TestVO [aB]#0 [zz],TestVO [aA]#0 [aa],TestVO [aC]#1 [zz],TestVO [aa]#1 [aa],TestVO [ab]#-1 [zz],TestVO [ac]#-1 [aa],TestVO [zA]#0 [bb],TestVO [ZA]#0 [aa],TestVO [zA]#1 [bb],TestVO [ZA]#1 [aa],TestVO [zA]#-1 [bb],TestVO [zA]#-1 [aa],TestVO [AA]#0 [aa],TestVO [AA]#0 [zz]',
+ items.toString());
+
+ import testshim.RoyaleUnitTestRunner;
+
+ RoyaleUnitTestRunner.consoleOut('items ' + items.toString());
+
+
+
+ items.sortOn('field1',0);
+ Assert.assertEquals('unexpected sortOn result',
+ 'TestVO [AA]#0 [aa],TestVO [AA]#0 [zz],TestVO [ZA]#0 [aa],TestVO [ZA]#-1 [aa],TestVO [ZA]#1 [aa],TestVO [aA]#0 [zz],TestVO [aA]#-1 [zz],TestVO [aA]#-1 [aa],TestVO [aA]#0 [aa],TestVO [aA]#1 [aa],TestVO [aA]#1 [zz],TestVO [zA]#-1 [bb],TestVO [zA]#0 [bb],TestVO [zA]#1 [bb]',
+ items.toString());
+
+
+
+ RoyaleUnitTestRunner.consoleOut('items ' + items.toString());*/
+
+ }
+
+
+ }
+}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/core/BinaryDataTesterTest.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/core/BinaryDataTesterTest.as
index b6613b7..867a103 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/core/BinaryDataTesterTest.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/core/BinaryDataTesterTest.as
@@ -18,605 +18,617 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.core
{
-
-
+
+
import org.apache.royale.utils.Endian;
+
import flexunit.framework.Assert;
+
import org.apache.royale.utils.BinaryData
-
-
+
+
public class BinaryDataTesterTest
- {
-
- [Before]
- public function setUp():void {
- }
-
- [After]
- public function tearDown():void {
- }
-
- [BeforeClass]
- public static function setUpBeforeClass():void {
- }
-
- [AfterClass]
- public static function tearDownAfterClass():void {
- }
-
-
- //util check functions
- private static function bytesMatchExpectedData(bd:BinaryData,expected:Array,offset:int=0):Boolean{
- var len:uint = expected.length;
- var end:uint=offset+len;
- for (var i:int=offset;i<end;i++) {
- var check:uint = bd.readByteAt(i);
- if (expected[i-offset]!=check) {
- // trace('failed at ',i,expected[i-offset],check);
- return false;
- }
- }
- return true;
- }
-
- private static function reversedBytesMatch(bd1:BinaryData,bd2:BinaryData,len:uint,offset:int=0):Boolean{
- var end:uint=offset+len;
- for (var i:int=offset;i<end;i++) {
- if (bd1.readByteAt(i) != bd2.readByteAt(end-1-i)) return false;
- }
- return true;
-
- }
-
-
- [Test]
- public function testBasicPositionAndLength():void
- {
- var ba:BinaryData = new BinaryData();
-
- Assert.assertEquals("new Instance, position", 0, ba.position);
- Assert.assertEquals("new Instance, length", 0, ba.length);
-
- ba.position=100;
- Assert.assertEquals("position change, position", 100, ba.position);
- Assert.assertEquals("position change, length", 0, ba.length);
- Assert.assertEquals("position change, length", 0, ba.bytesAvailable);
-
- ba.length=100;
- Assert.assertEquals("length change, position", 100, ba.position);
- Assert.assertEquals("length change, length", 100, ba.length);
-
- ba.length=50;
- Assert.assertEquals("length change, position", 50, ba.position);
- Assert.assertEquals("length change, length", 50, ba.length);
-
-
- }
-
- [Test]
- public function testAdvancedPositionAndLength():void
- {
- var ba:BinaryData = new BinaryData();
-
- ba.position=100;
- ba.length=100;
-
- ba.writeByteAt(49,255);
- Assert.assertEquals("writeByteAt does not affect position",100, ba.position);
- Assert.assertEquals("writeByteAt (internal) does not affect length",100, ba.length);
-
- ba.readByteAt(48);
- Assert.assertEquals("readByteAt does not affect position",100, ba.position);
- Assert.assertEquals("readByteAt does not affect length",100, ba.length);
-
- ba.writeByteAt(199,255);
- Assert.assertEquals("writeByteAt (beyond length) does affect length",200, ba.length);
- Assert.assertEquals("writeByteAt (beyond length) does not affect position",100, ba.position);
-
- Assert.assertStrictlyEquals("out of range byte read request",0 ,ba.readByteAt(205));
-
- }
-
-
- [Test]
- public function testUTFWritePosition():void
- {
- var ba:BinaryData = new BinaryData();
- ba.writeUTF('This is a test');
- //writeUTF
- Assert.assertEquals("basic post-writeUTF position", 16, ba.position);
- ba=new BinaryData();
- ba.writeUTFBytes('This is a test');
- //writeUTFBytes
- Assert.assertEquals("basic post-writeUTFBytes position", 14, ba.position);
-
- //overlapping
- ba.position=5;
- ba.writeUTFBytes('This is a test');
- Assert.assertEquals("Advanced post-writeUTFBytes position (overlap)", 19, ba.position);
-
- }
-
- [Test]
- public function testBooleanRoundTripping():void
- {
- var ba:BinaryData = new BinaryData();
- ba.writeBoolean(true);
- ba.writeBoolean(false);
- ba.position = 0;
- Assert.assertTrue(ba.readBoolean());
- Assert.assertFalse(ba.readBoolean());
- }
-
- [Test]
- public function testByteRoundTripping():void
- {
- var ba:BinaryData = new BinaryData();
- ba.writeByte(255);
- ba.writeByte(256);
- ba.writeByte(-256);
- ba.writeByte(-257);
- ba.writeByte(-128);
- ba.writeByte(128);
- ba.writeByte(127);
- ba.writeByte(-50);
- ba.writeByte(50);
- ba.position = 0;
-
-
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -1, ba.readByte());
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 0, ba.readByte());
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 0, ba.readByte());
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -1, ba.readByte());
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -128, ba.readByte());
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -128, ba.readByte());
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 127, ba.readByte());
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -50, ba.readByte());
- Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 50, ba.readByte());
- }
-
-
- [Test]
- public function testUnsignedByteRoundTripping():void
- {
- var ba:BinaryData = new BinaryData();
- ba.writeByte(255);
- ba.writeByte(256);
- ba.writeByte(-256);
- ba.writeByte(-257);
- ba.writeByte(-128);
- ba.writeByte(128);
- ba.writeByte(127);
- ba.writeByte(-50);
- ba.writeByte(50);
- ba.position = 0;
- //check read values
-
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 255, ba.readUnsignedByte());
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 0, ba.readUnsignedByte());
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 0, ba.readUnsignedByte());
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 255, ba.readUnsignedByte());
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 128, ba.readUnsignedByte());
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 128, ba.readUnsignedByte());
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 127, ba.readUnsignedByte());
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 206, ba.readUnsignedByte());
- Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 50, ba.readUnsignedByte());
- }
-
-
- [Test]
- public function testBasicEndian():void
- {
-
- var systemEndian:String = Endian.systemEndian;
- //check we have a decisive systemEndian detection
- Assert.assertNotNull(systemEndian );
-
-
- var ba:BinaryData = new BinaryData();
- var defaultEndian:String = ba.endian;
-
- var alternateEndian:String = (defaultEndian == Endian.BIG_ENDIAN) ? Endian.LITTLE_ENDIAN : Endian.BIG_ENDIAN;
- var expected:Object ={};
- expected[Endian.BIG_ENDIAN] = 218038271;
- expected[Endian.LITTLE_ENDIAN] = 4294966796;
- var bytes:Array = [12, 254, 255, 255];
- for each(var byte:uint in bytes) ba.writeByte(byte);
- ba.position = 0;
-
- Assert.assertEquals("testing endian:"+defaultEndian, expected[defaultEndian] , ba.readUnsignedInt());
-
- ba.position = 0;
- ba.endian = alternateEndian;
- var result:uint = ba.readUnsignedInt();
-
- Assert.assertEquals("testing endian:"+alternateEndian, expected[alternateEndian], result);
-
- ba.position = 0;
- ba.endian = defaultEndian;
- Assert.assertEquals("testing endian:"+defaultEndian, int(expected[defaultEndian]), ba.readInt());
-
- ba.position = 0;
- ba.endian = alternateEndian;
- Assert.assertEquals("testing endian:"+alternateEndian, int(expected[alternateEndian]), ba.readInt());
-
- var leBA:BinaryData = new BinaryData();
- leBA.endian = Endian.LITTLE_ENDIAN;
- var beBA:BinaryData = new BinaryData();
- beBA.endian = Endian.BIG_ENDIAN;
- //int writing
- beBA.writeInt(-500);
- leBA.writeInt(-500);
- //check they represent reversed byte sequence
- Assert.assertTrue(reversedBytesMatch(beBA,leBA,4));
- beBA.position=0;
- leBA.position=0;
- //check they each read back to the same uint value
- Assert.assertEquals('big endian',4294966796,beBA.readUnsignedInt());
- Assert.assertEquals('little endian',4294966796,leBA.readUnsignedInt());
-
- beBA.position=0;
- leBA.position=0;
- //uint writing
- beBA.writeUnsignedInt(4294966796);
- leBA.writeUnsignedInt(4294966796);
- //check they represent reversed byte sequence
- Assert.assertTrue(reversedBytesMatch(beBA,leBA,4));
- beBA.position=0;
- leBA.position=0;
- //check they each read back to the same uint value
- Assert.assertEquals('big endian',4294966796,beBA.readUnsignedInt());
- Assert.assertEquals('little endian',4294966796,leBA.readUnsignedInt());
-
-
- beBA.position=0;
- leBA.position=0;
-
- //check they each read back to the same int value
- Assert.assertEquals('big endian',-500,beBA.readInt());
- Assert.assertEquals('little endian',-500,leBA.readInt());
-
-
- beBA.position=0;
- leBA.position=0;
-
- //short writing
- beBA.writeShort(-500);
- leBA.writeShort(-500);
- //check they represent reversed byte sequence
- Assert.assertTrue(reversedBytesMatch(beBA,leBA,2));
- beBA.position=0;
- leBA.position=0;
- //check they each read back to the same uint value
- Assert.assertEquals('big endian',65036,beBA.readUnsignedShort());
- Assert.assertEquals('little endian',65036,leBA.readUnsignedShort());
-
-
- beBA.position=0;
- leBA.position=0;
-
- //check they each read back to the same int value
- Assert.assertEquals('big endian',-500,beBA.readShort());
- Assert.assertEquals('little endian',-500,leBA.readShort());
-
- }
-
-
- [Test]
- public function testUTFRoundtripping():void
- {
-
- //test big-endian round-tripping
- var ba:BinaryData = new BinaryData();
- ba.endian = Endian.BIG_ENDIAN;
- ba.writeUTF('This is a test');
- //writeUTF
- Assert.assertEquals("basic post-writeUTF position", 16, ba.position);
- ba.position = 0;
- Assert.assertEquals("utf big endian round-tripping", 'This is a test', ba.readUTF());
-
- ba = new BinaryData();
- //test little-endian round-tripping
- ba.endian = Endian.LITTLE_ENDIAN;
- ba.writeUTF('This is a test');
- //writeUTF
- Assert.assertEquals("basic post-writeUTF position", 16, ba.position);
- ba.position = 0;
- Assert.assertEquals("utf big endian round-tripping", 'This is a test', ba.readUTF());
-
- }
-
-
- [Test]
- public function testShortRoundTripping():void
- {
- var ba:BinaryData = new BinaryData();
- //test LITTLE_ENDIAN round-tripping
- ba.endian = Endian.LITTLE_ENDIAN;
- ba.writeShort(255);
- ba.writeShort(-50);
- ba.writeShort(50);
- ba.position = 0;
-
- Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 6, ba.length);
- Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 255, ba.readShort());
- Assert.assertEquals("Error testing post writeShort/readShort round-tripping", -50, ba.readShort());
- Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 50, ba.readShort());
-
- //test BIG_ENDIAN round-tripping
-
- ba.position = 0;
- ba.endian = Endian.BIG_ENDIAN ;
- ba.writeShort(255);
- ba.writeShort(-50);
- ba.writeShort(50);
- ba.position = 0;
-
- Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 6, ba.length);
- Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 255, ba.readShort());
- Assert.assertEquals("Error testing post writeShort/readShort round-tripping", -50, ba.readShort());
- Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 50, ba.readShort());
- }
-
-
- [Test]
- public function testUnsignedShortRoundTripping():void
- {
- var ba:BinaryData = new BinaryData();
- //test LITTLE_ENDIAN round-tripping
- ba.endian = Endian.LITTLE_ENDIAN;
- ba.writeShort(255);
- ba.writeShort(-50);
- ba.writeShort(50);
- ba.position = 0;
-
- Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 6, ba.length);
- Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 255, ba.readUnsignedShort());
- Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 65486, ba.readUnsignedShort());
- Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 50, ba.readUnsignedShort());
-
- //test BIG_ENDIAN round-tripping
-
- ba.position = 0;
- ba.endian = Endian.BIG_ENDIAN ;
- ba.writeShort(255);
- ba.writeShort(-50);
- ba.writeShort(50);
- ba.position = 0;
-
- Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 6, ba.length);
- Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 255, ba.readUnsignedShort());
- Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 65486, ba.readUnsignedShort());
- Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 50, ba.readUnsignedShort());
- }
-
- [Test]
- public function testIntRoundTripping():void
- {
- var ba:BinaryData = new BinaryData();
- //test LITTLE_ENDIAN round-tripping
- ba.endian = Endian.LITTLE_ENDIAN;
- ba.writeInt(65536);
- ba.writeInt(-50);
- ba.writeInt(50);
- ba.position = 0;
-
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length);
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 65536, ba.readInt());
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", -50, ba.readInt());
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readInt());
-
- //test BIG_ENDIAN round-tripping
-
- ba.position = 0;
- ba.endian = Endian.BIG_ENDIAN ;
- ba.writeInt(65536);
- ba.writeInt(-50);
- ba.writeInt(50);
- ba.position = 0;
-
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length);
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 65536, ba.readInt());
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", -50, ba.readInt());
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readInt());
- }
-
-
- [Test]
- public function testUnsignedIntRoundTripping():void
- {
- var ba:BinaryData = new BinaryData();
- //test LITTLE_ENDIAN round-tripping
- ba.endian = Endian.LITTLE_ENDIAN;
- ba.writeUnsignedInt(65536);
- ba.writeUnsignedInt(-50);
- ba.writeUnsignedInt(50);
- ba.position = 0;
-
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length);
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping",65536, ba.readUnsignedInt());
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 4294967246, ba.readUnsignedInt());
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readUnsignedInt());
-
- //test BIG_ENDIAN round-tripping
-
- ba.position = 0;
- ba.endian = Endian.BIG_ENDIAN ;
- ba.writeUnsignedInt(65536);
- ba.writeUnsignedInt(-50);
- ba.writeUnsignedInt(50);
- ba.position = 0;
-
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length);
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping",65536, ba.readUnsignedInt());
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 4294967246, ba.readUnsignedInt());
- Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readUnsignedInt());
- }
-
- [Test]
- public function testFloatRoundTripping():void
- {
- var ble:BinaryData = new BinaryData();
- //test LITTLE_ENDIAN round-tripping
- ble.endian = Endian.LITTLE_ENDIAN;
- ble.writeFloat(86.54);
-
-
- Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, ble.length);
- Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, ble.position);
- //check bytes to account for precision loss between double and float comparisons
- Assert.assertTrue("Error testing post writeFloat/readFloat round-tripping", bytesMatchExpectedData(ble,[123,20,173,66]));
-
- var bbe:BinaryData = new BinaryData();
- //test BIG_ENDIAN round-tripping
- bbe.endian = Endian.BIG_ENDIAN;
- bbe.writeFloat(86.54);
-
-
- Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, bbe.length);
- Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, bbe.position);
- //check bytes to account for precision loss between double and float comparisons
- Assert.assertTrue("Error testing post writeFloat/readFloat round-tripping", bytesMatchExpectedData(bbe,[66,173,20,123]));
-
-
- }
-
-
- [Test]
- public function testDoubleRoundTripping():void
- {
-
- var ble:BinaryData = new BinaryData();
- //test LITTLE_ENDIAN round-tripping
- ble.endian = Endian.LITTLE_ENDIAN;
- ble.writeDouble(86.54);
-
-
- Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.length);
- Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.position);
-
- //check bytes
- Assert.assertTrue("Error testing post writeDouble/readDouble round-tripping", bytesMatchExpectedData(ble,[195,245,40,92,143,162,85,64]));
-
- var bbe:BinaryData = new BinaryData();
- //test BIG_ENDIAN round-tripping
- bbe.endian = Endian.BIG_ENDIAN;
- bbe.writeDouble(86.54);
-
-
- Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.length);
- Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.position);
- //check bytes
-
- Assert.assertTrue("Error testing post writeDouble/readDouble round-tripping", bytesMatchExpectedData(bbe,[64,85,162,143,92,40,245,195]));
-
-
- ble.position = 0;
- bbe.position = 0;
- Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 86.54, bbe.readDouble());
- Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 86.54, ble.readDouble());
-
- Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.position);
- Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.position);
-
- }
-
-
-
- [Test]
- public function testWriteBinaryData():void
- {
- var ba:BinaryData = new BinaryData();
- for (var i:int=0;i<50;i++) ba.writeByte(i);
-
-
- var newBa:BinaryData = new BinaryData();
- newBa.writeBinaryData(ba);
-
- Assert.assertEquals("BinaryData writeBinaryData: length", 50, newBa.length);
- Assert.assertEquals("BinaryData writeBinaryData: position", 50, newBa.position);
-
- for (i=0;i<50;i++) {
- Assert.assertEquals("BinaryData writeBinaryData: content check", i, newBa.array[i]);
- }
-
-
-
- }
-
- [Test]
- public function testReadBinaryData():void
- {
- var ba:BinaryData = new BinaryData();
- for (var i:int=0;i<50;i++) ba.writeByte(i);
- ba.position=0;
- var newBa:BinaryData = new BinaryData();
-
- ba.readBinaryData(newBa,5,10);
- Assert.assertEquals("BinaryData readBinaryData: position", 10, ba.position);
- Assert.assertEquals("BinaryData readBinaryData: length", 15, newBa.length);
- Assert.assertEquals("BinaryData readBinaryData: position", 0, newBa.position);
- var expected:Array = [0,0,0,0,0,0,1,2,3,4,5,6,7,8,9];
- for (i=0;i<15;i++) {
- Assert.assertEquals("BinaryData readBinaryData: content check", expected[i], newBa.array[i]);
- }
- newBa.position = 15;
- ba.readBinaryData(newBa,5,10);
- expected = [0,0,0,0,0,10,11,12,13,14,15,16,17,18,19];
- for (i=0;i<15;i++) {
- Assert.assertEquals("BinaryData readBinaryData: content check", expected[i], newBa.array[i]);
- }
- Assert.assertEquals("BinaryData readBinaryData: length", 15, newBa.length);
- Assert.assertEquals("BinaryData readBinaryData: position", 15, newBa.position);
- }
-
- [Test]
- public function testReadOddBytes():void
- {
- var ba:BinaryData = new BinaryData();
- for (var i:int=0;i<50;i++) ba.writeByte(i);
- ba.endian = Endian.BIG_ENDIAN;
- ba.position=0;
- Assert.assertEquals("BinaryData readByte: should be 0", 0, ba.readByte());
- Assert.assertEquals("BinaryData readShort: should be 258", 258, ba.readShort());
- Assert.assertEquals("BinaryData readInt: should be 50595078", 50595078, ba.readInt());
- ba.endian = Endian.LITTLE_ENDIAN;
- ba.position=0;
- Assert.assertEquals("BinaryData readByte: should be 0", 0, ba.readByte());
- Assert.assertEquals("BinaryData readShort: should be 513", 513, ba.readShort());
- Assert.assertEquals("BinaryData readInt: should be 100992003", 100992003, ba.readInt());
-
- ba = new BinaryData();
- ba.writeByte(25);
- ba.writeShort(65535);
- ba.writeUnsignedInt(4294967295);
- ba.position = 0;
- Assert.assertEquals("BinaryData readByte: should be 25", 25, ba.readByte());
- Assert.assertEquals("BinaryData readUnsignedShort: should be 65535", 65535, ba.readUnsignedShort());
- Assert.assertEquals("BinaryData readInt: should be 4294967295", 4294967295, ba.readUnsignedInt());
-
- ba = new BinaryData();
- ba.writeByte(-25);
- ba.writeShort(-1029);
- ba.writeInt(-131072);
- ba.writeFloat(12345.2);
- ba.writeDouble(3.1415927410);
- ba.position = 0;
- Assert.assertEquals("BinaryData readByte: should be -25", -25, ba.readByte());
- Assert.assertEquals("BinaryData readShort: should be -1029", -1029, ba.readShort());
- Assert.assertEquals("BinaryData readInt: should be -131072", -131072, ba.readInt());
- Assert.assertEquals("BinaryData readFloat: should be 12345.2", 12345.2, Math.round(ba.readFloat() * 100)/100);
- Assert.assertEquals("BinaryData readDouble: should be 3.1415927410", 3.1415927410, ba.readDouble());
- ba = new BinaryData()
- ba.writeFloat(12345.2);
- ba.position = 0;
- Assert.assertEquals("BinaryData readFloat: should be 12345.2", 12345.2, Math.round(ba.readFloat() * 100)/100);
- ba.position = 0;
- ba.writeDouble(3.1415927410);
- ba.position = 0;
- Assert.assertEquals("BinaryData readDouble: should be 3.1415927410", 3.1415927410, ba.readDouble());
- }
-
-
- }
+ {
+
+ [Before]
+ public function setUp():void
+ {
+ }
+
+ [After]
+ public function tearDown():void
+ {
+ }
+
+ [BeforeClass]
+ public static function setUpBeforeClass():void
+ {
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ }
+
+
+ //util check functions
+ private static function bytesMatchExpectedData(bd:BinaryData, expected:Array, offset:int = 0):Boolean
+ {
+ var len:uint = expected.length;
+ var end:uint = offset + len;
+ for (var i:int = offset; i < end; i++)
+ {
+ var check:uint = bd.readByteAt(i);
+ if (expected[i - offset] != check)
+ {
+ // trace('failed at ',i,expected[i-offset],check);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static function reversedBytesMatch(bd1:BinaryData, bd2:BinaryData, len:uint, offset:int = 0):Boolean
+ {
+ var end:uint = offset + len;
+ for (var i:int = offset; i < end; i++)
+ {
+ if (bd1.readByteAt(i) != bd2.readByteAt(end - 1 - i)) return false;
+ }
+ return true;
+
+ }
+
+
+ [Test]
+ public function testBasicPositionAndLength():void
+ {
+ var ba:BinaryData = new BinaryData();
+
+ Assert.assertEquals("new Instance, position", 0, ba.position);
+ Assert.assertEquals("new Instance, length", 0, ba.length);
+
+ ba.position = 100;
+ Assert.assertEquals("position change, position", 100, ba.position);
+ Assert.assertEquals("position change, length", 0, ba.length);
+ Assert.assertEquals("position change, length", 0, ba.bytesAvailable);
+
+ ba.length = 100;
+ Assert.assertEquals("length change, position", 100, ba.position);
+ Assert.assertEquals("length change, length", 100, ba.length);
+
+ ba.length = 50;
+ Assert.assertEquals("length change, position", 50, ba.position);
+ Assert.assertEquals("length change, length", 50, ba.length);
+
+
+ }
+
+ [Test]
+ public function testAdvancedPositionAndLength():void
+ {
+ var ba:BinaryData = new BinaryData();
+
+ ba.position = 100;
+ ba.length = 100;
+
+ ba.writeByteAt(49, 255);
+ Assert.assertEquals("writeByteAt does not affect position", 100, ba.position);
+ Assert.assertEquals("writeByteAt (internal) does not affect length", 100, ba.length);
+
+ ba.readByteAt(48);
+ Assert.assertEquals("readByteAt does not affect position", 100, ba.position);
+ Assert.assertEquals("readByteAt does not affect length", 100, ba.length);
+
+ ba.writeByteAt(199, 255);
+ Assert.assertEquals("writeByteAt (beyond length) does affect length", 200, ba.length);
+ Assert.assertEquals("writeByteAt (beyond length) does not affect position", 100, ba.position);
+
+ Assert.assertStrictlyEquals("out of range byte read request", 0, ba.readByteAt(205));
+
+ }
+
+
+ [Test]
+ public function testUTFWritePosition():void
+ {
+ var ba:BinaryData = new BinaryData();
+ ba.writeUTF('This is a test');
+ //writeUTF
+ Assert.assertEquals("basic post-writeUTF position", 16, ba.position);
+ ba = new BinaryData();
+ ba.writeUTFBytes('This is a test');
+ //writeUTFBytes
+ Assert.assertEquals("basic post-writeUTFBytes position", 14, ba.position);
+
+ //overlapping
+ ba.position = 5;
+ ba.writeUTFBytes('This is a test');
+ Assert.assertEquals("Advanced post-writeUTFBytes position (overlap)", 19, ba.position);
+
+ }
+
+ [Test]
+ public function testBooleanRoundTripping():void
+ {
+ var ba:BinaryData = new BinaryData();
+ ba.writeBoolean(true);
+ ba.writeBoolean(false);
+ ba.position = 0;
+ Assert.assertTrue(ba.readBoolean());
+ Assert.assertFalse(ba.readBoolean());
+ }
+
+ [Test]
+ public function testByteRoundTripping():void
+ {
+ var ba:BinaryData = new BinaryData();
+ ba.writeByte(255);
+ ba.writeByte(256);
+ ba.writeByte(-256);
+ ba.writeByte(-257);
+ ba.writeByte(-128);
+ ba.writeByte(128);
+ ba.writeByte(127);
+ ba.writeByte(-50);
+ ba.writeByte(50);
+ ba.position = 0;
+
+
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -1, ba.readByte());
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 0, ba.readByte());
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 0, ba.readByte());
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -1, ba.readByte());
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -128, ba.readByte());
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -128, ba.readByte());
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 127, ba.readByte());
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", -50, ba.readByte());
+ Assert.assertEquals("Error testing post writeByte/readByte round-tripping", 50, ba.readByte());
+ }
+
+
+ [Test]
+ public function testUnsignedByteRoundTripping():void
+ {
+ var ba:BinaryData = new BinaryData();
+ ba.writeByte(255);
+ ba.writeByte(256);
+ ba.writeByte(-256);
+ ba.writeByte(-257);
+ ba.writeByte(-128);
+ ba.writeByte(128);
+ ba.writeByte(127);
+ ba.writeByte(-50);
+ ba.writeByte(50);
+ ba.position = 0;
+ //check read values
+
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 255, ba.readUnsignedByte());
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 0, ba.readUnsignedByte());
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 0, ba.readUnsignedByte());
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 255, ba.readUnsignedByte());
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 128, ba.readUnsignedByte());
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 128, ba.readUnsignedByte());
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 127, ba.readUnsignedByte());
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 206, ba.readUnsignedByte());
+ Assert.assertEquals("Error testing post writeByte/readUnsignedByte round-tripping", 50, ba.readUnsignedByte());
+ }
+
+
+ [Test]
+ public function testBasicEndian():void
+ {
+
+ var systemEndian:String = Endian.systemEndian;
+ //check we have a decisive systemEndian detection
+ Assert.assertNotNull(systemEndian);
+
+
+ var ba:BinaryData = new BinaryData();
+ var defaultEndian:String = ba.endian;
+
+ var alternateEndian:String = (defaultEndian == Endian.BIG_ENDIAN) ? Endian.LITTLE_ENDIAN : Endian.BIG_ENDIAN;
+ var expected:Object = {};
+ expected[Endian.BIG_ENDIAN] = 218038271;
+ expected[Endian.LITTLE_ENDIAN] = 4294966796;
+ var bytes:Array = [12, 254, 255, 255];
+ for each(var byte:uint in bytes) ba.writeByte(byte);
+ ba.position = 0;
+
+ Assert.assertEquals("testing endian:" + defaultEndian, expected[defaultEndian], ba.readUnsignedInt());
+
+ ba.position = 0;
+ ba.endian = alternateEndian;
+ var result:uint = ba.readUnsignedInt();
+
+ Assert.assertEquals("testing endian:" + alternateEndian, expected[alternateEndian], result);
+
+ ba.position = 0;
+ ba.endian = defaultEndian;
+ Assert.assertEquals("testing endian:" + defaultEndian, int(expected[defaultEndian]), ba.readInt());
+
+ ba.position = 0;
+ ba.endian = alternateEndian;
+ Assert.assertEquals("testing endian:" + alternateEndian, int(expected[alternateEndian]), ba.readInt());
+
+ var leBA:BinaryData = new BinaryData();
+ leBA.endian = Endian.LITTLE_ENDIAN;
+ var beBA:BinaryData = new BinaryData();
+ beBA.endian = Endian.BIG_ENDIAN;
+ //int writing
+ beBA.writeInt(-500);
+ leBA.writeInt(-500);
+ //check they represent reversed byte sequence
+ Assert.assertTrue(reversedBytesMatch(beBA, leBA, 4));
+ beBA.position = 0;
+ leBA.position = 0;
+ //check they each read back to the same uint value
+ Assert.assertEquals('big endian', 4294966796, beBA.readUnsignedInt());
+ Assert.assertEquals('little endian', 4294966796, leBA.readUnsignedInt());
+
+ beBA.position = 0;
+ leBA.position = 0;
+ //uint writing
+ beBA.writeUnsignedInt(4294966796);
+ leBA.writeUnsignedInt(4294966796);
+ //check they represent reversed byte sequence
+ Assert.assertTrue(reversedBytesMatch(beBA, leBA, 4));
+ beBA.position = 0;
+ leBA.position = 0;
+ //check they each read back to the same uint value
+ Assert.assertEquals('big endian', 4294966796, beBA.readUnsignedInt());
+ Assert.assertEquals('little endian', 4294966796, leBA.readUnsignedInt());
+
+
+ beBA.position = 0;
+ leBA.position = 0;
+
+ //check they each read back to the same int value
+ Assert.assertEquals('big endian', -500, beBA.readInt());
+ Assert.assertEquals('little endian', -500, leBA.readInt());
+
+
+ beBA.position = 0;
+ leBA.position = 0;
+
+ //short writing
+ beBA.writeShort(-500);
+ leBA.writeShort(-500);
+ //check they represent reversed byte sequence
+ Assert.assertTrue(reversedBytesMatch(beBA, leBA, 2));
+ beBA.position = 0;
+ leBA.position = 0;
+ //check they each read back to the same uint value
+ Assert.assertEquals('big endian', 65036, beBA.readUnsignedShort());
+ Assert.assertEquals('little endian', 65036, leBA.readUnsignedShort());
+
+
+ beBA.position = 0;
+ leBA.position = 0;
+
+ //check they each read back to the same int value
+ Assert.assertEquals('big endian', -500, beBA.readShort());
+ Assert.assertEquals('little endian', -500, leBA.readShort());
+
+ }
+
+
+ [Test]
+ public function testUTFRoundtripping():void
+ {
+
+ //test big-endian round-tripping
+ var ba:BinaryData = new BinaryData();
+ ba.endian = Endian.BIG_ENDIAN;
+ ba.writeUTF('This is a test');
+ //writeUTF
+ Assert.assertEquals("basic post-writeUTF position", 16, ba.position);
+ ba.position = 0;
+ Assert.assertEquals("utf big endian round-tripping", 'This is a test', ba.readUTF());
+
+ ba = new BinaryData();
+ //test little-endian round-tripping
+ ba.endian = Endian.LITTLE_ENDIAN;
+ ba.writeUTF('This is a test');
+ //writeUTF
+ Assert.assertEquals("basic post-writeUTF position", 16, ba.position);
+ ba.position = 0;
+ Assert.assertEquals("utf big endian round-tripping", 'This is a test', ba.readUTF());
+
+ }
+
+
+ [Test]
+ public function testShortRoundTripping():void
+ {
+ var ba:BinaryData = new BinaryData();
+ //test LITTLE_ENDIAN round-tripping
+ ba.endian = Endian.LITTLE_ENDIAN;
+ ba.writeShort(255);
+ ba.writeShort(-50);
+ ba.writeShort(50);
+ ba.position = 0;
+
+ Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 6, ba.length);
+ Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 255, ba.readShort());
+ Assert.assertEquals("Error testing post writeShort/readShort round-tripping", -50, ba.readShort());
+ Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 50, ba.readShort());
+
+ //test BIG_ENDIAN round-tripping
+
+ ba.position = 0;
+ ba.endian = Endian.BIG_ENDIAN;
+ ba.writeShort(255);
+ ba.writeShort(-50);
+ ba.writeShort(50);
+ ba.position = 0;
+
+ Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 6, ba.length);
+ Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 255, ba.readShort());
+ Assert.assertEquals("Error testing post writeShort/readShort round-tripping", -50, ba.readShort());
+ Assert.assertEquals("Error testing post writeShort/readShort round-tripping", 50, ba.readShort());
+ }
+
+
+ [Test]
+ public function testUnsignedShortRoundTripping():void
+ {
+ var ba:BinaryData = new BinaryData();
+ //test LITTLE_ENDIAN round-tripping
+ ba.endian = Endian.LITTLE_ENDIAN;
+ ba.writeShort(255);
+ ba.writeShort(-50);
+ ba.writeShort(50);
+ ba.position = 0;
+
+ Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 6, ba.length);
+ Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 255, ba.readUnsignedShort());
+ Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 65486, ba.readUnsignedShort());
+ Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 50, ba.readUnsignedShort());
+
+ //test BIG_ENDIAN round-tripping
+
+ ba.position = 0;
+ ba.endian = Endian.BIG_ENDIAN;
+ ba.writeShort(255);
+ ba.writeShort(-50);
+ ba.writeShort(50);
+ ba.position = 0;
+
+ Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 6, ba.length);
+ Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 255, ba.readUnsignedShort());
+ Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 65486, ba.readUnsignedShort());
+ Assert.assertEquals("Error testing post unsigned writeShort/readShort round-tripping", 50, ba.readUnsignedShort());
+ }
+
+ [Test]
+ public function testIntRoundTripping():void
+ {
+ var ba:BinaryData = new BinaryData();
+ //test LITTLE_ENDIAN round-tripping
+ ba.endian = Endian.LITTLE_ENDIAN;
+ ba.writeInt(65536);
+ ba.writeInt(-50);
+ ba.writeInt(50);
+ ba.position = 0;
+
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length);
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 65536, ba.readInt());
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", -50, ba.readInt());
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readInt());
+
+ //test BIG_ENDIAN round-tripping
+
+ ba.position = 0;
+ ba.endian = Endian.BIG_ENDIAN;
+ ba.writeInt(65536);
+ ba.writeInt(-50);
+ ba.writeInt(50);
+ ba.position = 0;
+
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length);
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 65536, ba.readInt());
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", -50, ba.readInt());
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readInt());
+ }
+
+
+ [Test]
+ public function testUnsignedIntRoundTripping():void
+ {
+ var ba:BinaryData = new BinaryData();
+ //test LITTLE_ENDIAN round-tripping
+ ba.endian = Endian.LITTLE_ENDIAN;
+ ba.writeUnsignedInt(65536);
+ ba.writeUnsignedInt(-50);
+ ba.writeUnsignedInt(50);
+ ba.position = 0;
+
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length);
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 65536, ba.readUnsignedInt());
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 4294967246, ba.readUnsignedInt());
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readUnsignedInt());
+
+ //test BIG_ENDIAN round-tripping
+
+ ba.position = 0;
+ ba.endian = Endian.BIG_ENDIAN;
+ ba.writeUnsignedInt(65536);
+ ba.writeUnsignedInt(-50);
+ ba.writeUnsignedInt(50);
+ ba.position = 0;
+
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 12, ba.length);
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 65536, ba.readUnsignedInt());
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 4294967246, ba.readUnsignedInt());
+ Assert.assertEquals("Error testing post writeInt/readInt round-tripping", 50, ba.readUnsignedInt());
+ }
+
+ [Test]
+ public function testFloatRoundTripping():void
+ {
+ var ble:BinaryData = new BinaryData();
+ //test LITTLE_ENDIAN round-tripping
+ ble.endian = Endian.LITTLE_ENDIAN;
+ ble.writeFloat(86.54);
+
+
+ Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, ble.length);
+ Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, ble.position);
+ //check bytes to account for precision loss between double and float comparisons
+ Assert.assertTrue("Error testing post writeFloat/readFloat round-tripping", bytesMatchExpectedData(ble, [123, 20, 173, 66]));
+
+ var bbe:BinaryData = new BinaryData();
+ //test BIG_ENDIAN round-tripping
+ bbe.endian = Endian.BIG_ENDIAN;
+ bbe.writeFloat(86.54);
+
+
+ Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, bbe.length);
+ Assert.assertEquals("Error testing post writeFloat/readFloat round-tripping", 4, bbe.position);
+ //check bytes to account for precision loss between double and float comparisons
+ Assert.assertTrue("Error testing post writeFloat/readFloat round-tripping", bytesMatchExpectedData(bbe, [66, 173, 20, 123]));
+
+
+ }
+
+
+ [Test]
+ public function testDoubleRoundTripping():void
+ {
+
+ var ble:BinaryData = new BinaryData();
+ //test LITTLE_ENDIAN round-tripping
+ ble.endian = Endian.LITTLE_ENDIAN;
+ ble.writeDouble(86.54);
+
+
+ Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.length);
+ Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.position);
+
+ //check bytes
+ Assert.assertTrue("Error testing post writeDouble/readDouble round-tripping", bytesMatchExpectedData(ble, [195, 245, 40, 92, 143, 162, 85, 64]));
+
+ var bbe:BinaryData = new BinaryData();
+ //test BIG_ENDIAN round-tripping
+ bbe.endian = Endian.BIG_ENDIAN;
+ bbe.writeDouble(86.54);
+
+
+ Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.length);
+ Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.position);
+ //check bytes
+
+ Assert.assertTrue("Error testing post writeDouble/readDouble round-tripping", bytesMatchExpectedData(bbe, [64, 85, 162, 143, 92, 40, 245, 195]));
+
+
+ ble.position = 0;
+ bbe.position = 0;
+ Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 86.54, bbe.readDouble());
+ Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 86.54, ble.readDouble());
+
+ Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, bbe.position);
+ Assert.assertEquals("Error testing post writeDouble/readDouble round-tripping", 8, ble.position);
+
+ }
+
+
+ [Test]
+ public function testWriteBinaryData():void
+ {
+ var ba:BinaryData = new BinaryData();
+ for (var i:int = 0; i < 50; i++) ba.writeByte(i);
+
+
+ var newBa:BinaryData = new BinaryData();
+ newBa.writeBinaryData(ba);
+
+ Assert.assertEquals("BinaryData writeBinaryData: length", 50, newBa.length);
+ Assert.assertEquals("BinaryData writeBinaryData: position", 50, newBa.position);
+
+ for (i = 0; i < 50; i++)
+ {
+ Assert.assertEquals("BinaryData writeBinaryData: content check", i, newBa.array[i]);
+ }
+
+
+ }
+
+ [Test]
+ public function testReadBinaryData():void
+ {
+ var ba:BinaryData = new BinaryData();
+ for (var i:int = 0; i < 50; i++) ba.writeByte(i);
+ ba.position = 0;
+ var newBa:BinaryData = new BinaryData();
+
+ ba.readBinaryData(newBa, 5, 10);
+ Assert.assertEquals("BinaryData readBinaryData: position", 10, ba.position);
+ Assert.assertEquals("BinaryData readBinaryData: length", 15, newBa.length);
+ Assert.assertEquals("BinaryData readBinaryData: position", 0, newBa.position);
+ var expected:Array = [0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ for (i = 0; i < 15; i++)
+ {
+ Assert.assertEquals("BinaryData readBinaryData: content check", expected[i], newBa.array[i]);
+ }
+ newBa.position = 15;
+ ba.readBinaryData(newBa, 5, 10);
+ expected = [0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
+ for (i = 0; i < 15; i++)
+ {
+ Assert.assertEquals("BinaryData readBinaryData: content check", expected[i], newBa.array[i]);
+ }
+ Assert.assertEquals("BinaryData readBinaryData: length", 15, newBa.length);
+ Assert.assertEquals("BinaryData readBinaryData: position", 15, newBa.position);
+ }
+
+ [Test]
+ public function testReadOddBytes():void
+ {
+ var ba:BinaryData = new BinaryData();
+ for (var i:int = 0; i < 50; i++) ba.writeByte(i);
+ ba.endian = Endian.BIG_ENDIAN;
+ ba.position = 0;
+ Assert.assertEquals("BinaryData readByte: should be 0", 0, ba.readByte());
+ Assert.assertEquals("BinaryData readShort: should be 258", 258, ba.readShort());
+ Assert.assertEquals("BinaryData readInt: should be 50595078", 50595078, ba.readInt());
+ ba.endian = Endian.LITTLE_ENDIAN;
+ ba.position = 0;
+ Assert.assertEquals("BinaryData readByte: should be 0", 0, ba.readByte());
+ Assert.assertEquals("BinaryData readShort: should be 513", 513, ba.readShort());
+ Assert.assertEquals("BinaryData readInt: should be 100992003", 100992003, ba.readInt());
+
+ ba = new BinaryData();
+ ba.writeByte(25);
+ ba.writeShort(65535);
+ ba.writeUnsignedInt(4294967295);
+ ba.position = 0;
+ Assert.assertEquals("BinaryData readByte: should be 25", 25, ba.readByte());
+ Assert.assertEquals("BinaryData readUnsignedShort: should be 65535", 65535, ba.readUnsignedShort());
+ Assert.assertEquals("BinaryData readInt: should be 4294967295", 4294967295, ba.readUnsignedInt());
+
+ ba = new BinaryData();
+ ba.writeByte(-25);
+ ba.writeShort(-1029);
+ ba.writeInt(-131072);
+ ba.writeFloat(12345.2);
+ ba.writeDouble(3.1415927410);
+ ba.position = 0;
+ Assert.assertEquals("BinaryData readByte: should be -25", -25, ba.readByte());
+ Assert.assertEquals("BinaryData readShort: should be -1029", -1029, ba.readShort());
+ Assert.assertEquals("BinaryData readInt: should be -131072", -131072, ba.readInt());
+ Assert.assertEquals("BinaryData readFloat: should be 12345.2", 12345.2, Math.round(ba.readFloat() * 100) / 100);
+ Assert.assertEquals("BinaryData readDouble: should be 3.1415927410", 3.1415927410, ba.readDouble());
+ ba = new BinaryData()
+ ba.writeFloat(12345.2);
+ ba.position = 0;
+ Assert.assertEquals("BinaryData readFloat: should be 12345.2", 12345.2, Math.round(ba.readFloat() * 100) / 100);
+ ba.position = 0;
+ ba.writeDouble(3.1415927410);
+ ba.position = 0;
+ Assert.assertEquals("BinaryData readDouble: should be 3.1415927410", 3.1415927410, ba.readDouble());
+ }
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/core/MD5Test.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/core/MD5Test.as
index 20dc46f..0c154cf 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/core/MD5Test.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/core/MD5Test.as
@@ -23,7 +23,7 @@ package flexUnitTests.core
import org.apache.royale.utils.MD5;
public class MD5Test
- {
+ {
[Before]
public function setUp():void
{
@@ -47,9 +47,9 @@ package flexUnitTests.core
[Test]
public function testHash():void
{
- Assert.assertEquals("Error testing foobaz", "80338e79d2ca9b9c090ebaaa2ef293c7",MD5.hash("foobaz"));
- Assert.assertEquals("Error testing bazfoo", "b6a013d5e2c00f894584ad577249dbc7",MD5.hash("bazfoo"));
- Assert.assertEquals("Error testing password1234", "bdc87b9c894da5168059e00ebffb9077",MD5.hash("password1234"));
- }
+ Assert.assertEquals("Error testing foobaz", "80338e79d2ca9b9c090ebaaa2ef293c7", MD5.hash("foobaz"));
+ Assert.assertEquals("Error testing bazfoo", "b6a013d5e2c00f894584ad577249dbc7", MD5.hash("bazfoo"));
+ Assert.assertEquals("Error testing password1234", "bdc87b9c894da5168059e00ebffb9077", MD5.hash("password1234"));
+ }
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/core/StrandTesterTest.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/core/StrandTesterTest.as
index 4151dc8..8d09d33 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/core/StrandTesterTest.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/core/StrandTesterTest.as
@@ -23,7 +23,7 @@ package flexUnitTests.core
import org.apache.royale.core.Strand;
public class StrandTesterTest
- {
+ {
[Before]
public function setUp():void
{
@@ -49,7 +49,7 @@ package flexUnitTests.core
{
var strand:Strand = new Strand();
strand.id = "foo";
- Assert.assertEquals("Error testing Srand.id", "foo",strand.id);
- }
+ Assert.assertEquals("Error testing Srand.id", "foo", strand.id);
+ }
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterIntUint.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterIntUint.as
new file mode 100644
index 0000000..90f99ca
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterIntUint.as
@@ -0,0 +1,168 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.language
+{
+
+
+ import flexunit.framework.Assert;
+
+ import flexUnitTests.language.support.*;
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class LanguageTesterIntUint
+ {
+
+ public static var isJS:Boolean;
+
+ [BeforeClass]
+ public static function setUpBeforeClass():void
+ {
+ var js:Boolean;
+ COMPILE::JS {
+ js = true;
+ }
+ isJS = js;
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ }
+
+ [Before]
+ public function setUp():void
+ {
+
+ }
+
+ [After]
+ public function tearDown():void
+ {
+ }
+
+
+ [Test]
+ public function testNumerics():void
+ {
+ var val1:Number = 2.5;
+ var val2:Number = 2;
+ var var3:String = '';
+ var var4:String = '0';
+ var var5:String = '2';
+
+ var clazz:Class = int;
+ var intVal:int = (val1 as int);
+ Assert.assertTrue('Unexpected int check', intVal == 0);
+
+ intVal = (var3 as int);
+ Assert.assertTrue('Unexpected int check', intVal == 0);
+ intVal = (var4 as int);
+ Assert.assertTrue('Unexpected int check', intVal == 0);
+ intVal = (var5 as int);
+ Assert.assertTrue('Unexpected int check', intVal == 0);
+
+ intVal = int(var3);
+ Assert.assertTrue('Unexpected int check', intVal == 0);
+ intVal = int(var4);
+ Assert.assertTrue('Unexpected int check', intVal == 0);
+ intVal = int(var5);
+ Assert.assertTrue('Unexpected int check', intVal == 2);
+
+ intVal = new int(var3);
+ Assert.assertTrue('Unexpected int check', intVal == 0);
+ intVal = new int(var4);
+ Assert.assertTrue('Unexpected int check', intVal == 0);
+ intVal = new int(var5);
+ Assert.assertTrue('Unexpected int check', intVal == 2);
+
+
+ Assert.assertFalse('int check should be false', val1 is int);
+ Assert.assertTrue('int check should be true', val2 is int);
+
+ Assert.assertFalse('uint check should be false', val1 is uint);
+ Assert.assertTrue('uint check should be true', val2 is uint);
+
+ var dyn:* = new clazz();
+
+ Assert.assertTrue('Unexpected int check', dyn == 0);
+ Assert.assertTrue('Unexpected int check', dyn === 0);
+
+
+ Assert.assertTrue('random check', int === int);
+
+ Assert.assertTrue('Unexpected int check', new clazz(3.5) == 3);
+
+ Assert.assertFalse('Unexpected int check', dyn !== 0);
+ dyn = new clazz(3.5);
+ intVal = dyn;
+ Assert.assertTrue('Unexpected int check', intVal === 3);
+ Assert.assertTrue('Unexpected int check', new clazz(3.5) === 3);
+
+ //extra indirection
+ var dynInt:* = var5;
+
+ Assert.assertFalse('Unexpected int check', dynInt is clazz);
+ Assert.assertNull('Unexpected int check', dynInt as clazz);
+ Assert.assertTrue('Unexpected int check', clazz(dynInt) === 2);
+ }
+
+
+ [Test]
+ public function testUntypedMath():void
+ {
+ var val:int = 30;
+ var c:Class = int;
+ var untyped:* = val;
+ var untyped2:* = new c(30);
+ var untyped3:Object = new c(30);
+ Assert.assertTrue('Unexpected int check', untyped3 == 30);
+ Assert.assertTrue('Unexpected int check', untyped3 === 30);
+
+ val += 1.5;
+ untyped += 1.5;
+ untyped2 += 1.5;
+ Assert.assertTrue('Unexpected int check', val == 31);
+ Assert.assertTrue('Unexpected int check', val === 31);
+
+ Assert.assertTrue('Unexpected int check', untyped == 31.5);
+ Assert.assertTrue('Unexpected int check', untyped === 31.5);
+
+ Assert.assertTrue('Unexpected int check', untyped2 == 31.5);
+ Assert.assertTrue('Unexpected int check', untyped2 === 31.5);
+
+ untyped = new Number(30);
+ Assert.assertTrue('Unexpected Number check', untyped == 30);
+ Assert.assertTrue('Unexpected Number check', untyped === 30);
+
+ var numClass:Class = Number;
+ untyped = new numClass(30);
+ Assert.assertTrue('Unexpected Number check', untyped == 30);
+ Assert.assertTrue('Unexpected Number check', untyped === 30);
+ Assert.assertTrue('Unexpected Number check', 30 === untyped);
+
+ untyped += 1.5;
+ Assert.assertTrue('Unexpected Number check', untyped == 31.5);
+ Assert.assertTrue('Unexpected Number check', untyped === 31.5);
+
+ }
+
+ }
+}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestIs.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestIs.as
new file mode 100644
index 0000000..54f377a
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestIs.as
@@ -0,0 +1,249 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.language
+{
+
+
+ import flexunit.framework.Assert;
+
+ import flexUnitTests.language.support.*;
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class LanguageTesterTestIs
+ {
+
+ public static var isJS:Boolean;
+
+ [BeforeClass]
+ public static function setUpBeforeClass():void
+ {
+ var js:Boolean;
+ COMPILE::JS {
+ js = true;
+ }
+ isJS = js;
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ }
+
+ [Before]
+ public function setUp():void
+ {
+ }
+
+ [After]
+ public function tearDown():void
+ {
+ }
+
+
+ [Test]
+ public function testIsOwnType():void
+ {
+ var test1:TestClass1 = new TestClass1();
+ Assert.assertTrue('Unexpected instance is {Class} check', test1 is TestClass1)
+ }
+
+ [Test]
+ public function testIsAncestorType():void
+ {
+ var test2:TestClass2 = new TestClass2();
+ Assert.assertTrue('Unexpected instance is {AncestorClass} check', test2 is TestClass1)
+ }
+
+ [Test]
+ public function testIsDistantAncestorType():void
+ {
+ var test4:TestClass4 = new TestClass4();
+ Assert.assertTrue('Unexpected instance is {DistantAncestorClass} check', test4 is TestClass1)
+ }
+
+
+ [Test]
+ public function testIsImplementedInterface():void
+ {
+ var test1:TestClass1 = new TestClass1();
+ Assert.assertTrue('Unexpected instance is {OwnInterface} check', test1 is ITestInterface)
+ }
+
+
+ [Test]
+ public function testIsAncestorInterface():void
+ {
+ var test2:TestClass2 = new TestClass2();
+ Assert.assertTrue('Unexpected instance is {AncestorInterface} check', test2 is ITestInterface)
+ }
+
+ [Test]
+ public function testIsImplementedInterfaceAncestor():void
+ {
+ var test3:TestClass3 = new TestClass3();
+ Assert.assertTrue('Unexpected instance is {InterfaceAncestor} check', test3 is ITestInterface)
+
+ }
+
+ [Test]
+ public function testIsImplementedInterfaceAncestor2():void
+ {
+ var test4:TestClass4 = new TestClass4();
+ Assert.assertTrue('Unexpected instance is {InterfaceAncestor} check', test4 is ITestInterface)
+ }
+
+
+ [Test]
+ public function testNullCoercion():void
+ {
+ var val:Object = null;
+
+ var s:String = String(val);
+ Assert.assertEquals('Unexpected coercion check', s, 'null');
+ var i:int = int(val);
+ Assert.assertTrue('Unexpected coercion check', i === 0);
+ var u:uint = uint(val);
+ Assert.assertTrue('Unexpected coercion check', u === 0);
+ var n:Number = Number(val);
+ Assert.assertTrue('Unexpected coercion check', n === 0);
+ var b:Boolean = Boolean(val);
+ Assert.assertTrue('Unexpected coercion check', b === false);
+
+ var t:TestClass1 = TestClass1(val);
+ Assert.assertTrue('Unexpected coercion check', t === null);
+
+ //with indirection
+ var c:Class = String;
+ var result:* = c(val);
+ Assert.assertTrue('Unexpected coercion check', result === 'null');
+ c = int;
+ result = c(val);
+ Assert.assertTrue('Unexpected coercion check', result === 0);
+ c = uint;
+ result = c(val);
+ Assert.assertTrue('Unexpected coercion check', result === 0);
+ c = Number;
+ result = c(val);
+ Assert.assertTrue('Unexpected coercion check', result === 0);
+
+ c = Boolean;
+ result = c(val);
+ Assert.assertTrue('Unexpected coercion check', result === false);
+
+ c = TestClass1;
+ result = c(val);
+ Assert.assertTrue('Unexpected coercion check', result === null);
+ }
+
+ [Test]
+ public function testObjectCoercion():void
+ {
+ Assert.assertTrue('Unexpected null check', Object(undefined) != null);
+ Assert.assertTrue('Unexpected null check', Object(null) != null);
+ Assert.assertTrue('Unexpected null check', Object('test') === 'test');
+ Assert.assertTrue('Unexpected null check', Object(1) === 1);
+ Assert.assertTrue('Unexpected null check', Object(false) === false);
+ Assert.assertTrue('Unexpected null check', Object(true) === true);
+ var indirection:* = undefined;
+ Assert.assertTrue('Unexpected null check', Object(indirection) != null);
+ indirection = null;
+ Assert.assertTrue('Unexpected null check', Object(indirection) != null);
+ indirection = 'test';
+ Assert.assertTrue('Unexpected null check', Object(indirection) === 'test');
+ indirection = 1;
+ Assert.assertTrue('Unexpected null check', Object(indirection) === 1);
+ indirection = false;
+ Assert.assertTrue('Unexpected null check', Object(indirection) === false);
+ indirection = true;
+ Assert.assertTrue('Unexpected null check', Object(indirection) === true);
+ var dynObjectClass:Class = Object;
+ //regular indirect coercion
+ indirection = undefined;
+ Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) != null);
+ indirection = null;
+ Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) != null);
+ indirection = 'test';
+ Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) === 'test');
+ indirection = 1;
+ Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) === 1);
+ indirection = false;
+ Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) === false);
+ indirection = true;
+ Assert.assertTrue('Unexpected null check', dynObjectClass(indirection) === true);
+ //no need to test 'new Object(something)' as it is not permitted explicitly in actionscript
+ //but it can be achieved via indirection:
+ var dynObject:Class = Object;
+ indirection = undefined;
+ Assert.assertTrue('Unexpected null check', new dynObject(indirection) != null);
+ indirection = null;
+ Assert.assertTrue('Unexpected null check', new dynObject(indirection) != null);
+ indirection = 'test';
+ Assert.assertTrue('Unexpected null check', new dynObject(indirection) === 'test');
+ indirection = 1;
+ Assert.assertTrue('Unexpected null check', new dynObject(indirection) === 1);
+ indirection = false;
+ Assert.assertTrue('Unexpected null check', new dynObject(indirection) === false);
+ indirection = true;
+ Assert.assertTrue('Unexpected null check', new dynObject(indirection) === true);
+
+ }
+
+ [Test]
+ public function testImplicitCoercion():void
+ {
+ var testclass2Class:Class = TestClass2;
+ var testClass3:TestClass3;
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ testClass3 = new testclass2Class();
+ } catch (e:Error)
+ {
+ caughtError = e is TypeError
+ }
+
+ Assert.assertTrue('Unexpected coercion check', caughtError);
+ Assert.assertTrue('Unexpected coercion check', testClass3 == null);
+ }
+
+ [Test]
+ public function testNullUndefined():void
+ {
+ Assert.assertTrue('Unexpected null check', null == null);
+ Assert.assertTrue('Unexpected null check', null == undefined);
+ Assert.assertTrue('Unexpected null check', null === null);
+ Assert.assertTrue('Unexpected undefined check', undefined === undefined);
+ Assert.assertFalse('Unexpected null/undefined check', undefined === null);
+ }
+
+ [Test]
+ public function testString():void
+ {
+ Assert.assertTrue('Unexpected string check', String('test') == 'test');
+ Assert.assertTrue('Unexpected string check', String('test') === 'test');
+ Assert.assertTrue('Unexpected string check', new String('test') == 'test');
+ Assert.assertTrue('Unexpected string check', new String('test') === 'test');
+ }
+
+
+ }
+}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestVector.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestVector.as
new file mode 100644
index 0000000..7231610
--- /dev/null
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/LanguageTesterTestVector.as
@@ -0,0 +1,1150 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 flexUnitTests.language
+{
+
+ import flexunit.framework.Assert;
+ import flexUnitTests.language.support.*;
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class LanguageTesterTestVector
+ {
+
+ public static var isJS:Boolean;
+
+ [BeforeClass]
+ public static function setUpBeforeClass():void
+ {
+ var js:Boolean;
+ COMPILE::JS {
+ js = true;
+ }
+ isJS = js;
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ }
+
+ [Before]
+ public function setUp():void
+ {
+ }
+
+ [After]
+ public function tearDown():void
+ {
+ }
+
+
+ private function _mapper(item:Object, index:int, vector:Vector.<*>):Object
+ {
+ return new TestClass1();
+ }
+
+ [Test]
+ public function testVectorBasic():void
+ {
+
+ var vi:Vector.<int> = new Vector.<int>();
+
+ Assert.assertFalse('Unexpected Vector check', vi.fixed);
+ Assert.assertTrue('Unexpected Vector check', vi.length == 0);
+
+ vi = new Vector.<int>(20);
+
+ Assert.assertFalse('Unexpected Vector check', vi.fixed);
+ Assert.assertTrue('Unexpected Vector check', vi.length == 20);
+ Assert.assertEquals('Unexpected Vector check', '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', vi.toString());
+
+ vi = new Vector.<int>(20, true);
+
+ Assert.assertTrue('Unexpected Vector check', vi.fixed);
+ Assert.assertTrue('Unexpected Vector check', vi.length == 20);
+ Assert.assertEquals('Unexpected Vector check', '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', vi.toString());
+
+ var c:Class = Vector.<int>;
+
+ //dynamic instantiation
+ var n:* = new c();
+ n.push(12);
+ n.push(24);
+ Assert.assertFalse('Unexpected Vector check', n.fixed);
+ Assert.assertTrue('Unexpected Vector check', n.length == 2);
+ Assert.assertEquals('Unexpected Vector check', '12,24', n.toString());
+
+ n = new c(20);
+ Assert.assertFalse('Unexpected Vector check', n.fixed);
+ Assert.assertTrue('Unexpected Vector check', n.length == 20);
+ Assert.assertEquals('Unexpected Vector check', '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', n.toString());
+
+ n = new c(20, true);
+ Assert.assertTrue('Unexpected Vector check', n.fixed);
+ Assert.assertTrue('Unexpected Vector check', n.length == 20);
+ Assert.assertEquals('Unexpected Vector check', '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0', n.toString());
+
+ var source:Array = [1, '', false, NaN, {test: true}, undefined];
+
+ //coercion
+ vi = Vector.<int>(source);
+ Assert.assertFalse('Unexpected Vector check', vi.fixed);
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertEquals('Unexpected Vector check', '1,0,0,0,0,0', vi.toString());
+
+ var vb:Vector.<Boolean> = Vector.<Boolean>(source);
+ Assert.assertFalse('Unexpected Vector check', vb.fixed);
+ Assert.assertTrue('Unexpected Vector check', vb.length == 6);
+ Assert.assertEquals('Unexpected Vector check', 'true,false,false,false,true,false', vb.toString());
+
+ n = vb;
+ Assert.assertFalse('Unexpected Vector check', n is Vector);
+ Assert.assertFalse('Unexpected Vector check', n is Array);
+ Assert.assertTrue('Unexpected Vector check', n is Vector.<Boolean>);
+
+ var vs:Vector.<String> = Vector.<String>(source);
+
+ Assert.assertFalse('Unexpected Vector check', vs.fixed);
+ Assert.assertTrue('Unexpected Vector check', vs.length == 6);
+ Assert.assertEquals('Unexpected Vector check', '1,,false,NaN,[object Object],null', vs.toString());
+
+ var vstar:Vector.<*> = Vector.<*>(source);
+
+ Assert.assertFalse('Unexpected Vector check', vstar.fixed);
+ Assert.assertTrue('Unexpected Vector check', vstar.length == 6);
+ Assert.assertEquals('Unexpected Vector check', '1,,false,NaN,[object Object],null', vstar.toString());
+ vstar.fixed = true;
+ Assert.assertTrue('Unexpected Vector check', vstar.fixed);
+
+ var customClasses:Array = [null, new TestClass2(), undefined, new TestClass1()];
+
+ var vcustom:Vector.<TestClass1> = Vector.<TestClass1>(customClasses);
+
+ Assert.assertFalse('Unexpected Vector check', vcustom.fixed);
+ Assert.assertTrue('Unexpected Vector check', vcustom.length == 4);
+ Assert.assertTrue('Unexpected Vector check', vcustom[0] === null);
+ Assert.assertTrue('Unexpected Vector check', vcustom[1] is TestClass2);
+ Assert.assertTrue('Unexpected Vector check', vcustom[2] === null);
+ Assert.assertTrue('Unexpected Vector check', vcustom[3] is TestClass1);
+
+ var nested:Vector.<Vector.<TestClass1>> = Vector.<Vector.<TestClass1>>([vcustom, null, undefined, vcustom]);
+ Assert.assertFalse('Unexpected Vector check', nested.fixed);
+ Assert.assertTrue('Unexpected Vector check', nested.length == 4);
+ Assert.assertTrue('Unexpected Vector check', nested[0] === vcustom);
+ Assert.assertTrue('Unexpected Vector check', nested[1] === null);
+ Assert.assertTrue('Unexpected Vector check', nested[2] === null);
+ Assert.assertTrue('Unexpected Vector check', nested[3] === vcustom);
+
+ //indirect/dynamic coercion
+ c = Vector.<int>;
+ var result:*;
+ result = c(source);
+ Assert.assertFalse('Unexpected Vector check', result.fixed);
+ Assert.assertTrue('Unexpected Vector check', result.length == 6);
+ Assert.assertFalse('Unexpected Vector check', result is Vector);
+ Assert.assertFalse('Unexpected Vector check', result is Array);
+ Assert.assertFalse('Unexpected Vector check', result is Vector.<*>);
+ Assert.assertTrue('Unexpected Vector check', result is Vector.<int>);
+ Assert.assertEquals('Unexpected Vector check', '1,0,0,0,0,0', result.toString());
+
+ c = Vector.<Boolean>;
+ result = c(source);
+ Assert.assertFalse('Unexpected Vector check', result.fixed);
+ Assert.assertTrue('Unexpected Vector check', result.length == 6);
+ Assert.assertFalse('Unexpected Vector check', result is Vector);
+ Assert.assertFalse('Unexpected Vector check', result is Array);
+ Assert.assertTrue('Unexpected Vector check', result is Vector.<*>);
+ Assert.assertTrue('Unexpected Vector check', result is Vector.<Boolean>);
+ Assert.assertEquals('Unexpected Vector check', 'true,false,false,false,true,false', result.toString());
+
+ c = Vector.<String>;
+ result = c(source);
+
+ Assert.assertFalse('Unexpected Vector check', result.fixed);
+ Assert.assertTrue('Unexpected Vector check', result.length == 6);
+ Assert.assertFalse('Unexpected Vector check', result is Vector);
+ Assert.assertFalse('Unexpected Vector check', result is Array);
+ Assert.assertTrue('Unexpected Vector check', result is Vector.<*>);
+ Assert.assertTrue('Unexpected Vector check', result is Vector.<String>);
+ Assert.assertEquals('Unexpected Vector check', '1,,false,NaN,[object Object],null', result.toString());
+
+ c = Vector.<*>;
+ result = c(source);
+
+ Assert.assertFalse('Unexpected Vector check', result.fixed);
+ Assert.assertTrue('Unexpected Vector check', result.length == 6);
+ Assert.assertFalse('Unexpected Vector check', result is Vector);
+ Assert.assertFalse('Unexpected Vector check', result is Array);
+ Assert.assertTrue('Unexpected Vector check', result is Vector.<*>);
+ Assert.assertFalse('Unexpected Vector check', result is Vector.<Object>);
+ Assert.assertEquals('Unexpected Vector check', '1,,false,NaN,[object Object],null', result.toString());
+ }
+
+ [Test]
+ public function testFixedVectorBasicMethods():void
+ {
+ var nested:Vector.<Vector.<TestClass1>> = new Vector.<Vector.<TestClass1>>(20, false);
+
+ var caughtError:Boolean;
+
+ nested.fixed = true;
+ try
+ {
+ caughtError = false;
+ nested.pop();
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ try
+ {
+ caughtError = false;
+ nested.push(null);
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ try
+ {
+ caughtError = false;
+ nested.shift();
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ try
+ {
+ caughtError = false;
+ nested.unshift(null);
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ try
+ {
+ caughtError = false;
+ nested.removeAt(0);
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ try
+ {
+ caughtError = false;
+ nested.insertAt(0, null);
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ }
+
+ [Test]
+ public function testFixedVectorMutationMethodCoercion():void
+ {
+ var tc1Vec:Vector.<TestClass1> = new Vector.<TestClass1>();
+
+ var content:* = new TestClass5();
+
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ //not allowed, because TestClass5 does not coerce to TestClass1
+ tc1Vec.push(content);
+ } catch (e:Error)
+ {
+ caughtError = e is TypeError;
+
+ }
+ //even though it was an error, it has pushed null into the vector, so it
+ //now has length of 1
+ Assert.assertTrue('Unexpected Vector check', tc1Vec.length == 1);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[0]);
+
+ try
+ {
+ caughtError = false;
+ //multiple args, with one valid at the start and end
+ //when the first error is hit as the second item, that items, and the following items
+ //are pushed as null
+ //the nwe length is therefore increased by 4 here,
+ //but the 2nd item is an error, so only the first one makes it in
+ tc1Vec.push(new TestClass1(), content, content, new TestClass1());
+ } catch (e:Error)
+ {
+ caughtError = e is TypeError;
+ }
+ //even though it had an extra 2 error elements, it has pushed null into the vector, so it
+ //now has length of 5
+ Assert.assertTrue('Unexpected Vector check', tc1Vec.length == 5);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[0]);
+ Assert.assertTrue('Unexpected Vector check', tc1Vec[1] is TestClass1);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[2]);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[3]);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[4]);
+
+ try
+ {
+ caughtError = false;
+ //similar to push, the first failed argument coercion (2nd argument here) results
+ //in it and the remaining items being coerced to null and unshifted
+ //so this also increases the length by 4, but only the first item makes
+ //it in (and the error is thrown)
+ tc1Vec.unshift(new TestClass1(), content, new TestClass1(), content);
+ } catch (e:Error)
+ {
+ caughtError = e is TypeError;
+ }
+
+ Assert.assertTrue('Unexpected Vector check', tc1Vec.length == 9);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ Assert.assertTrue('Unexpected Vector check', tc1Vec[0] is TestClass1);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[1]);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[2]);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[3]);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[4]);
+ Assert.assertTrue('Unexpected Vector check', tc1Vec[5] is TestClass1);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[6]);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[7]);
+ Assert.assertNull('Unexpected Vector check', tc1Vec[8]);
+
+ }
+
+ [Test]
+ public function testVectorAdvancedMethods():void
+ {
+
+ var customClasses:Array = [null, new TestClass2(), undefined, new TestClass1()];
+
+ var vcustom:Vector.<TestClass1> = Vector.<TestClass1>(customClasses);
+ var vcustom2:Vector.<TestClass1> = vcustom.map(_mapper);
+
+ Assert.assertTrue('Unexpected Vector check', vcustom2 != vcustom);
+ Assert.assertTrue('Unexpected Vector check', vcustom2[0] is TestClass1);
+ Assert.assertTrue('Unexpected Vector check', vcustom2[1] is TestClass1);
+ Assert.assertTrue('Unexpected Vector check', vcustom2[2] is TestClass1);
+ Assert.assertTrue('Unexpected Vector check', vcustom2[3] is TestClass1);
+ //remove 1 item at position 1 and replace it with a new TestClass2 instance
+ var vcustom3:Vector.<TestClass1> = vcustom2.splice(1, 1, new TestClass2());
+ Assert.assertTrue('Unexpected Vector check', vcustom3 != vcustom2);
+ Assert.assertTrue('Unexpected Vector check', vcustom3.length == 1);
+ Assert.assertTrue('Unexpected Vector check', vcustom2.length == 4);
+ Assert.assertTrue('Unexpected Vector check', vcustom3[0] is TestClass1);
+ Assert.assertTrue('Unexpected Vector check', vcustom2[1] is TestClass2);
+
+ vcustom3.insertAt(0, new TestClass2());
+ Assert.assertTrue('Unexpected Vector check', vcustom3.length == 2);
+ Assert.assertTrue('Unexpected Vector check', vcustom3[0] is TestClass2);
+ Assert.assertTrue('Unexpected Vector check', vcustom3[1] is TestClass1);
+
+ var removedItem:* = vcustom3.removeAt(0);
+ Assert.assertTrue('Unexpected Vector check', vcustom3.length == 1);
+ Assert.assertTrue('Unexpected Vector check', vcustom3[0] is TestClass1);
+ Assert.assertTrue('Unexpected Vector check', removedItem is TestClass2);
+
+ var tc1Vec:Vector.<TestClass1> = new Vector.<TestClass1>(4);
+
+ //insert at invalid index:
+ tc1Vec.insertAt(6, new TestClass1());
+ //no error, insertAt minimises the specified index to the Vector's length and inserts there
+ Assert.assertTrue('Unexpected Vector check', tc1Vec.length == 5);
+ Assert.assertTrue('Unexpected Vector check', tc1Vec[4] is TestClass1);
+
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ tc1Vec.removeAt(6);
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ try
+ {
+ caughtError = false;
+ tc1Vec.removeAt(-1);
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+ Assert.assertTrue('Unexpected Vector check', tc1Vec.length == 4);
+ Assert.assertEquals('Unexpected Vector check', 'null,null,null,null', tc1Vec.toString());
+ //no error
+ Assert.assertFalse('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ tc1Vec.insertAt(-1, new TestClass1());
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', tc1Vec.length == 5);
+ //new item is at position 3
+ Assert.assertNotNull('Unexpected Vector check', tc1Vec[3]);
+ //moving the original content (null) from position 3 to 4
+ Assert.assertNull('Unexpected Vector check', tc1Vec[4]);
+ //no error
+ Assert.assertFalse('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ //even though this is out of range, it still works without error
+ tc1Vec.insertAt(-200, new TestClass1());
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', tc1Vec.length == 6);
+ //new item is at position 0
+ Assert.assertNotNull('Unexpected Vector check', tc1Vec[0]);
+ //the other non-null item is now at postion 4
+ Assert.assertNotNull('Unexpected Vector check', tc1Vec[4]);
+ //no error
+ Assert.assertFalse('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ tc1Vec.removeAt(-200);
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError;
+ }
+
+ Assert.assertTrue('Unexpected Vector check', tc1Vec.length == 5);
+ //position 0 is now null
+ Assert.assertNull('Unexpected Vector check', tc1Vec[0]);
+ //the non-null item is now at postion 3
+ Assert.assertNotNull('Unexpected Vector check', tc1Vec[3]);
+ //no error
+ Assert.assertFalse('Unexpected Vector check', caughtError);
+
+ }
+
+ [Test]
+ public function testVectorConcat():void
+ {
+ var source:Array = [1, '', false, NaN, {test: true}, undefined];
+ var vi1:Vector.<int> = new <int>[1, 2, 3, 4, 5];
+ var vi2:Vector.<int> = new <int>[5, 4, 3, 2, 1];
+ var vu2:Vector.<uint> = new <uint>[5, 4, 3, 2, 1];
+ var vi3:Vector.<int> = vi1.concat(vi2);
+ Assert.assertEquals('Unexpected Vector check', '1,2,3,4,5,5,4,3,2,1', vi3.toString());
+ Assert.assertTrue('Unexpected Vector check', vi3 is Vector.<int>);
+
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ vi3 = vi1.concat(vu2);
+ } catch (e:Error)
+ {
+ caughtError = e is TypeError
+ }
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ var vs:Vector.<String> = Vector.<String>(source);
+ var testConcat:Vector.<String> = vs.concat(vs);
+ Assert.assertEquals('Unexpected Vector check', '1,,false,NaN,[object Object],null,1,,false,NaN,[object Object],null', testConcat.toString());
+ Assert.assertTrue('Unexpected Vector check', testConcat is Vector.<String>);
+
+ }
+
+ [Test]
+ public function testVectorFilter():void
+ {
+ var vi1:Vector.<int> = new <int>[1, 2, 3, 4, 5, 4, 3, 2, 1];
+
+ var f:Function = function (value:int, index:int, source:*):Boolean
+ {
+ return value > 2
+ };
+
+ var vi2:Vector.<int> = vi1.filter(f);
+ Assert.assertEquals('Unexpected Vector check', '3,4,5,4,3', vi2.toString());
+ Assert.assertFalse('Unexpected Vector check', vi2 is Array);
+ Assert.assertTrue('Unexpected Vector check', vi2 is Vector.<int>);
+ }
+
+ [Test]
+ public function testVectorAsIs():void
+ {
+ var source:Array = [1, '', false, NaN, {test: true}, undefined];
+
+ var vi:Vector.<int> = Vector.<int>(source);
+ Assert.assertFalse('Unexpected Vector check', vi is Vector);
+ Assert.assertFalse('Unexpected Vector check', vi is Array);
+ Assert.assertTrue('Unexpected Vector check', vi is Vector.<int>);
+ Assert.assertFalse('Unexpected Vector check', vi is Vector.<*>);
+
+ var vu:Vector.<uint> = Vector.<uint>(source);
+ Assert.assertFalse('Unexpected Vector check', vu is Vector);
+ Assert.assertFalse('Unexpected Vector check', vu is Array);
+ Assert.assertTrue('Unexpected Vector check', vu is Vector.<uint>);
+ Assert.assertFalse('Unexpected Vector check', vu is Vector.<*>);
+
+ var vn:Vector.<Number> = Vector.<Number>(source);
+ Assert.assertFalse('Unexpected Vector check', vn is Vector);
+ Assert.assertFalse('Unexpected Vector check', vn is Array);
+ Assert.assertTrue('Unexpected Vector check', vn is Vector.<Number>);
+ Assert.assertFalse('Unexpected Vector check', vn is Vector.<*>);
+
+ var vb:Vector.<Boolean> = Vector.<Boolean>(source);
+ Assert.assertFalse('Unexpected Vector check', vb is Vector);
+ Assert.assertFalse('Unexpected Vector check', vb is Array);
+ Assert.assertTrue('Unexpected Vector check', vb is Vector.<Boolean>);
+ Assert.assertTrue('Unexpected Vector check', vb is Vector.<*>);
+
+ var vs:Vector.<String> = Vector.<String>(source);
+ Assert.assertFalse('Unexpected Vector check', vs is Vector);
+ Assert.assertFalse('Unexpected Vector check', vs is Array);
+ Assert.assertTrue('Unexpected Vector check', vs is Vector.<String>);
+ Assert.assertTrue('Unexpected Vector check', vs is Vector.<*>);
+
+ var vstar:Vector.<*> = Vector.<*>(source);
+ Assert.assertFalse('Unexpected Vector check', vstar is Vector);
+ Assert.assertFalse('Unexpected Vector check', vstar is Array);
+ Assert.assertTrue('Unexpected Vector check', vstar is Vector.<*>);
+ Assert.assertTrue('Unexpected Vector check', vstar is Vector.<*>);
+
+
+ var customClasses:Array = [null, new TestClass2(), undefined, new TestClass1()];
+
+ var vcustom:Vector.<TestClass1> = Vector.<TestClass1>(customClasses);
+
+ Assert.assertFalse('Unexpected Vector check', vcustom is Vector);
+ Assert.assertFalse('Unexpected Vector check', vcustom is Array);
+ Assert.assertTrue('Unexpected Vector check', vcustom is Vector.<TestClass1>);
+ Assert.assertTrue('Unexpected Vector check', vcustom is Vector.<*>);
+
+ customClasses.push(new TestClass5());
+ var oldDef:Vector.<TestClass1> = vcustom;
+ //this is a coercion error
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ vcustom = Vector.<TestClass1>(customClasses);
+ } catch (e:Error)
+ {
+ caughtError = e is TypeError;
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ Assert.assertEquals('Unexpected Vector check', oldDef,vcustom);
+ }
+
+ [Test]
+ /**
+ * @royalesuppresscompleximplicitcoercion Vector.<TestClass1>
+ */
+ public function testVectorAsIsIndirect():void
+ {
+ var source:Array = [1, '', false, NaN, {test: true}, undefined];
+
+ var vi:Vector.<int> = Vector.<int>(source);
+ Assert.assertFalse('Unexpected Vector check', vi is Vector);
+ Assert.assertFalse('Unexpected Vector check', vi is Array);
+ Assert.assertTrue('Unexpected Vector check', vi is Vector.<int>);
+ Assert.assertFalse('Unexpected Vector check', vi is Vector.<*>);
+
+ var vu:Vector.<uint> = Vector.<uint>(source);
+ Assert.assertFalse('Unexpected Vector check', vu is Vector);
+ Assert.assertFalse('Unexpected Vector check', vu is Array);
+ Assert.assertTrue('Unexpected Vector check', vu is Vector.<uint>);
+ Assert.assertFalse('Unexpected Vector check', vu is Vector.<*>);
+
+ var vn:Vector.<Number> = Vector.<Number>(source);
+ Assert.assertFalse('Unexpected Vector check', vn is Vector);
+ Assert.assertFalse('Unexpected Vector check', vn is Array);
+ Assert.assertTrue('Unexpected Vector check', vn is Vector.<Number>);
+ Assert.assertFalse('Unexpected Vector check', vn is Vector.<*>);
+
+ var vb:Vector.<Boolean> = Vector.<Boolean>(source);
+ Assert.assertFalse('Unexpected Vector check', vb is Vector);
+ Assert.assertFalse('Unexpected Vector check', vb is Array);
+ Assert.assertTrue('Unexpected Vector check', vb is Vector.<Boolean>);
+ Assert.assertTrue('Unexpected Vector check', vb is Vector.<*>);
+
+ var vs:Vector.<String> = Vector.<String>(source);
+ Assert.assertFalse('Unexpected Vector check', vs is Vector);
+ Assert.assertFalse('Unexpected Vector check', vs is Array);
+ Assert.assertTrue('Unexpected Vector check', vs is Vector.<String>);
+ Assert.assertTrue('Unexpected Vector check', vs is Vector.<*>);
+
+ var vstar:Vector.<*> = Vector.<*>(source);
+ Assert.assertFalse('Unexpected Vector check', vstar is Vector);
+ Assert.assertFalse('Unexpected Vector check', vstar is Array);
+ Assert.assertTrue('Unexpected Vector check', vstar is Vector.<*>);
+ Assert.assertTrue('Unexpected Vector check', vstar is Vector.<*>);
+
+
+ var customClasses:Array = [null, new TestClass2(), undefined, new TestClass1()];
+
+ var vcustom:Vector.<TestClass1> = Vector.<TestClass1>(customClasses);
+
+ Assert.assertFalse('Unexpected Vector check', vcustom is Vector);
+ Assert.assertFalse('Unexpected Vector check', vcustom is Array);
+ Assert.assertTrue('Unexpected Vector check', vcustom is Vector.<TestClass1>);
+ Assert.assertTrue('Unexpected Vector check', vcustom is Vector.<*>);
+
+ var claZZ:Class = Vector.<TestClass1>;
+ vcustom = claZZ(customClasses);
+
+ Assert.assertFalse('Unexpected Vector check', vcustom is Vector);
+ Assert.assertFalse('Unexpected Vector check', vcustom is Array);
+ Assert.assertTrue('Unexpected Vector check', vcustom is Vector.<TestClass1>);
+ Assert.assertTrue('Unexpected Vector check', vcustom is Vector.<*>);
+ }
+
+ [Test]
+ public function testVectorLiteral():void
+ {
+ var test:* = 'hello';
+ var vi:Vector.<int> = new <int>[1, 2, test, 4, 5];
+
+ Assert.assertFalse('Unexpected Vector check', vi.fixed);
+ Assert.assertTrue('Unexpected Vector check', vi.length == 5);
+ Assert.assertEquals('Unexpected Vector check', '1,2,0,4,5', vi.toString());
+ }
+
+ [Test]
+ public function testVectorLengthIncreasedDefaults():void
+ {
+ var vi:Vector.<int> = new <int>[1, 2, 3, 4, 5];
+ vi.length = 10;
+ Assert.assertFalse('Unexpected Vector check', vi.fixed);
+ Assert.assertTrue('Unexpected Vector check', vi.length == 10);
+ Assert.assertEquals('Unexpected Vector check', '1,2,3,4,5,0,0,0,0,0', vi.toString());
+ }
+
+ [TestVariance(variance="JS", description="Variance in js implementation for access to 'constructor' via Vector instance, js is specific vs. Vector.<*> in swf.")]
+ [Test]
+ public function testVectorConstructor():void
+ {
+ var vi:Vector.<int> = new <int>[1, 2, 3, 4, 5];
+ Assert.assertTrue('Unexpected Vector check', vi['constructor'] === Vector.<int>);
+
+ var vui:Vector.<uint> = new <uint>[1, 2, 3, 4, 5];
+ Assert.assertTrue('Unexpected Vector check', vui['constructor'] === Vector.<uint>);
+
+ var vn:Vector.<Number> = new <Number>[1, 2, 3, 4, 5];
+ Assert.assertTrue('Unexpected Vector check', vn['constructor'] === Vector.<Number>);
+
+ var vs:Vector.<String> = new <String>[];
+ //current variance in the javascript vs. avm implementations
+ const expected:Class = isJS ? Vector.<String> : Vector.<*>;
+ Assert.assertTrue('Unexpected Vector check', vs['constructor'] === expected);
+ }
+
+
+ private var _viTest:Vector.<int>;
+
+ private function getVector():Vector.<int>
+ {
+ return _viTest;
+ }
+
+ [Test]
+ public function testFixedVectorLengthChangeErrors():void
+ {
+ var vi:Vector.<int> = new <int>[1, 2, 3, 4, 5];
+ vi.fixed = true;
+ _viTest = vi;
+
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ vi.length = 10;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ vi.length += 5;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ vi.length = vi.length + 5;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ vi.length++;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ vi.length--;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ ++vi.length;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ --vi.length;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ _viTest.length = 10;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ _viTest.length += 5;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ _viTest.length = _viTest.length + 5;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ _viTest.length++;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ _viTest.length--;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ ++_viTest.length;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ --_viTest.length;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ getVector().length = 10;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ getVector().length += 5;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ getVector().length = _viTest.length + 5;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ getVector().length++;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ getVector().length--;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ ++getVector().length;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ --getVector().length;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ }
+
+ [Test]
+ /**
+ * no matter what the global setting is, do not suppress index checks inside this method:
+ * @royalesuppressvectorindexcheck false
+ */
+ public function testRegularVectorIndexChecks():void
+ {
+ var vi:Vector.<int> = new <int>[1, 2, 3, 4, 5];
+ //allowed, not an error:
+ vi[5] = 6;
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertEquals('Unexpected Vector check', '1,2,3,4,5,6', vi.toString());
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ //not allowed, because even though fixed==false,
+ //Vectors are not allowed to be sparse and
+ //index is greater than current length of 6
+ vi[7] = 8;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ vi.fixed = true;
+ //not allowed, because it is now fixed length of 6 (after v[5] = 6 above)
+ //so anything outside range of 0..5 is not permitted
+ vi[6] = 7;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ //not allowed, because it is a non-uint index
+ //only uint indices in range of 0..5 are permitted
+ vi[1.5] = 0;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ //this is a non-realistic example which should not be encountered in 'real' code
+ //but is included here for coverage
+ new Vector.<int>()[2] = 3;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+ }
+
+
+ [TestVariance(variance="JS", description="Variance in js implementation with @royalesuppressvectorindexcheck true, Vector instance can enter invalid state.")]
+ [Test]
+ /**
+ * local avoidance of vector index checking (all cases)
+ * no matter what the global setting is, always suppress inside this method:
+ * @royalesuppressvectorindexcheck true
+ * this will cause variance in the most Assertions
+ */
+ public function testSuppressedVectorIndexChecks():void
+ {
+ var vi:Vector.<int> = new <int>[1, 2, 3, 4, 5];
+ //allowed, not an error:
+ vi[5] = 6;
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertEquals('Unexpected Vector check', '1,2,3,4,5,6', vi.toString());
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ //not allowed, because even though fixed==false,
+ //Vectors are not allowed to be sparse and
+ //index is greater than current length of 6
+ vi[7] = 8;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == (isJS? 8 : 6));
+ Assert.assertTrue('Unexpected Vector check', caughtError === (isJS ? false : true));
+
+ try
+ {
+ caughtError = false;
+ vi.fixed = true;
+ //not allowed, because it is now fixed length of 6 (after v[5] = 6 above)
+ //so anything outside range of 0..5 is not permitted
+ vi[6] = 7;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == (isJS? 8 : 6));
+ Assert.assertTrue('Unexpected Vector check', caughtError === (isJS ? false : true));
+
+ try
+ {
+ caughtError = false;
+ //not allowed, because it is a non-uint index
+ //only uint indices in range of 0..5 are permitted
+ vi[1.5] = 0;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == (isJS? 8 : 6));
+ Assert.assertTrue('Unexpected Vector check', caughtError === (isJS ? false : true));
+
+ try
+ {
+ caughtError = false;
+ //this is a non-realistic example which should not be encountered in 'real' code
+ //but is included here for coverage
+ new Vector.<int>()[2] = 3;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+ Assert.assertTrue('Unexpected Vector check', caughtError === (isJS ? false : true));
+ }
+
+ [TestVariance(variance="JS", description="Variance in js implementation with @royalesuppressvectorindexcheck {name here}, Vector instance can enter invalid state.")]
+ [Test]
+ /**
+ * local avoidance of vector index checking (specific named case only)
+ * no matter what the global setting is, do not suppress by default inside this method:
+ * @royalesuppressvectorindexcheck false
+ * aside from the above, suppress index checking specifically for an instance referenced as 'vi2':
+ * @royalesuppressvectorindexcheck vi2
+ * this will cause variance in the last Assertion
+ */
+ public function testSpecificSuppressedVectorIndexChecks():void
+ {
+ var vi:Vector.<int> = new <int>[1, 2, 3, 4, 5];
+ //allowed, not an error:
+ vi[5] = 6;
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertEquals('Unexpected Vector check', '1,2,3,4,5,6', vi.toString());
+ var caughtError:Boolean;
+ try
+ {
+ caughtError = false;
+ //not allowed, because even though fixed==false,
+ //Vectors are not allowed to be sparse and
+ //index is greater than current length of 6
+ vi[7] = 8;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ vi.fixed = true;
+ //not allowed, because it is now fixed length of 6 (after v[5] = 6 above)
+ //so anything outside range of 0..5 is not permitted
+ vi[6] = 7;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ try
+ {
+ caughtError = false;
+ //not allowed, because it is a non-uint index
+ //only uint indices in range of 0..5 are permitted
+ vi[1.5] = 0;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi.length == 6);
+ Assert.assertTrue('Unexpected Vector check', caughtError);
+
+ var vi2:Vector.<int> = vi;
+ try
+ {
+ caughtError = false;
+ //not allowed, because it is a non-uint index
+ //only uint indices in range of 0..5 are permitted
+ vi2[1.5] = 0;
+ } catch (e:Error)
+ {
+ caughtError = e is RangeError
+ }
+
+ Assert.assertTrue('Unexpected Vector check', vi2.length == 6);
+ Assert.assertTrue('Unexpected Vector check', caughtError === (isJS ? false : true));
+ }
+
+
+ }
+}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface.as
similarity index 90%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface.as
index 05825f4..a6f7e65 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface.as
@@ -16,12 +16,11 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests.reflection.support
+package flexUnitTests.language.support
{
-
- public interface ITestInterface3
- {
- //empty
-
- }
+
+ public interface ITestInterface
+ {
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface2.as
similarity index 88%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface2.as
index 05825f4..fc52d4f 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface2.as
@@ -16,12 +16,12 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests.reflection.support
+package flexUnitTests.language.support
{
-
- public interface ITestInterface3
- {
- //empty
-
- }
+
+ public interface ITestInterface2 extends ITestInterface
+ {
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface3.as
similarity index 89%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface3.as
index 05825f4..7de226b 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface3.as
@@ -16,12 +16,12 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests.reflection.support
+package flexUnitTests.language.support
{
-
- public interface ITestInterface3
- {
- //empty
-
- }
+
+ public interface ITestInterface3
+ {
+ //empty
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface4.as
similarity index 87%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface4.as
index 05825f4..bad16df 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/ITestInterface4.as
@@ -16,12 +16,12 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests.reflection.support
+package flexUnitTests.language.support
{
-
- public interface ITestInterface3
- {
- //empty
-
- }
+
+ public interface ITestInterface4 extends ITestInterface2, ITestInterface3
+ {
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass1.as
similarity index 75%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass1.as
index 11f62e3..9bae597 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass1.as
@@ -16,18 +16,19 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests
+package flexUnitTests.language.support
{
- import flexUnitTests.observedbugs.*
-
- [Suite]
- [RunWith("org.flexunit.runners.Suite")]
- public class ObservedBugsTester
+
+
+ public class TestClass1 implements ITestInterface
{
- public function ObservedBugsTester()
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing against it
+ public function TestClass1()
{
- var arr:Array = [ObservedBugTests];
+
}
- public var observedBugsTest1:ObservedBugTests;
+
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass2.as
similarity index 75%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass2.as
index 11f62e3..99b719c 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass2.as
@@ -16,18 +16,19 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests
+package flexUnitTests.language.support
{
- import flexUnitTests.observedbugs.*
-
- [Suite]
- [RunWith("org.flexunit.runners.Suite")]
- public class ObservedBugsTester
+
+ public class TestClass2 extends TestClass1
{
- public function ObservedBugsTester()
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing against it
+
+ public function TestClass2()
{
- var arr:Array = [ObservedBugTests];
+
}
- public var observedBugsTest1:ObservedBugTests;
+
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/GithubIssuesTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass3.as
similarity index 87%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/GithubIssuesTester.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass3.as
index 72b5ee1..ddb595b 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/GithubIssuesTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass3.as
@@ -16,14 +16,13 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests
+package flexUnitTests.language.support
{
- import flexUnitTests.github.*
-
- [Suite]
- [RunWith("org.flexunit.runners.Suite")]
- public class GithubIssuesTester
+
+
+ public class TestClass3 extends TestClass1 implements ITestInterface2, ITestInterface3
{
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass4.as
similarity index 73%
copy from manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
copy to manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass4.as
index 11f62e3..b5f982d 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/ObservedBugsTester.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/language/support/TestClass4.as
@@ -16,18 +16,20 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package flexUnitTests
+package flexUnitTests.language.support
{
- import flexUnitTests.observedbugs.*
-
- [Suite]
- [RunWith("org.flexunit.runners.Suite")]
- public class ObservedBugsTester
+
+
+ public class TestClass4 extends TestClass3 implements ITestInterface4
{
- public function ObservedBugsTester()
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing reflection into it
+
+ public function TestClass4()
{
- var arr:Array = [ObservedBugTests];
+
}
- public var observedBugsTest1:ObservedBugTests;
+
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/AMFBinaryDataTesterTest.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/AMFBinaryDataTesterTest.as
index f0b4531..98a2ca8 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/AMFBinaryDataTesterTest.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/AMFBinaryDataTesterTest.as
@@ -18,487 +18,520 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.network
{
-
-
- import flexUnitTests.network.support.DynamicPropertyWriter;
- import flexUnitTests.network.support.DynamicTestClass2;
- import flexUnitTests.network.support.TestClass1;
- import flexUnitTests.network.support.TestClass2;
- import flexUnitTests.network.support.TestClass3;
- import flexUnitTests.network.support.TestClass4;
- import flexUnitTests.network.support.DynamicTestClass;
-
- import flexunit.framework.Assert;
+
+
+ import flexUnitTests.network.support.DynamicPropertyWriter;
+ import flexUnitTests.network.support.DynamicTestClass2;
+ import flexUnitTests.network.support.TestClass1;
+ import flexUnitTests.network.support.TestClass2;
+ import flexUnitTests.network.support.TestClass3;
+ import flexUnitTests.network.support.TestClass4;
+ import flexUnitTests.network.support.DynamicTestClass;
+
+ import flexunit.framework.Assert;
+
import org.apache.royale.net.remoting.amf.AMFBinaryData;
- import org.apache.royale.reflection.*;
-
-
+ import org.apache.royale.reflection.*;
+
+
public class AMFBinaryDataTesterTest
- {
-
- [Before]
- public function setUp():void {
- }
-
- [After]
- public function tearDown():void {
- }
-
- [BeforeClass]
- public static function setUpBeforeClass():void {
- }
-
- [AfterClass]
- public static function tearDownAfterClass():void {
- }
-
-
- //util check functions
- private static function bytesMatchExpectedData(bd:AMFBinaryData,expected:Array,offset:int=0):Boolean{
- var len:uint = expected.length;
- var end:uint=offset+len;
- for (var i:int=offset;i<end;i++) {
- var check:uint = bd.readByteAt(i);
- if (expected[i-offset]!=check) {
- // trace('failed at ',i,expected[i-offset],check);
- return false;
- }
- }
- return true;
- }
-
- private static function dynamicKeyCountMatches(forObject:Object, expectedCount:uint):Boolean{
- var keyCount:uint=0;
- for (var key:String in forObject) {
- keyCount++;
- }
- return keyCount === expectedCount;
-
- }
-
- [Test]
- public function testStringObjectEncoding():void{
- var ba:AMFBinaryData = new AMFBinaryData();
- var testString:String = 'testString';
-
- ba.writeObject(testString);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 12);
- Assert.assertEquals("post-write position was not correct", ba.position, 12);
- ba.position = 0;
- var readString:String = ba.readObject() as String;
- Assert.assertEquals("post-write read of written string was not correct", readString, testString);
- }
-
- [Test]
- public function testBooleanObjectEncoding():void{
- var ba:AMFBinaryData = new AMFBinaryData();
-
- ba.writeObject(false);
- ba.writeObject(true);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 2);
- Assert.assertEquals("post-write position was not correct", ba.position, 2);
- ba.position = 0;
-
- Assert.assertTrue("post-write read of written boolean was not correct", ba.readObject() === false);
- Assert.assertTrue("post-write read of written boolean was not correct", ba.readObject() === true);
- }
-
- [Test]
- public function testNumberEncoding():void{
- var ba:AMFBinaryData = new AMFBinaryData();
-
-
- ba.writeObject(NaN);
- ba.writeObject(1.0);
- ba.writeObject(-1.0);
- ba.writeObject(1.5);
- ba.writeObject(-1.5);
- ba.writeObject(Infinity);
- ba.writeObject(-Infinity);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 52);
- Assert.assertEquals("post-write position was not correct", ba.position, 52);
- ba.position = 0;
-
- var num:Number = ba.readObject();
- Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
- Assert.assertTrue("post-write read of written Number was not correct", isNaN(num));
- num = ba.readObject();
- Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
- Assert.assertTrue("post-write read of written Number was not correct", num === 1.0);
- num = ba.readObject();
- Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
- Assert.assertTrue("post-write read of written Number was not correct", num === -1.0);
- num = ba.readObject();
- Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
- Assert.assertTrue("post-write read of written Number was not correct", num === 1.5);
- num = ba.readObject();
- Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
- Assert.assertTrue("post-write read of written Number was not correct", num === -1.5);
- num = ba.readObject();
- Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
- Assert.assertTrue("post-write read of written Number was not correct", !isFinite(num));
- Assert.assertTrue("post-write read of written Number was not correct", (num > 0));
- num = ba.readObject();
- Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
- Assert.assertTrue("post-write read of written Number was not correct", !isFinite(num));
- Assert.assertTrue("post-write read of written Number was not correct", (num < 0));
- }
-
-
- [Test]
- public function testArrayInstance():void {
- var ba:AMFBinaryData = new AMFBinaryData();
- var instance:Array = [];
- ba.writeObject(instance);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 3);
- Assert.assertEquals("post-write position was not correct", ba.position, 3);
-
- instance = [99];
- ba.length = 0;
- ba.writeObject(instance);
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 3, 1, 4, 99]));
- instance = ba.readObject() as Array;
- Assert.assertTrue("post-write read did not match expected result", instance.length == 1 && instance[0] == 99);
- //sparse array
- instance =[];
- instance[100]='100';
- ba.length = 0;
- ba.writeObject(instance);
- Assert.assertEquals("post-write length was not correct", ba.length, 9);
- Assert.assertEquals("post-write position was not correct", ba.position, 9);
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 1, 7, 49, 48, 48, 6, 0, 1]));
- //check that read matches
- ba.position = 0;
- instance = ba.readObject();
-
- Assert.assertEquals("post-write read was not correct", instance.length, 101);
- Assert.assertEquals("post-write read was not correct", instance[100], '100');
- Assert.assertTrue("post-write read was not correct", instance[0] === undefined);
- //sparse with associative content
- instance=[];
- instance['test'] = true;
- instance[10] = 'I am number 10';
- ba.length = 0;
- ba.writeObject(instance);
- Assert.assertEquals("post-write length was not correct", ba.length, 28);
- Assert.assertEquals("post-write position was not correct", ba.position, 28);
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 1, 5, 49, 48, 6, 29, 73, 32, 97, 109, 32, 110, 117, 109, 98, 101, 114, 32, 49, 48, 9, 116, 101, 115, 116, 3, 1]));
-
- //check that read matches
- ba.position = 0;
- instance = ba.readObject();
- Assert.assertEquals("post-write read was not correct", instance.length, 11);
- Assert.assertEquals("post-write read was not correct", instance[10], 'I am number 10');
- Assert.assertEquals("post-write read was not correct", instance['test'], true);
- Assert.assertTrue("post-write read was not correct", instance[0] === undefined);
-
- //edge cases
- instance=[];
- //length ==2 and Object.keys().length ==2
- //but no dense keys;
- instance[1]=true;
- instance['test'] = true;
- ba.length = 0;
- ba.writeObject(instance);
- Assert.assertEquals("post-write length was not correct", ba.length, 12);
- Assert.assertEquals("post-write position was not correct", ba.position, 12);
-
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 1, 3, 49, 3, 9, 116, 101, 115, 116, 3, 1]));
-
- //empty array with length
- instance = new Array(100);
- Assert.assertEquals("pre-write array length was not correct", instance.length, 100);
- ba.length = 0;
- ba.writeObject(instance);
- Assert.assertEquals("post-write length was not correct", ba.length, 3);
- Assert.assertEquals("post-write position was not correct", ba.position, 3);
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 1, 1]));
-
- ba.position = 0;
- instance = ba.readObject() as Array;
- //although the Array had a length of 100 on write, it has length zero on read:
- Assert.assertTrue("post-write read did not match expected value", instance.length == 0);
-
- var ar:Array = [1,2,3];
- var f:Function = function():void{trace('func')};
- ar['__AS3__.vec'] = f;
- ba.length=0;
- ba.writeObject(ar);
- Assert.assertEquals("post-write length was not correct", ba.length, 9);
- Assert.assertEquals("post-write position was not correct", ba.position, 9);
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 7, 1, 4, 1, 4, 2, 4, 3]));
- ar = [f, 1, 2, 3, f];
- ba.length=0;
- ba.writeObject(ar);
- Assert.assertEquals("post-write length was not correct", ba.length, 15);
- Assert.assertEquals("post-write position was not correct", ba.position, 15);
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 1, 3, 49, 4, 1, 3, 50, 4, 2, 3, 51, 4, 3, 1]));
- //post write read is an array with length of 4 instead of 5.
- ba.position = 0;
- ar = ba.readObject();
- Assert.assertEquals("post-write read length was not correct", ar.length, 4);
-
-
- ar = [Object, 1, 2, 3, Object];
- ba.length=0;
- ba.writeObject(ar);
- Assert.assertEquals("post-write length was not correct", ba.length, 15);
- Assert.assertEquals("post-write position was not correct", ba.position, 15);
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 11, 1, 10, 11, 1, 1, 4, 1, 4, 2, 4, 3, 10, 2]));
-
-
- }
-
-
- [Test]
- public function testAnonObject():void{
- var ba:AMFBinaryData = new AMFBinaryData();
-
- var instance:Object = {};
- ba.writeObject(instance);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 4);
- Assert.assertEquals("post-write position was not correct", ba.position, 4);
- ba.position = 0;
-
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 11, 1, 1]));
- instance = ba.readObject();
- Assert.assertTrue("post-write read did not match expected result", dynamicKeyCountMatches(instance, 0));
-
- var obj1:Object = {test:true};
- var obj2:Object = {test:'maybe'};
- var obj3:Object = {test:true};
- ba.length = 0;
- ba.writeObject([obj1, obj2, obj3]);
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 7, 1, 10, 11, 1, 9, 116, 101, 115, 116, 3, 1, 10, 1, 0, 6, 11, 109, 97, 121, 98, 101, 1, 10, 1, 0, 3, 1]));
-
- }
-
-
- [Test]
- public function testFunction():void{
- var ba:AMFBinaryData = new AMFBinaryData();
- //functions are always encoded as undefined
- var instance:Function = function():void {};
- ba.writeObject(instance);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 1);
- Assert.assertEquals("post-write position was not correct", ba.position, 1);
- ba.position = 0;
-
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[0]));
- instance = ba.readObject();
-
- Assert.assertTrue("post-write read did not match expected result", instance === null);
-
- //for a property that has a function value, the property is also undefined
- var objectWithFunction:Object = {'function': function():void {}};
- ba.length=0;
- ba.writeObject(objectWithFunction);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 4);
- Assert.assertEquals("post-write position was not correct", ba.position, 4);
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 11, 1, 1]));
-
- //the dynamic deserialized object has no key for the function value
- var obj:Object = ba.readObject();
- Assert.assertTrue("post-write read did not match expected result", dynamicKeyCountMatches(obj,0));
-
- ba.length=0;
- var tc4:TestClass4 = new TestClass4();
- tc4.testField1 =function():void {};
-
- ba.writeObject(tc4);
- Assert.assertEquals("post-write length was not correct", ba.length, 15);
- Assert.assertEquals("post-write position was not correct", ba.position, 15);
-
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 19, 1, 21, 116, 101, 115, 116, 70, 105, 101, 108, 100, 49, 0]));
-
- }
-
-
- [Test]
- /**
- * @royaleignorecoercion TestClass1
- */
- public function testBasicClassInstance():void
- {
- var ba:AMFBinaryData = new AMFBinaryData();
-
- var instance:TestClass1 = new TestClass1();
- ba.writeObject(instance);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 16);
- Assert.assertEquals("post-write position was not correct", ba.position, 16);
-
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 19, 1, 21, 116, 101, 115, 116, 70, 105, 101, 108, 100, 49, 6, 1]));
- ba.position = 0;
-
- var anonObject:Object = ba.readObject();
-
- Assert.assertTrue('post-write read did not match expected value', anonObject['testField1'] === instance.testField1 );
-
- var multipleDifferentInstances:Array = [new TestClass1(), new TestClass2()];
- ba.length = 0;
- ba.writeObject(multipleDifferentInstances);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 24);
- Assert.assertEquals("post-write position was not correct", ba.position, 24);
- ba.position = 0;
-
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 5, 1, 10, 19, 1, 21, 116, 101, 115, 116, 70, 105, 101, 108, 100, 49, 6, 1, 10, 19, 1, 0, 3]));
-
- }
-
- [Test]
- public function testDynamicClassInstance():void
- {
- var ba:AMFBinaryData = new AMFBinaryData();
- var instance:DynamicTestClass = new DynamicTestClass();
- ba.writeObject(instance);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 25);
- Assert.assertEquals("post-write position was not correct", ba.position, 25);
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 1]));
-
- instance['someDynamicField'] = 'nonSealedPropValue';
-
- ba.writeObject(instance);
- Assert.assertEquals("post-write length was not correct", ba.length, 62);
- Assert.assertEquals("post-write position was not correct", ba.position, 62);
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 33, 115, 111, 109, 101, 68, 121, 110, 97, 109, 105, 99, 70, 105, 101, 108, 100, 6, 37, 110, 111, 110, 83, 101, 97, 108, 101, 100, 80, 114, 111, 112, 86, 97, 108, 117, 101, 1]));
-
- var instanceAnon:Object = ba.readObject();
- Assert.assertTrue('post-write read did not match expected value', instanceAnon['someDynamicField'] === 'nonSealedPropValue' );
-
-
- }
-
- [Test]
- public function testByteArray():void{
- //on swf it is native ByteArray that encodes to 'ByteArray', in js it is AMFBinaryData
- COMPILE::SWF{
- import flash.utils.ByteArray;
- var source:ByteArray = new ByteArray();
- }
-
- COMPILE::JS{
- var source:AMFBinaryData = new AMFBinaryData();
- }
-
- for (var i:uint=0;i<26;i++) source.writeByte(i);
- var ba:AMFBinaryData = new AMFBinaryData();
- var holder:Array = [source, source];
-
- ba.writeObject(holder);
- Assert.assertEquals("post-write error length was not correct", ba.length, 33);
- Assert.assertEquals("post-write error position was not correct", ba.position, 33);
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[9, 5, 1, 12, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 12, 2]));
- }
-
-
- [Test]
- public function testExternalizable():void
- {
- var ba:AMFBinaryData = new AMFBinaryData();
- var test3:TestClass3 = new TestClass3();
- //TestClass3 is externalizable and does not have an alias, this is an error in flash
-
- var err:Error;
- try {
- ba.writeObject(test3);
- } catch(e:Error) {
- err = e;
- }
-
- Assert.assertTrue("externalizable writing should fail without an alias registered", err != null);
- Assert.assertEquals("post-write error length was not correct", ba.length, 1);
- Assert.assertEquals("post-write error position was not correct", ba.position, 1);
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10]));
-
- ba.length=0;
- //register an alias
- registerClassAlias('TestClass3', TestClass3);
- ba.writeObject(test3);
- Assert.assertEquals("post-write length was not correct", ba.length, 18);
- Assert.assertEquals("post-write position was not correct", ba.position, 18);
-
- ba.position = 0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 7, 21, 84, 101, 115, 116, 67, 108, 97, 115, 115, 51, 9, 3, 1, 6, 0]));
-
- test3.content[0] = (test3.content[0]).split("").reverse().join("");
- ba.writeObject(test3);
- Assert.assertEquals("post-write length was not correct", ba.length, 28);
- Assert.assertEquals("post-write position was not correct", ba.position, 28);
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 7, 21, 84, 101, 115, 116, 67, 108, 97, 115, 115, 51, 9, 3, 1, 6, 21, 51, 115, 115, 97, 108, 67, 116, 115, 101, 84]));
-
- ba.position=0;
- var test3Read:TestClass3 = ba.readObject() as TestClass3;
-
- //proof that it created a new instance, and that the reversed content string content is present in the new instance
- Assert.assertTrue("post-write read did not match expected data", test3Read.content[0] == test3.content[0]);
-
- }
-
-
- [Test]
- public function testDynamicPropertyWriter():void{
- var ba:AMFBinaryData = new AMFBinaryData();
- var instance:DynamicTestClass2 = new DynamicTestClass2();
- instance['_underscore'] = 'pseudo - private value';
- instance['raining'] = 'cats and dogs';
-
- ba.writeObject(instance);
-
- Assert.assertEquals("post-write length was not correct", ba.length, 84);
- Assert.assertEquals("post-write position was not correct", ba.position, 84);
-
- //in this case the order of encoding the dynamic fields is not defined. So we need to account for the valid serialization options of either output sequence of the two fields
- var raining_then_underscore:Array = [10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 15, 114, 97, 105, 110, 105, 110, 103, 6, 27, 99, 97, 116, 115, 32, 97, 110, 100, 32, 100, 111, 103, 115, 23, 95, 117, 110, 100, 101, 114, 115, 99, 111, 114, 101, 6, 45, 112, 115, 101, 117, 100, 111, 32, 45, 32, 112, 114, 105, 118, 97, 116, 101, 32, 118, 97, 108, 117, 101, 1];
- var underscore_then_raining:Array = [10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 23, 95, 117, 110, 100, 101, 114, 115, 99, 111, 114, 101, 6, 45, 112, 115, 101, 117, 100, 111, 32, 45, 32, 112, 114, 105, 118, 97, 116, 101, 32, 118, 97, 108, 117, 101, 15, 114, 97, 105, 110, 105, 110, 103, 6, 27, 99, 97, 116, 115, 32, 97, 110, 100, 32, 100, 111, 103, 115, 1];
-
- ba.position=0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, raining_then_underscore) || bytesMatchExpectedData(ba, underscore_then_raining));
-
- //now test the same instance with an IDynamicPropertyWriter that ignores the underscored field, only outputting the 'raining' field
- ba.length = 0;
- AMFBinaryData.dynamicPropertyWriter = new DynamicPropertyWriter();
- ba.writeObject(instance);
- Assert.assertEquals("post-write length was not correct", ba.length, 48);
- Assert.assertEquals("post-write position was not correct", ba.position, 48);
- ba.position=0;
- Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba,[10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 15, 114, 97, 105, 110, 105, 110, 103, 6, 27, 99, 97, 116, 115, 32, 97, 110, 100, 32, 100, 111, 103, 115, 1]));
-
- //remove the custom dynamicPropertyWriter
- AMFBinaryData.dynamicPropertyWriter = null;
-
- }
-
- [Test]
- public function testXML():void{
- var ba:AMFBinaryData = new AMFBinaryData();
- var xml:XML = <xml><item/></xml>;
-
- ba.writeObject(xml);
- ba.position = 0;
-
- var xml2:XML = ba.readObject() as XML;
-
- //javascript toXMLString pretty printing does not match exactly flash...
- Assert.assertTrue('XML round-tripping failed', xml.toXMLString() === xml2.toXMLString());
- }
-
- }
+ {
+
+ [Before]
+ public function setUp():void
+ {
+ }
+
+ [After]
+ public function tearDown():void
+ {
+ }
+
+ [BeforeClass]
+ public static function setUpBeforeClass():void
+ {
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ }
+
+
+ //util check functions
+ private static function bytesMatchExpectedData(bd:AMFBinaryData, expected:Array, offset:int = 0):Boolean
+ {
+ var len:uint = expected.length;
+ var end:uint = offset + len;
+ for (var i:int = offset; i < end; i++)
+ {
+ var check:uint = bd.readByteAt(i);
+ if (expected[i - offset] != check)
+ {
+ // trace('failed at ',i,expected[i-offset],check);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static function dynamicKeyCountMatches(forObject:Object, expectedCount:uint):Boolean
+ {
+ var keyCount:uint = 0;
+ for (var key:String in forObject)
+ {
+ keyCount++;
+ }
+ return keyCount === expectedCount;
+
+ }
+
+ [Test]
+ public function testStringObjectEncoding():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+ var testString:String = 'testString';
+
+ ba.writeObject(testString);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 12);
+ Assert.assertEquals("post-write position was not correct", ba.position, 12);
+ ba.position = 0;
+ var readString:String = ba.readObject() as String;
+ Assert.assertEquals("post-write read of written string was not correct", readString, testString);
+ }
+
+ [Test]
+ public function testBooleanObjectEncoding():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+
+ ba.writeObject(false);
+ ba.writeObject(true);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 2);
+ Assert.assertEquals("post-write position was not correct", ba.position, 2);
+ ba.position = 0;
+
+ Assert.assertTrue("post-write read of written boolean was not correct", ba.readObject() === false);
+ Assert.assertTrue("post-write read of written boolean was not correct", ba.readObject() === true);
+ }
+
+ [Test]
+ public function testNumberEncoding():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+
+
+ ba.writeObject(NaN);
+ ba.writeObject(1.0);
+ ba.writeObject(-1.0);
+ ba.writeObject(1.5);
+ ba.writeObject(-1.5);
+ ba.writeObject(Infinity);
+ ba.writeObject(-Infinity);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 52);
+ Assert.assertEquals("post-write position was not correct", ba.position, 52);
+ ba.position = 0;
+
+ var num:Number = ba.readObject();
+ Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
+ Assert.assertTrue("post-write read of written Number was not correct", isNaN(num));
+ num = ba.readObject();
+ Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
+ Assert.assertTrue("post-write read of written Number was not correct", num === 1.0);
+ num = ba.readObject();
+ Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
+ Assert.assertTrue("post-write read of written Number was not correct", num === -1.0);
+ num = ba.readObject();
+ Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
+ Assert.assertTrue("post-write read of written Number was not correct", num === 1.5);
+ num = ba.readObject();
+ Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
+ Assert.assertTrue("post-write read of written Number was not correct", num === -1.5);
+ num = ba.readObject();
+ Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
+ Assert.assertTrue("post-write read of written Number was not correct", !isFinite(num));
+ Assert.assertTrue("post-write read of written Number was not correct", (num > 0));
+ num = ba.readObject();
+ Assert.assertTrue("post-write read of written Number was not correct", (num is Number));
+ Assert.assertTrue("post-write read of written Number was not correct", !isFinite(num));
+ Assert.assertTrue("post-write read of written Number was not correct", (num < 0));
+ }
+
+
+ [Test]
+ public function testArrayInstance():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+ var instance:Array = [];
+ ba.writeObject(instance);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 3);
+ Assert.assertEquals("post-write position was not correct", ba.position, 3);
+
+ instance = [99];
+ ba.length = 0;
+ ba.writeObject(instance);
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 3, 1, 4, 99]));
+ instance = ba.readObject() as Array;
+ Assert.assertTrue("post-write read did not match expected result", instance.length == 1 && instance[0] == 99);
+ //sparse array
+ instance = [];
+ instance[100] = '100';
+ ba.length = 0;
+ ba.writeObject(instance);
+ Assert.assertEquals("post-write length was not correct", ba.length, 9);
+ Assert.assertEquals("post-write position was not correct", ba.position, 9);
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 1, 7, 49, 48, 48, 6, 0, 1]));
+ //check that read matches
+ ba.position = 0;
+ instance = ba.readObject();
+
+ Assert.assertEquals("post-write read was not correct", instance.length, 101);
+ Assert.assertEquals("post-write read was not correct", instance[100], '100');
+ Assert.assertTrue("post-write read was not correct", instance[0] === undefined);
+ //sparse with associative content
+ instance = [];
+ instance['test'] = true;
+ instance[10] = 'I am number 10';
+ ba.length = 0;
+ ba.writeObject(instance);
+ Assert.assertEquals("post-write length was not correct", ba.length, 28);
+ Assert.assertEquals("post-write position was not correct", ba.position, 28);
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 1, 5, 49, 48, 6, 29, 73, 32, 97, 109, 32, 110, 117, 109, 98, 101, 114, 32, 49, 48, 9, 116, 101, 115, 116, 3, 1]));
+
+ //check that read matches
+ ba.position = 0;
+ instance = ba.readObject();
+ Assert.assertEquals("post-write read was not correct", instance.length, 11);
+ Assert.assertEquals("post-write read was not correct", instance[10], 'I am number 10');
+ Assert.assertEquals("post-write read was not correct", instance['test'], true);
+ Assert.assertTrue("post-write read was not correct", instance[0] === undefined);
+
+ //edge cases
+ instance = [];
+ //length ==2 and Object.keys().length ==2
+ //but no dense keys;
+ instance[1] = true;
+ instance['test'] = true;
+ ba.length = 0;
+ ba.writeObject(instance);
+ Assert.assertEquals("post-write length was not correct", ba.length, 12);
+ Assert.assertEquals("post-write position was not correct", ba.position, 12);
+
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 1, 3, 49, 3, 9, 116, 101, 115, 116, 3, 1]));
+
+ //empty array with length
+ instance = new Array(100);
+ Assert.assertEquals("pre-write array length was not correct", instance.length, 100);
+ ba.length = 0;
+ ba.writeObject(instance);
+ Assert.assertEquals("post-write length was not correct", ba.length, 3);
+ Assert.assertEquals("post-write position was not correct", ba.position, 3);
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 1, 1]));
+
+ ba.position = 0;
+ instance = ba.readObject() as Array;
+ //although the Array had a length of 100 on write, it has length zero on read:
+ Assert.assertTrue("post-write read did not match expected value", instance.length == 0);
+
+ var ar:Array = [1, 2, 3];
+ var f:Function = function ():void
+ {
+ trace('func')
+ };
+ ar['__AS3__.vec'] = f;
+ ba.length = 0;
+ ba.writeObject(ar);
+ Assert.assertEquals("post-write length was not correct", ba.length, 9);
+ Assert.assertEquals("post-write position was not correct", ba.position, 9);
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 7, 1, 4, 1, 4, 2, 4, 3]));
+ ar = [f, 1, 2, 3, f];
+ ba.length = 0;
+ ba.writeObject(ar);
+ Assert.assertEquals("post-write length was not correct", ba.length, 15);
+ Assert.assertEquals("post-write position was not correct", ba.position, 15);
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 1, 3, 49, 4, 1, 3, 50, 4, 2, 3, 51, 4, 3, 1]));
+ //post write read is an array with length of 4 instead of 5.
+ ba.position = 0;
+ ar = ba.readObject();
+ Assert.assertEquals("post-write read length was not correct", ar.length, 4);
+
+
+ ar = [Object, 1, 2, 3, Object];
+ ba.length = 0;
+ ba.writeObject(ar);
+ Assert.assertEquals("post-write length was not correct", ba.length, 15);
+ Assert.assertEquals("post-write position was not correct", ba.position, 15);
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 11, 1, 10, 11, 1, 1, 4, 1, 4, 2, 4, 3, 10, 2]));
+
+
+ }
+
+
+ [Test]
+ public function testAnonObject():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+
+ var instance:Object = {};
+ ba.writeObject(instance);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 4);
+ Assert.assertEquals("post-write position was not correct", ba.position, 4);
+ ba.position = 0;
+
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 11, 1, 1]));
+ instance = ba.readObject();
+ Assert.assertTrue("post-write read did not match expected result", dynamicKeyCountMatches(instance, 0));
+
+ var obj1:Object = {test: true};
+ var obj2:Object = {test: 'maybe'};
+ var obj3:Object = {test: true};
+ ba.length = 0;
+ ba.writeObject([obj1, obj2, obj3]);
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 7, 1, 10, 11, 1, 9, 116, 101, 115, 116, 3, 1, 10, 1, 0, 6, 11, 109, 97, 121, 98, 101, 1, 10, 1, 0, 3, 1]));
+
+ }
+
+
+ [Test]
+ public function testFunction():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+ //functions are always encoded as undefined
+ var instance:Function = function ():void
+ {
+ };
+ ba.writeObject(instance);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 1);
+ Assert.assertEquals("post-write position was not correct", ba.position, 1);
+ ba.position = 0;
+
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [0]));
+ instance = ba.readObject();
+
+ Assert.assertTrue("post-write read did not match expected result", instance === null);
+
+ //for a property that has a function value, the property is also undefined
+ var objectWithFunction:Object = {
+ 'function': function ():void
+ {
+ }
+ };
+ ba.length = 0;
+ ba.writeObject(objectWithFunction);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 4);
+ Assert.assertEquals("post-write position was not correct", ba.position, 4);
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 11, 1, 1]));
+
+ //the dynamic deserialized object has no key for the function value
+ var obj:Object = ba.readObject();
+ Assert.assertTrue("post-write read did not match expected result", dynamicKeyCountMatches(obj, 0));
+
+ ba.length = 0;
+ var tc4:TestClass4 = new TestClass4();
+ tc4.testField1 = function ():void
+ {
+ };
+
+ ba.writeObject(tc4);
+ Assert.assertEquals("post-write length was not correct", ba.length, 15);
+ Assert.assertEquals("post-write position was not correct", ba.position, 15);
+
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 19, 1, 21, 116, 101, 115, 116, 70, 105, 101, 108, 100, 49, 0]));
+
+ }
+
+
+ [Test]
+ /**
+ * @royaleignorecoercion TestClass1
+ */
+ public function testBasicClassInstance():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+
+ var instance:TestClass1 = new TestClass1();
+ ba.writeObject(instance);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 16);
+ Assert.assertEquals("post-write position was not correct", ba.position, 16);
+
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 19, 1, 21, 116, 101, 115, 116, 70, 105, 101, 108, 100, 49, 6, 1]));
+ ba.position = 0;
+
+ var anonObject:Object = ba.readObject();
+
+ Assert.assertTrue('post-write read did not match expected value', anonObject['testField1'] === instance.testField1);
+
+ var multipleDifferentInstances:Array = [new TestClass1(), new TestClass2()];
+ ba.length = 0;
+ ba.writeObject(multipleDifferentInstances);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 24);
+ Assert.assertEquals("post-write position was not correct", ba.position, 24);
+ ba.position = 0;
+
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 5, 1, 10, 19, 1, 21, 116, 101, 115, 116, 70, 105, 101, 108, 100, 49, 6, 1, 10, 19, 1, 0, 3]));
+
+ }
+
+ [Test]
+ public function testDynamicClassInstance():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+ var instance:DynamicTestClass = new DynamicTestClass();
+ ba.writeObject(instance);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 25);
+ Assert.assertEquals("post-write position was not correct", ba.position, 25);
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 1]));
+
+ instance['someDynamicField'] = 'nonSealedPropValue';
+
+ ba.writeObject(instance);
+ Assert.assertEquals("post-write length was not correct", ba.length, 62);
+ Assert.assertEquals("post-write position was not correct", ba.position, 62);
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 33, 115, 111, 109, 101, 68, 121, 110, 97, 109, 105, 99, 70, 105, 101, 108, 100, 6, 37, 110, 111, 110, 83, 101, 97, 108, 101, 100, 80, 114, 111, 112, 86, 97, 108, 117, 101, 1]));
+
+ var instanceAnon:Object = ba.readObject();
+ Assert.assertTrue('post-write read did not match expected value', instanceAnon['someDynamicField'] === 'nonSealedPropValue');
+
+
+ }
+
+ [Test]
+ public function testByteArray():void
+ {
+ //on swf it is native ByteArray that encodes to 'ByteArray', in js it is AMFBinaryData
+ COMPILE::SWF{
+ import flash.utils.ByteArray;
+
+ var source:ByteArray = new ByteArray();
+ }
+
+ COMPILE::JS{
+ var source:AMFBinaryData = new AMFBinaryData();
+ }
+
+ for (var i:uint = 0; i < 26; i++) source.writeByte(i);
+ var ba:AMFBinaryData = new AMFBinaryData();
+ var holder:Array = [source, source];
+
+ ba.writeObject(holder);
+ Assert.assertEquals("post-write error length was not correct", ba.length, 33);
+ Assert.assertEquals("post-write error position was not correct", ba.position, 33);
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [9, 5, 1, 12, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 12, 2]));
+ }
+
+
+ [Test]
+ public function testExternalizable():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+ var test3:TestClass3 = new TestClass3();
+ //TestClass3 is externalizable and does not have an alias, this is an error in flash
+
+ var err:Error;
+ try
+ {
+ ba.writeObject(test3);
+ } catch (e:Error)
+ {
+ err = e;
+ }
+
+ Assert.assertTrue("externalizable writing should fail without an alias registered", err != null);
+ Assert.assertEquals("post-write error length was not correct", ba.length, 1);
+ Assert.assertEquals("post-write error position was not correct", ba.position, 1);
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10]));
+
+ ba.length = 0;
+ //register an alias
+ registerClassAlias('TestClass3', TestClass3);
+ ba.writeObject(test3);
+ Assert.assertEquals("post-write length was not correct", ba.length, 18);
+ Assert.assertEquals("post-write position was not correct", ba.position, 18);
+
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 7, 21, 84, 101, 115, 116, 67, 108, 97, 115, 115, 51, 9, 3, 1, 6, 0]));
+
+ test3.content[0] = (test3.content[0]).split("").reverse().join("");
+ ba.writeObject(test3);
+ Assert.assertEquals("post-write length was not correct", ba.length, 28);
+ Assert.assertEquals("post-write position was not correct", ba.position, 28);
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 7, 21, 84, 101, 115, 116, 67, 108, 97, 115, 115, 51, 9, 3, 1, 6, 21, 51, 115, 115, 97, 108, 67, 116, 115, 101, 84]));
+
+ ba.position = 0;
+ var test3Read:TestClass3 = ba.readObject() as TestClass3;
+
+ //proof that it created a new instance, and that the reversed content string content is present in the new instance
+ Assert.assertTrue("post-write read did not match expected data", test3Read.content[0] == test3.content[0]);
+
+ }
+
+
+ [Test]
+ public function testDynamicPropertyWriter():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+ var instance:DynamicTestClass2 = new DynamicTestClass2();
+ instance['_underscore'] = 'pseudo - private value';
+ instance['raining'] = 'cats and dogs';
+
+ ba.writeObject(instance);
+
+ Assert.assertEquals("post-write length was not correct", ba.length, 84);
+ Assert.assertEquals("post-write position was not correct", ba.position, 84);
+
+ //in this case the order of encoding the dynamic fields is not defined. So we need to account for the valid serialization options of either output sequence of the two fields
+ var raining_then_underscore:Array = [10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 15, 114, 97, 105, 110, 105, 110, 103, 6, 27, 99, 97, 116, 115, 32, 97, 110, 100, 32, 100, 111, 103, 115, 23, 95, 117, 110, 100, 101, 114, 115, 99, 111, 114, 101, 6, 45, 112, 115, 101, 117, 100, 111, 32, 45, 32, 112, 114, 105, 118, 97, 116, 101, 32, 118, 97, 108, 117, 101, 1];
+ var underscore_then_raining:Array = [10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 23, 95, 117, 110, 100, 101, 114, 115, 99, 111, 114, 101, 6, 45, 112, 115, 101, 117, 100, 111, 32, 45, 32, 112, 114, 105, 118, 97, 116, 101, 32, 118, 97, 108, 117, 101, 15, 114, 97, 105, 110, 105, 110, 103, 6, 27, 99, 97, 116, 115, 32, 97, 110, 100, 32, 100, 111, 103, 115, 1];
+
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, raining_then_underscore) || bytesMatchExpectedData(ba, underscore_then_raining));
+
+ //now test the same instance with an IDynamicPropertyWriter that ignores the underscored field, only outputting the 'raining' field
+ ba.length = 0;
+ AMFBinaryData.dynamicPropertyWriter = new DynamicPropertyWriter();
+ ba.writeObject(instance);
+ Assert.assertEquals("post-write length was not correct", ba.length, 48);
+ Assert.assertEquals("post-write position was not correct", ba.position, 48);
+ ba.position = 0;
+ Assert.assertTrue("post-write bytes did not match expected data", bytesMatchExpectedData(ba, [10, 27, 1, 39, 115, 101, 97, 108, 101, 100, 73, 110, 115, 116, 97, 110, 99, 101, 80, 114, 111, 112, 49, 2, 15, 114, 97, 105, 110, 105, 110, 103, 6, 27, 99, 97, 116, 115, 32, 97, 110, 100, 32, 100, 111, 103, 115, 1]));
+
+ //remove the custom dynamicPropertyWriter
+ AMFBinaryData.dynamicPropertyWriter = null;
+
+ }
+
+ [Test]
+ public function testXML():void
+ {
+ var ba:AMFBinaryData = new AMFBinaryData();
+ var xml:XML = <xml><item/></xml>;
+
+ ba.writeObject(xml);
+ ba.position = 0;
+
+ var xml2:XML = ba.readObject() as XML;
+
+ //javascript toXMLString pretty printing does not match exactly flash...
+ Assert.assertTrue('XML round-tripping failed', xml.toXMLString() === xml2.toXMLString());
+ }
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicPropertyWriter.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicPropertyWriter.as
index 293da6b..ccc4b33 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicPropertyWriter.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicPropertyWriter.as
@@ -18,38 +18,44 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.network.support
{
- import org.apache.royale.utils.net.IDynamicPropertyWriter;
- import org.apache.royale.reflection.*;
- COMPILE::JS{
- import org.apache.royale.utils.net.IDynamicPropertyOutput;
- }
-
- COMPILE::SWF{
- import flash.net.IDynamicPropertyOutput;
- }
-
-
- public class DynamicPropertyWriter implements IDynamicPropertyWriter
- {
- //Note: do not change this test class unless you change the related tests to
- //support any changes that might appear when testing with it
-
-
- public function DynamicPropertyWriter() {
- // constructor code
- }
-
- public var excludeBeginningUnderscores:Boolean = true;
-
- public function writeDynamicProperties(obj:Object, output:IDynamicPropertyOutput):void {
- var dynamicProperties:Array = getDynamicFields(obj);
- while (dynamicProperties.length) {
- var prop:String = dynamicProperties.shift();
- if (excludeBeginningUnderscores && (prop.charAt(0) == '_')) continue;
- output.writeDynamicProperty(prop,obj[prop]);
- }
- }
-
- }
-
+ import org.apache.royale.utils.net.IDynamicPropertyWriter;
+ import org.apache.royale.reflection.*;
+
+ COMPILE::JS{
+ import org.apache.royale.utils.net.IDynamicPropertyOutput;
+ }
+
+ COMPILE::SWF{
+ import flash.net.IDynamicPropertyOutput;
+ }
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class DynamicPropertyWriter implements IDynamicPropertyWriter
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing with it
+
+
+ public function DynamicPropertyWriter()
+ {
+ // constructor code
+ }
+
+ public var excludeBeginningUnderscores:Boolean = true;
+
+ public function writeDynamicProperties(obj:Object, output:IDynamicPropertyOutput):void
+ {
+ var dynamicProperties:Array = getDynamicFields(obj);
+ while (dynamicProperties.length)
+ {
+ var prop:String = dynamicProperties.shift();
+ if (excludeBeginningUnderscores && (prop.charAt(0) == '_')) continue;
+ output.writeDynamicProperty(prop, obj[prop]);
+ }
+ }
+
+ }
+
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicTestClass.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicTestClass.as
index 9c29fe8..703479d 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicTestClass.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicTestClass.as
@@ -18,17 +18,19 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.network.support
{
-
-
-
- dynamic public class DynamicTestClass
- {
- //Note: do not change this test class unless you change the related tests to
- //support any changes that might appear when testing with it
-
-
- public var sealedInstanceProp1:Boolean;
-
-
- }
+
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ dynamic public class DynamicTestClass
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing with it
+
+
+ public var sealedInstanceProp1:Boolean;
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicTestClass2.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicTestClass2.as
index fd3599e..2e72d2c 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicTestClass2.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/DynamicTestClass2.as
@@ -18,17 +18,19 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.network.support
{
-
-
-
- dynamic public class DynamicTestClass2
- {
- //Note: do not change this test class unless you change the related tests to
- //support any changes that might appear when testing with it
-
-
- public var sealedInstanceProp1:Boolean;
-
-
- }
+
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ dynamic public class DynamicTestClass2
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing with it
+
+
+ public var sealedInstanceProp1:Boolean;
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass1.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass1.as
index 80ce7e7..3ccc02f 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass1.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass1.as
@@ -18,17 +18,17 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.network.support
{
-
- public class TestClass1
- {
- public function TestClass1()
- {
- }
-
- public var testField1:String = '';
-
-
-
-
- }
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class TestClass1
+ {
+ public function TestClass1()
+ {
+ }
+
+ public var testField1:String = '';
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass2.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass2.as
index d586d93..e98f23c 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass2.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass2.as
@@ -18,19 +18,22 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.network.support
{
-
-
- public class TestClass2
- {
- //Note: do not change this test class unless you change the related tests to
- //support any changes that might appear when testing reflection into it
-
- public function TestClass2(){
-
- }
-
-
- public var testField1:Boolean = true;
-
- }
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class TestClass2
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing reflection into it
+
+ public function TestClass2()
+ {
+
+ }
+
+
+ public var testField1:Boolean = true;
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass3.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass3.as
index fb8bb7c..a82137c 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass3.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass3.as
@@ -18,33 +18,38 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.network.support
{
- import org.apache.royale.utils.net.IExternalizable;
- COMPILE::JS{
- import org.apache.royale.utils.net.IDataInput;
- import org.apache.royale.utils.net.IDataOutput;
- }
-
- COMPILE::SWF{
- import flash.utils.IDataInput;
- import flash.utils.IDataOutput;
- }
-
-
- public class TestClass3 implements IExternalizable
- {
-
- public var content:Array=["TestClass3"];
-
-
- public function readExternal(input:IDataInput):void{
- var content:Array = input.readObject() as Array;
- this.content = content;
- }
-
- public function writeExternal(output:IDataOutput):void {
- output.writeObject(content);
- }
-
- }
-
+ import org.apache.royale.utils.net.IExternalizable;
+
+ COMPILE::JS{
+ import org.apache.royale.utils.net.IDataInput;
+ import org.apache.royale.utils.net.IDataOutput;
+ }
+
+ COMPILE::SWF{
+ import flash.utils.IDataInput;
+ import flash.utils.IDataOutput;
+ }
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class TestClass3 implements IExternalizable
+ {
+
+ public var content:Array = ["TestClass3"];
+
+
+ public function readExternal(input:IDataInput):void
+ {
+ var content:Array = input.readObject() as Array;
+ this.content = content;
+ }
+
+ public function writeExternal(output:IDataOutput):void
+ {
+ output.writeObject(content);
+ }
+
+ }
+
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass4.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass4.as
index 85f86e0..c40e523 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass4.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/network/support/TestClass4.as
@@ -18,15 +18,17 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.network.support
{
-
- public class TestClass4
- {
- public function TestClass4()
- {
- }
-
- public var testField1:Function;
-
-
- }
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class TestClass4
+ {
+ public function TestClass4()
+ {
+ }
+
+ public var testField1:Function;
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/observedbugs/ObservedBugTests.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/observedbugs/ObservedBugTests.as
index e1eeede..a0a3f52 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/observedbugs/ObservedBugTests.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/observedbugs/ObservedBugTests.as
@@ -19,25 +19,33 @@
package flexUnitTests.observedbugs
{
import flexunit.framework.Assert;
+
import org.apache.royale.reflection.*;
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class ObservedBugTests
- {
-
+ {
+
public static var isJS:Boolean;
+
[BeforeClass]
public static function setUpBeforeClass():void
{
var js:Boolean = false;
- try {
+ try
+ {
var check:* = getDefinitionByName("flash.system.Capabilities");
- } catch (e:Error) {
+ } catch (e:Error)
+ {
js = true;
}
- //this was originally necessary to avoid a gcc-related bug in js for release mode only
- if (check == null) {
+ //this was originally necessary to avoid a gcc-related bug in js for release mode only,
+ // appears to be resolved in GCC now:
+ /*if (check == null) {
js = true;
- }
+ }*/
isJS = js;
}
@@ -45,8 +53,8 @@ package flexUnitTests.observedbugs
public static function tearDownAfterClass():void
{
}
-
- [Before]
+
+ [Before]
public function setUp():void
{
}
@@ -55,37 +63,41 @@ package flexUnitTests.observedbugs
public function tearDown():void
{
}
-
-
+
+
[Test]
public function testTryCatchJSReleaseModeWorks_a():void
{
var js:int = 1;
- try {
+ try
+ {
js = getDefinitionByName("flash.system.Capabilities") != null ? 1 : 0;
- } catch (e:Error) {
+ } catch (e:Error)
+ {
js = 2;
}
-
- Assert.assertTrue("Unexpected value following try/catch",(isJS ? (js == 2) : (js == 1)));
-
+
+ Assert.assertTrue("Unexpected value following try/catch", (isJS ? (js == 2) : (js == 1)));
+
}
-
- //This Observed bug is no longer present 0.9.0
- //it may be related to a Google Closure Compiler update since it was originally observed
- //leaving the tests in here for now...
- //[TestVariance(variance="JS",description="Variance in test, this test fails in JS-Release mode only")]
+
+ //This Observed bug is no longer present 0.9.0
+ //it may be related to a Google Closure Compiler update since it was originally observed
+ //leaving the tests in here for now...
+ //[TestVariance(variance="JS",description="Variance in test, this test fails in JS-Release mode only")]
[Test]
public function testTryCatchJSReleaseModeFails_b():void
{
var js:Boolean = false;
- try {
+ try
+ {
var check:* = getDefinitionByName("flash.system.Capabilities");
- } catch (e:Error) {
+ } catch (e:Error)
+ {
js = true;
}
-
- Assert.assertTrue("Unexpected value following try/catch",(isJS ? (js === true) : (js === false)));
+
+ Assert.assertTrue("Unexpected value following try/catch", (isJS ? (js === true) : (js === false)));
}
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTest.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTest.as
index 7bd9bee..452c3cd 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTest.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTest.as
@@ -19,26 +19,35 @@
package flexUnitTests.reflection
{
import flexunit.framework.Assert;
- import flexUnitTests.reflection.support.*;
+
+ import flexUnitTests.reflection.support.*;
+
import org.apache.royale.reflection.*;
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class ReflectionTesterTest
{
-
+
public static var isJS:Boolean;
+
[BeforeClass]
public static function setUpBeforeClass():void
{
var js:Boolean = false;
- try {
+ try
+ {
var check:* = getDefinitionByName("flash.system.Capabilities");
- } catch (e:Error) {
+ } catch (e:Error)
+ {
js = true;
}
//if this next reference to 'check' is not included, then the above try/catch code
//appears to be optimized away in js-release mode
//a separate test has been created for this
- if (check == null) {
+ if (check == null)
+ {
js = true;
}
isJS = js;
@@ -48,8 +57,8 @@ package flexUnitTests.reflection
public static function tearDownAfterClass():void
{
}
-
- [Before]
+
+ [Before]
public function setUp():void
{
TestClass2.testStaticVar = "testStaticVar_val";
@@ -60,324 +69,324 @@ package flexUnitTests.reflection
public function tearDown():void
{
}
-
- private static function retrieveItemWithName(collection:Array, name:String):DefinitionBase {
+
+ private static function retrieveItemWithName(collection:Array, name:String):DefinitionBase
+ {
var ret:DefinitionBase;
- var i:uint=0,l:uint=collection.length;
- for (;i<l;i++) {
- if (collection[i].name==name) {
+ var i:uint = 0, l:uint = collection.length;
+ for (; i < l; i++)
+ {
+ if (collection[i].name == name)
+ {
ret = collection[i];
break;
}
}
-
+
return ret;
}
-
-
+
+
[Test]
public function testBasicDescribeTypeClass():void
{
var def:TypeDefinition = describeType(TestClass2);
-
- Assert.assertEquals("Unexpected package name",def.packageName,"flexUnitTests.reflection.support");
- Assert.assertEquals("Unexpected type name",def.name,"TestClass2");
-
+
+ Assert.assertEquals("Unexpected package name", def.packageName, "flexUnitTests.reflection.support");
+ Assert.assertEquals("Unexpected type name", def.name, "TestClass2");
+
var variables:Array = def.variables;
- Assert.assertEquals("unexpected variables length",1,variables.length);
-
-
+ Assert.assertEquals("unexpected variables length", 1, variables.length);
+
+
var methods:Array = def.methods;
- Assert.assertEquals("unexpected methods length",2,methods.length);
-
+ Assert.assertEquals("unexpected methods length", 2, methods.length);
+
var accessors:Array = def.accessors;
- Assert.assertEquals("unexpected accessors length",3,accessors.length);
-
+ Assert.assertEquals("unexpected accessors length", 3, accessors.length);
+
var constructor:MethodDefinition = def.constructorMethod;
Assert.assertEquals("unexpected constructor declaredBy",
"flexUnitTests.reflection.support.TestClass2",
constructor.declaredBy.qualifiedName);
-
+
Assert.assertEquals("unexpected constructor params",
1,
constructor.parameters.length);
-
+
var meta:Array = def.retrieveMetaDataByName("TestMeta");
Assert.assertEquals("unexpected class specific meta length",
1,
meta.length);
-
-
+
+
def = describeType(TestClass4);
- Assert.assertEquals("Unexpected package name",def.packageName,"flexUnitTests.reflection.support");
- Assert.assertEquals("Unexpected type name",def.name,"TestClass4");
-
+ Assert.assertEquals("Unexpected package name", def.packageName, "flexUnitTests.reflection.support");
+ Assert.assertEquals("Unexpected type name", def.name, "TestClass4");
+
variables = def.variables;
- Assert.assertEquals("unexpected variables length",2,variables.length);
-
-
+ Assert.assertEquals("unexpected variables length", 2, variables.length);
+
+
methods = def.methods;
- Assert.assertEquals("unexpected methods length",4,methods.length);
-
+ Assert.assertEquals("unexpected methods length", 4, methods.length);
+
accessors = def.accessors;
- Assert.assertEquals("unexpected accessors length",6,accessors.length);
-
+ Assert.assertEquals("unexpected accessors length", 6, accessors.length);
+
constructor = def.constructorMethod;
Assert.assertEquals("unexpected constructor declaredBy",
"flexUnitTests.reflection.support.TestClass4",
constructor.declaredBy.qualifiedName);
-
+
Assert.assertEquals("unexpected constructor params",
0,
constructor.parameters.length);
-
-
-
+
+
}
-
-
-
-
- [TestVariance(variance="JS",description="Variance in test due to current inability for js target to reflect into non-Royale base classes or typedefs")]
- [Test]
+
+
+ [TestVariance(variance="JS", description="Variance in test due to current inability for js target to reflect into non-Royale base classes or typedefs")]
+ [Test]
public function testDescribeTypeClass():void
{
var def:TypeDefinition = describeType(TestClass1);
var expected:*;
- Assert.assertEquals("Unexpected package name","flexUnitTests.reflection.support",def.packageName);
- Assert.assertEquals("Unexpected type name",def.name,"TestClass1");
-
+ Assert.assertEquals("Unexpected package name", "flexUnitTests.reflection.support", def.packageName);
+ Assert.assertEquals("Unexpected type name", def.name, "TestClass1");
+
var variables:Array = def.variables;
- Assert.assertEquals("unexpected instance variables length",3,variables.length);
-
+ Assert.assertEquals("unexpected instance variables length", 3, variables.length);
+
//there is a difference based on the EventDispatcher inheritance chain differences between js and swf:
expected = isJS ? 4 : 7;
var methods:Array = def.methods;
- Assert.assertEquals("unexpected instance methods length",expected,methods.length);
-
+ Assert.assertEquals("unexpected instance methods length", expected, methods.length);
+
var accessors:Array = def.accessors;
- Assert.assertEquals("unexpected instance accessors length",4,accessors.length);
-
- var staticVariables:Array =def.staticVariables;
- Assert.assertEquals("unexpected static variables length",2,staticVariables.length);
-
+ Assert.assertEquals("unexpected instance accessors length", 4, accessors.length);
+
+ var staticVariables:Array = def.staticVariables;
+ Assert.assertEquals("unexpected static variables length", 2, staticVariables.length);
+
var staticMethods:Array = def.staticMethods;
- Assert.assertEquals("unexpected static methods length",1,staticMethods.length);
+ Assert.assertEquals("unexpected static methods length", 1, staticMethods.length);
//there is a difference based on the native inheritance of readonly 'prototype' not collected from 'Class' (or Object for js):
expected = isJS ? 3 : 4;
var staticAccessors:Array = def.staticAccessors;
- Assert.assertEquals("unexpected static accessors length",expected,staticAccessors.length);
-
-
+ Assert.assertEquals("unexpected static accessors length", expected, staticAccessors.length);
+
+
}
-
- [TestVariance(variance="JS",description="Variance in test due to current inability for js target to reflect into non-Royale base classes or typedefs")]
+
+ [TestVariance(variance="JS", description="Variance in test due to current inability for js target to reflect into non-Royale base classes or typedefs")]
[Test]
public function testDescribeTypeInstance():void
{
var def:TypeDefinition = describeType(new TestClass1());
var expected:*;
- Assert.assertEquals("Unexpected package name","flexUnitTests.reflection.support",def.packageName);
- Assert.assertEquals("Unexpected type name",def.name,"TestClass1");
-
+ Assert.assertEquals("Unexpected package name", "flexUnitTests.reflection.support", def.packageName);
+ Assert.assertEquals("Unexpected type name", def.name, "TestClass1");
+
var variables:Array = def.variables;
- Assert.assertEquals("unexpected instance variables length",3,variables.length);
-
+ Assert.assertEquals("unexpected instance variables length", 3, variables.length);
+
//there is a difference based on the EventDispatcher inheritance chain differences between js and swf:
expected = isJS ? 4 : 7;
var methods:Array = def.methods;
- Assert.assertEquals("unexpected instance methods length",expected,methods.length);
-
+ Assert.assertEquals("unexpected instance methods length", expected, methods.length);
+
var accessors:Array = def.accessors;
- Assert.assertEquals("unexpected instance accessors length",4,accessors.length);
-
- var staticVariables:Array =def.staticVariables;
- Assert.assertEquals("unexpected static variables length",2,staticVariables.length);
-
+ Assert.assertEquals("unexpected instance accessors length", 4, accessors.length);
+
+ var staticVariables:Array = def.staticVariables;
+ Assert.assertEquals("unexpected static variables length", 2, staticVariables.length);
+
var staticMethods:Array = def.staticMethods;
- Assert.assertEquals("unexpected static methods length",1,staticMethods.length);
+ Assert.assertEquals("unexpected static methods length", 1, staticMethods.length);
//there is a difference based on the native inheritance of readonly 'prototype' not collected from 'Class' (or Object for js):
expected = isJS ? 3 : 4;
var staticAccessors:Array = def.staticAccessors;
- Assert.assertEquals("unexpected static accessors length",expected,staticAccessors.length);
-
-
+ Assert.assertEquals("unexpected static accessors length", expected, staticAccessors.length);
+
+
}
-
- [TestVariance(variance="JS",description="Variance in baseClasses due to current inability for js target to reflect into non-Royale base classes or typedefs")]
+
+ [TestVariance(variance="JS", description="Variance in baseClasses due to current inability for js target to reflect into non-Royale base classes or typedefs")]
[Test]
- public function testBaseClasses():void{
+ public function testBaseClasses():void
+ {
var def:TypeDefinition = describeType(TestClass1);
-
+
var baseClasses:Array = def.baseClasses;
var expected:uint = isJS ? 1 : 3;
- Assert.assertEquals("unexpected baseclasses length",expected,baseClasses.length);
+ Assert.assertEquals("unexpected baseclasses length", expected, baseClasses.length);
}
-
-
+
+
[Test]
- public function testMemberAccess():void{
+ public function testMemberAccess():void
+ {
//all of these should succeed without error
var inst:TestClass2 = new TestClass2("");
var def:TypeDefinition = describeType(inst);
-
+
/** instance variables **/
-
+
var variables:Array = def.variables;
var variable:VariableDefinition = variables[0];
- Assert.assertEquals("unexpected variable name","testVar",variable.name);
+ Assert.assertEquals("unexpected variable name", "testVar", variable.name);
var meta:MetaDataDefinition = variable.retrieveMetaDataByName("TestMeta")[0];
- Assert.assertEquals("unexpected meta name","TestMeta",meta.name);
-
+ Assert.assertEquals("unexpected meta name", "TestMeta", meta.name);
+
var metaArg:MetaDataArgDefinition = meta.getArgsByKey("foo")[0];
- Assert.assertEquals("unexpected meta arg name","foo",metaArg.name);
- Assert.assertEquals("unexpected meta arg value","instanceVariable",metaArg.value);
-
- // Assert.assertEquals("unexpected reflection initial variable value","testVar_val",inst[variable.name]);
- Assert.assertEquals("unexpected reflection initial variable value","testVar_val",variable.getValue(inst));
+ Assert.assertEquals("unexpected meta arg name", "foo", metaArg.name);
+ Assert.assertEquals("unexpected meta arg value", "instanceVariable", metaArg.value);
+
+ // Assert.assertEquals("unexpected reflection initial variable value","testVar_val",inst[variable.name]);
+ Assert.assertEquals("unexpected reflection initial variable value", "testVar_val", variable.getValue(inst));
variable.setValue(inst, "testVar_val_reflection_set");
- Assert.assertEquals("unexpected reflection initial variable value","testVar_val_reflection_set",variable.getValue(inst));
- inst.testVar = "testVar_val";
+ Assert.assertEquals("unexpected reflection initial variable value", "testVar_val_reflection_set", variable.getValue(inst));
+ inst.testVar = "testVar_val";
var accessors:Array = def.accessors;
- var testReadOnly:AccessorDefinition = retrieveItemWithName(accessors,"testReadOnly") as AccessorDefinition;
+ var testReadOnly:AccessorDefinition = retrieveItemWithName(accessors, "testReadOnly") as AccessorDefinition;
meta = testReadOnly.retrieveMetaDataByName("TestMeta")[0];
- Assert.assertEquals("unexpected meta name","TestMeta",meta.name);
-
+ Assert.assertEquals("unexpected meta name", "TestMeta", meta.name);
+
metaArg = meta.getArgsByKey("foo")[0];
- Assert.assertEquals("unexpected meta arg name","foo",metaArg.name);
- Assert.assertEquals("unexpected meta arg value","instanceAccessor",metaArg.value);
-
+ Assert.assertEquals("unexpected meta arg name", "foo", metaArg.name);
+ Assert.assertEquals("unexpected meta arg value", "instanceAccessor", metaArg.value);
+
/** instance accessors **/
- var testWriteOnly:AccessorDefinition = retrieveItemWithName(accessors,"testWriteOnly") as AccessorDefinition;
- var testReadWrite:AccessorDefinition = retrieveItemWithName(accessors,"testReadWrite") as AccessorDefinition;
+ var testWriteOnly:AccessorDefinition = retrieveItemWithName(accessors, "testWriteOnly") as AccessorDefinition;
+ var testReadWrite:AccessorDefinition = retrieveItemWithName(accessors, "testReadWrite") as AccessorDefinition;
Assert.assertNotNull(testReadOnly);
Assert.assertNotNull(testWriteOnly);
Assert.assertNotNull(testReadWrite);
-
- Assert.assertEquals("unexpected accessor initial value","instanceAccessor_initial_value",inst[testReadOnly.name]);
- Assert.assertEquals("unexpected accessor initial value","instanceAccessor_initial_value",inst[testReadWrite.name]);
-
+
+ Assert.assertEquals("unexpected accessor initial value", "instanceAccessor_initial_value", inst[testReadOnly.name]);
+ Assert.assertEquals("unexpected accessor initial value", "instanceAccessor_initial_value", inst[testReadWrite.name]);
+
inst[testWriteOnly.name] = "test";
- Assert.assertEquals("unexpected accessor initial value","test",inst[testReadOnly.name]);
- Assert.assertEquals("unexpected accessor initial value","test",inst[testReadWrite.name]);
-
+ Assert.assertEquals("unexpected accessor initial value", "test", inst[testReadOnly.name]);
+ Assert.assertEquals("unexpected accessor initial value", "test", inst[testReadWrite.name]);
+
inst[testReadWrite.name] = "test2";
- Assert.assertEquals("unexpected accessor initial value","test2",inst[testReadOnly.name]);
- Assert.assertEquals("unexpected accessor initial value","test2",inst[testReadWrite.name]);
-
+ Assert.assertEquals("unexpected accessor initial value", "test2", inst[testReadOnly.name]);
+ Assert.assertEquals("unexpected accessor initial value", "test2", inst[testReadWrite.name]);
+
/** instance methods **/
var methods:Array = def.methods;
- var testMethod:MethodDefinition = retrieveItemWithName(methods,"testMethod") as MethodDefinition;
+ var testMethod:MethodDefinition = retrieveItemWithName(methods, "testMethod") as MethodDefinition;
meta = testMethod.retrieveMetaDataByName("TestMeta")[0];
- Assert.assertEquals("unexpected meta name","TestMeta",meta.name);
-
+ Assert.assertEquals("unexpected meta name", "TestMeta", meta.name);
+
metaArg = meta.getArgsByKey("foo")[0];
- Assert.assertEquals("unexpected meta arg name","foo",metaArg.name);
- Assert.assertEquals("unexpected meta arg value","instanceMethod",metaArg.value);
- Assert.assertEquals("unexpected parameter count",0,testMethod.parameters.length);
+ Assert.assertEquals("unexpected meta arg name", "foo", metaArg.name);
+ Assert.assertEquals("unexpected meta arg value", "instanceMethod", metaArg.value);
+ Assert.assertEquals("unexpected parameter count", 0, testMethod.parameters.length);
inst[testMethod.name]();
- Assert.assertEquals("unexpected method invocation result","testMethod was called",inst[testReadWrite.name]);
-
- var testMethodWithArgs:MethodDefinition = retrieveItemWithName(methods,"testMethodWithArgs") as MethodDefinition;
- Assert.assertEquals("unexpected parameter count",2,testMethodWithArgs.parameters.length);
- Assert.assertTrue("unexpected method invocation result",inst[testMethodWithArgs.name]("test"));
- Assert.assertFalse("unexpected method invocation result",inst[testMethodWithArgs.name]("test", false));
- Assert.assertEquals("unexpected method invocation result","testMethodWithArgs was called",inst[testReadWrite.name]);
-
-
-
+ Assert.assertEquals("unexpected method invocation result", "testMethod was called", inst[testReadWrite.name]);
+
+ var testMethodWithArgs:MethodDefinition = retrieveItemWithName(methods, "testMethodWithArgs") as MethodDefinition;
+ Assert.assertEquals("unexpected parameter count", 2, testMethodWithArgs.parameters.length);
+ Assert.assertTrue("unexpected method invocation result", inst[testMethodWithArgs.name]("test"));
+ Assert.assertFalse("unexpected method invocation result", inst[testMethodWithArgs.name]("test", false));
+ Assert.assertEquals("unexpected method invocation result", "testMethodWithArgs was called", inst[testReadWrite.name]);
+
+
/** static vars **/
variables = def.staticVariables;
-
+
variable = variables[0];
- Assert.assertEquals("unexpected variable name","testStaticVar",variable.name);
+ Assert.assertEquals("unexpected variable name", "testStaticVar", variable.name);
meta = variable.retrieveMetaDataByName("TestMeta")[0];
- Assert.assertEquals("unexpected meta name","TestMeta",meta.name);
-
+ Assert.assertEquals("unexpected meta name", "TestMeta", meta.name);
+
metaArg = meta.getArgsByKey("foo")[0];
- Assert.assertEquals("unexpected meta arg name","foo",metaArg.name);
- Assert.assertEquals("unexpected meta arg value","staticVariable",metaArg.value);
-
- // Assert.assertEquals("unexpected reflection initial variable value","testStaticVar_val",TestClass2[variable.name]);
- Assert.assertEquals("unexpected reflection initial variable value","testStaticVar_val",variable.getValue());
- variable.setValue("testStaticVar_val_reflection_set");
- Assert.assertEquals("unexpected reflection initial variable value","testStaticVar_val_reflection_set",variable.getValue());
- TestClass2.testStaticVar = "testStaticVar_val";
+ Assert.assertEquals("unexpected meta arg name", "foo", metaArg.name);
+ Assert.assertEquals("unexpected meta arg value", "staticVariable", metaArg.value);
+ // Assert.assertEquals("unexpected reflection initial variable value","testStaticVar_val",TestClass2[variable.name]);
+ Assert.assertEquals("unexpected reflection initial variable value", "testStaticVar_val", variable.getValue());
+ variable.setValue("testStaticVar_val_reflection_set");
+ Assert.assertEquals("unexpected reflection initial variable value", "testStaticVar_val_reflection_set", variable.getValue());
+ TestClass2.testStaticVar = "testStaticVar_val";
/** static accessors **/
-
+
accessors = def.staticAccessors;
-
- testReadOnly = retrieveItemWithName(accessors,"testStaticReadOnly") as AccessorDefinition;
+
+ testReadOnly = retrieveItemWithName(accessors, "testStaticReadOnly") as AccessorDefinition;
meta = testReadOnly.retrieveMetaDataByName("TestMeta")[0];
- Assert.assertEquals("unexpected meta name","TestMeta",meta.name);
-
+ Assert.assertEquals("unexpected meta name", "TestMeta", meta.name);
+
metaArg = meta.getArgsByKey("foo")[0];
- Assert.assertEquals("unexpected meta arg name","foo",metaArg.name);
- Assert.assertEquals("unexpected meta arg value","staticAccessor",metaArg.value);
-
-
- testWriteOnly = retrieveItemWithName(accessors,"testStaticWriteOnly") as AccessorDefinition;
- testReadWrite = retrieveItemWithName(accessors,"testStaticReadWrite") as AccessorDefinition;
+ Assert.assertEquals("unexpected meta arg name", "foo", metaArg.name);
+ Assert.assertEquals("unexpected meta arg value", "staticAccessor", metaArg.value);
+
+
+ testWriteOnly = retrieveItemWithName(accessors, "testStaticWriteOnly") as AccessorDefinition;
+ testReadWrite = retrieveItemWithName(accessors, "testStaticReadWrite") as AccessorDefinition;
Assert.assertNotNull(testReadOnly);
Assert.assertNotNull(testWriteOnly);
Assert.assertNotNull(testReadWrite);
-
- Assert.assertEquals("unexpected accessor initial value","staticAccessor_initial_value",TestClass2[testReadOnly.name]);
- Assert.assertEquals("unexpected accessor initial value","staticAccessor_initial_value",TestClass2[testReadWrite.name]);
-
+
+ Assert.assertEquals("unexpected accessor initial value", "staticAccessor_initial_value", TestClass2[testReadOnly.name]);
+ Assert.assertEquals("unexpected accessor initial value", "staticAccessor_initial_value", TestClass2[testReadWrite.name]);
+
TestClass2[testWriteOnly.name] = "test";
- Assert.assertEquals("unexpected accessor initial value","test",TestClass2[testReadOnly.name]);
- Assert.assertEquals("unexpected accessor initial value","test",TestClass2[testReadWrite.name]);
-
+ Assert.assertEquals("unexpected accessor initial value", "test", TestClass2[testReadOnly.name]);
+ Assert.assertEquals("unexpected accessor initial value", "test", TestClass2[testReadWrite.name]);
+
TestClass2[testReadWrite.name] = "test2";
- Assert.assertEquals("unexpected accessor initial value","test2",TestClass2[testReadOnly.name]);
- Assert.assertEquals("unexpected accessor initial value","test2",TestClass2[testReadWrite.name]);
-
-
+ Assert.assertEquals("unexpected accessor initial value", "test2", TestClass2[testReadOnly.name]);
+ Assert.assertEquals("unexpected accessor initial value", "test2", TestClass2[testReadWrite.name]);
+
+
/** static methods **/
methods = def.staticMethods;
- testMethod = retrieveItemWithName(methods,"testStaticMethod") as MethodDefinition;
+ testMethod = retrieveItemWithName(methods, "testStaticMethod") as MethodDefinition;
meta = testMethod.retrieveMetaDataByName("TestMeta")[0];
- Assert.assertEquals("unexpected meta name","TestMeta",meta.name);
-
+ Assert.assertEquals("unexpected meta name", "TestMeta", meta.name);
+
metaArg = meta.getArgsByKey("foo")[0];
- Assert.assertEquals("unexpected meta arg name","foo",metaArg.name);
- Assert.assertEquals("unexpected meta arg value","staticMethod",metaArg.value);
- Assert.assertEquals("unexpected parameter count",0,testMethod.parameters.length);
+ Assert.assertEquals("unexpected meta arg name", "foo", metaArg.name);
+ Assert.assertEquals("unexpected meta arg value", "staticMethod", metaArg.value);
+ Assert.assertEquals("unexpected parameter count", 0, testMethod.parameters.length);
TestClass2[testMethod.name]();
- Assert.assertEquals("unexpected method invocation result","testStaticMethod was called",TestClass2[testReadWrite.name]);
-
- testMethodWithArgs = retrieveItemWithName(methods,"testStaticMethodWithArgs") as MethodDefinition;
- Assert.assertEquals("unexpected parameter count",2,testMethodWithArgs.parameters.length);
- Assert.assertTrue("unexpected method invocation result",TestClass2[testMethodWithArgs.name]("test"));
- Assert.assertFalse("unexpected method invocation result",TestClass2[testMethodWithArgs.name]("test", false));
- Assert.assertEquals("unexpected method invocation result","testStaticMethodWithArgs was called",TestClass2[testReadWrite.name]);
-
+ Assert.assertEquals("unexpected method invocation result", "testStaticMethod was called", TestClass2[testReadWrite.name]);
+
+ testMethodWithArgs = retrieveItemWithName(methods, "testStaticMethodWithArgs") as MethodDefinition;
+ Assert.assertEquals("unexpected parameter count", 2, testMethodWithArgs.parameters.length);
+ Assert.assertTrue("unexpected method invocation result", TestClass2[testMethodWithArgs.name]("test"));
+ Assert.assertFalse("unexpected method invocation result", TestClass2[testMethodWithArgs.name]("test", false));
+ Assert.assertEquals("unexpected method invocation result", "testStaticMethodWithArgs was called", TestClass2[testReadWrite.name]);
+
}
-
-
- [Test]
- public function testInterfaceReflection():void{
+
+
+ [Test]
+ public function testInterfaceReflection():void
+ {
var def:TypeDefinition = describeType(ITestInterface4);
- Assert.assertEquals("unexpected kind value","interface",def.kind);
- Assert.assertEquals("unexpected interfaces length",3,def.interfaces.length);
- Assert.assertEquals("unexpected accessors length",1,def.accessors.length);
- Assert.assertEquals("unexpected methods length",1,def.methods.length);
-
- Assert.assertEquals("unexpected variables length",0,def.variables.length);
- Assert.assertEquals("unexpected staticVariables length",0,def.staticVariables.length);
- Assert.assertEquals("unexpected variables length",0,def.staticMethods.length);
- Assert.assertEquals("unexpected staticVariables length",0,def.staticAccessors.length);
- Assert.assertNull("unexpected constructor Method definition",def.constructorMethod);
+ Assert.assertEquals("unexpected kind value", "interface", def.kind);
+ Assert.assertEquals("unexpected interfaces length", 3, def.interfaces.length);
+ Assert.assertEquals("unexpected accessors length", 1, def.accessors.length);
+ Assert.assertEquals("unexpected methods length", 1, def.methods.length);
+
+ Assert.assertEquals("unexpected variables length", 0, def.variables.length);
+ Assert.assertEquals("unexpected staticVariables length", 0, def.staticVariables.length);
+ Assert.assertEquals("unexpected variables length", 0, def.staticMethods.length);
+ Assert.assertEquals("unexpected staticVariables length", 0, def.staticAccessors.length);
+ Assert.assertNull("unexpected constructor Method definition", def.constructorMethod);
}
-
-
-
+
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestAlias.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestAlias.as
index 3d96b56..65a3942 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestAlias.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestAlias.as
@@ -19,26 +19,35 @@
package flexUnitTests.reflection
{
import flexunit.framework.Assert;
- import flexUnitTests.reflection.support.*;
+
+ import flexUnitTests.reflection.support.*;
+
import org.apache.royale.reflection.*;
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class ReflectionTesterTestAlias
- {
-
+ {
+
public static var isJS:Boolean;
+
[BeforeClass]
public static function setUpBeforeClass():void
{
var js:Boolean = false;
- try {
+ try
+ {
var check:* = getDefinitionByName("flash.system.Capabilities");
- } catch (e:Error) {
+ } catch (e:Error)
+ {
js = true;
}
//if this next reference to 'check' is not included, then the above try/catch code
//appears to be optimized away in js-release mode
//a separate test has been created for this
- if (check == null) {
+ if (check == null)
+ {
js = true;
}
isJS = js;
@@ -48,43 +57,41 @@ package flexUnitTests.reflection
public static function tearDownAfterClass():void
{
}
-
- [Before]
+
+ [Before]
public function setUp():void
{
-
+
}
[After]
public function tearDown():void
{
-
+
}
-
-
-
-
+
+
[Test]
- public function testBasicAlias():void {
+ public function testBasicAlias():void
+ {
//no initial alias
Assert.assertNull(getAliasByClass(TestClass2));
registerClassAlias("fjsTest", TestClass2);
//alias is registered
- Assert.assertEquals("unexpected Alias value","fjsTest",getAliasByClass(TestClass2));
+ Assert.assertEquals("unexpected Alias value", "fjsTest", getAliasByClass(TestClass2));
//register same alias for another class
registerClassAlias("fjsTest", TestClass3);
//original alias mapping is deregistered
Assert.assertNull(getAliasByClass(TestClass2));
//alias is registered for new class
- Assert.assertEquals("unexpected Alias value","fjsTest",getAliasByClass(TestClass3));
-
+ Assert.assertEquals("unexpected Alias value", "fjsTest", getAliasByClass(TestClass3));
+
//class is retrievable by alias
- Assert.assertEquals("unexpected Class value",TestClass3,getClassByAlias("fjsTest"));
-
-
+ Assert.assertEquals("unexpected Class value", TestClass3, getClassByAlias("fjsTest"));
+
+
}
-
-
-
+
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestDynamic.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestDynamic.as
index 4aa2155..9d51353 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestDynamic.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestDynamic.as
@@ -19,20 +19,26 @@
package flexUnitTests.reflection
{
import flexunit.framework.Assert;
- import flexUnitTests.reflection.support.*;
+
+ import flexUnitTests.reflection.support.*;
+
import org.apache.royale.reflection.*;
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class ReflectionTesterTestDynamic
{
-
+
public static var isJS:Boolean;
+
[BeforeClass]
public static function setUpBeforeClass():void
{
- var js:Boolean;
- COMPILE::JS{
- js = true;
- }
+ var js:Boolean;
+ COMPILE::JS{
+ js = true;
+ }
isJS = js;
}
@@ -40,8 +46,8 @@ package flexUnitTests.reflection
public static function tearDownAfterClass():void
{
}
-
- [Before]
+
+ [Before]
public function setUp():void
{
@@ -53,151 +59,165 @@ package flexUnitTests.reflection
}
- private static function contentStringsMatch(arr1:Array, arr2:Array):Boolean{
- if (arr1 == arr2) return true;
- if (!arr1 || !arr2) return false;
- if (arr1.length != arr2.length) return false;
- const arr1Copy:Array = arr1.concat();
- var l:uint = arr1Copy.length;
- while (l--) {
- var s:String = arr1Copy.shift();
- if (arr2.indexOf(s) == -1) return false
- }
- return true;
- }
-
-
+ private static function contentStringsMatch(arr1:Array, arr2:Array):Boolean
+ {
+ if (arr1 == arr2) return true;
+ if (!arr1 || !arr2) return false;
+ if (arr1.length != arr2.length) return false;
+ const arr1Copy:Array = arr1.concat();
+ var l:uint = arr1Copy.length;
+ while (l--)
+ {
+ var s:String = arr1Copy.shift();
+ if (arr2.indexOf(s) == -1) return false
+ }
+ return true;
+ }
+
+
[Test]
- public function testisDynamic():void {
+ public function testisDynamic():void
+ {
//class
-
- Assert.assertTrue("class should be dynamic",isDynamicObject(Object));
-
- Assert.assertTrue("class should be dynamic",isDynamicObject(TestClass1));
- //interface is dynamic (even if it doesn't make much sense)
- Assert.assertTrue("interface should be dynamic",true,isDynamicObject(ITestInterface));
+
+ Assert.assertTrue("class should be dynamic", isDynamicObject(Object));
+
+ Assert.assertTrue("class should be dynamic", isDynamicObject(TestClass1));
+ //interface is dynamic (even if it doesn't make much sense)
+ Assert.assertTrue("interface should be dynamic", true, isDynamicObject(ITestInterface));
//instance
- Assert.assertTrue("generic object should be dynamic",isDynamicObject({}));
-
- Assert.assertFalse("sealed class instance should not be dynamic",isDynamicObject(new TestClass1()));
-
- Assert.assertTrue("dynamic class instance should be dynamic",isDynamicObject(new DynamicTestClass()));
-
-
- Assert.assertFalse("String instance should not be dynamic",isDynamicObject("String"));
- Assert.assertFalse("int instance should not be dynamic",isDynamicObject(99));
- Assert.assertFalse("Number instance should not be dynamic",isDynamicObject(99.99));
- Assert.assertFalse("Boolean instance should not be dynamic",isDynamicObject(true));
-
-
- Assert.assertTrue("function instance should be dynamic",isDynamicObject(function():void{}));
- Assert.assertTrue("Array instance should be dynamic",isDynamicObject([]));
+ Assert.assertTrue("generic object should be dynamic", isDynamicObject({}));
+
+ Assert.assertFalse("sealed class instance should not be dynamic", isDynamicObject(new TestClass1()));
+
+ Assert.assertTrue("dynamic class instance should be dynamic", isDynamicObject(new DynamicTestClass()));
+
+
+ Assert.assertFalse("String instance should not be dynamic", isDynamicObject("String"));
+ Assert.assertFalse("int instance should not be dynamic", isDynamicObject(99));
+ Assert.assertFalse("Number instance should not be dynamic", isDynamicObject(99.99));
+ Assert.assertFalse("Boolean instance should not be dynamic", isDynamicObject(true));
+
+
+ Assert.assertTrue("function instance should be dynamic", isDynamicObject(function ():void
+ {
+ }));
+ Assert.assertTrue("Array instance should be dynamic", isDynamicObject([]));
}
-
-
-
- [TestVariance(variance="JS",description="Variance in test due to reliance on 'js-default-initializers=true' throughout entire inheritance chain for 'getDynamicFields' function")]
- [Test]
- public function testGetDynamicFields():void {
-
- const emptyArray:Array = [];
- const singleDynField:Array = ['test'];
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(Object),emptyArray));
- Object['test'] = true;
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(Object),singleDynField));
- delete Object['test'];
-
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(TestClass1),emptyArray));
- TestClass1['test'] = true;
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(TestClass1),singleDynField));
- delete TestClass1['test'];
-
- //interface is dynamic (even if it doesn't make much sense)
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(ITestInterface),emptyArray));
- ITestInterface['test'] = true;
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(ITestInterface),singleDynField));
- delete ITestInterface['test'];
-
- //instance
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields({}),emptyArray));
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields({test:true}),singleDynField));
-
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(new TestClass1()),emptyArray));
-
- const dynInstance:DynamicTestClass = new DynamicTestClass();
- dynInstance.test = true;
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(dynInstance),singleDynField));
-
-
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields("String"),emptyArray));
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(99),emptyArray));
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(99.99),emptyArray));
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(true),emptyArray));
-
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(function():void{}),emptyArray));
-
- const numericFields:Array=["0","1","2","3"];
- var arr:Array = [1,2,3,4];
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(arr),numericFields));
- numericFields.push('test');
- arr['test'] = true;
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(arr),numericFields));
-
-
- var testclass2:DynamicTestClass2 = new DynamicTestClass2();
- testclass2.test = true;
- testclass2.something = '*something*';
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(testclass2),singleDynField));
-
-
- testclass2.test = 'test';
- testclass2.something = '*something else*';
-
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(testclass2),singleDynField));
- var testClass3:DynamicTestClass3 = new DynamicTestClass3();
- var swapAssertion:Boolean;
- COMPILE::JS{
- var check:Boolean = new CompilationData(testClass3).hasSameAncestry(CompilationData.WITH_DEFAULT_INITIALIZERS);
- if (!check) {
- //variance... due framework ancestry having different compilation settings
- swapAssertion = true;
- }
- }
-
- if (!swapAssertion) {
- Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(testClass3), emptyArray));
- } else {
- Assert.assertFalse("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(testClass3), emptyArray));
- trace('[WARN] Variance: a test is technically wrong in javascript, but is expected to be wrong, because the compilation settings do not support it throughout the inheritance chain');
- }
- testClass3.test='true';
- testClass3.x = 10;
- testClass3.className = 'hello';
-
-
- if (!swapAssertion) {
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(testClass3),singleDynField));
- } else {
- Assert.assertFalse("dynamic fields should not match reference list",contentStringsMatch(getDynamicFields(testClass3),singleDynField));
- trace('[WARN] Variance: a test is technically wrong in javascript, but is expected to be wrong, because the compilation settings do not support it throughout the inheritance chain');
- }
-
- }
-
- [Test]
- public function testGetDynamicFieldsWithPredicate():void {
- const test:Object = {
- 'test1':true,
- 'test2':true,
- '_underscore':true
- };
- const withoutUnderscores:Array = ['test1', 'test2'];
- var excludeUnderscores:Function = function(prop:String):Boolean {
- return prop && prop.charAt(0) != '_';
- };
- Assert.assertTrue("dynamic fields should match reference list",contentStringsMatch(getDynamicFields(test, excludeUnderscores), withoutUnderscores));
-
- }
-
+
+
+ [TestVariance(variance="JS", description="Variance in test due to reliance on 'js-default-initializers=true' throughout entire inheritance chain for 'getDynamicFields' function")]
+ [Test]
+ public function testGetDynamicFields():void
+ {
+
+ const emptyArray:Array = [];
+ const singleDynField:Array = ['test'];
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(Object), emptyArray));
+ Object['test'] = true;
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(Object), singleDynField));
+ delete Object['test'];
+
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(TestClass1), emptyArray));
+ TestClass1['test'] = true;
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(TestClass1), singleDynField));
+ delete TestClass1['test'];
+
+ //interface is dynamic (even if it doesn't make much sense)
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(ITestInterface), emptyArray));
+ ITestInterface['test'] = true;
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(ITestInterface), singleDynField));
+ delete ITestInterface['test'];
+
+ //instance
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields({}), emptyArray));
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields({test: true}), singleDynField));
+
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(new TestClass1()), emptyArray));
+
+ const dynInstance:DynamicTestClass = new DynamicTestClass();
+ dynInstance.test = true;
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(dynInstance), singleDynField));
+
+
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields("String"), emptyArray));
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(99), emptyArray));
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(99.99), emptyArray));
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(true), emptyArray));
+
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(function ():void
+ {
+ }), emptyArray));
+
+ const numericFields:Array = ["0", "1", "2", "3"];
+ var arr:Array = [1, 2, 3, 4];
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(arr), numericFields));
+ numericFields.push('test');
+ arr['test'] = true;
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(arr), numericFields));
+
+
+ var testclass2:DynamicTestClass2 = new DynamicTestClass2();
+ testclass2.test = true;
+ testclass2.something = '*something*';
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(testclass2), singleDynField));
+
+
+ testclass2.test = 'test';
+ testclass2.something = '*something else*';
+
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(testclass2), singleDynField));
+ var testClass3:DynamicTestClass3 = new DynamicTestClass3();
+ var swapAssertion:Boolean;
+ COMPILE::JS{
+ var check:Boolean = new CompilationData(testClass3).hasSameAncestry(CompilationData.WITH_DEFAULT_INITIALIZERS);
+ if (!check)
+ {
+ //variance... due framework ancestry having different compilation settings
+ swapAssertion = true;
+ }
+ }
+
+ if (!swapAssertion)
+ {
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(testClass3), emptyArray));
+ } else
+ {
+ Assert.assertFalse("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(testClass3), emptyArray));
+ trace('[WARN] Variance: a test is technically wrong in javascript, but is expected to be wrong, because the compilation settings do not support it throughout the inheritance chain');
+ }
+ testClass3.test = 'true';
+ testClass3.x = 10;
+ testClass3.className = 'hello';
+
+
+ if (!swapAssertion)
+ {
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(testClass3), singleDynField));
+ } else
+ {
+ Assert.assertFalse("dynamic fields should not match reference list", contentStringsMatch(getDynamicFields(testClass3), singleDynField));
+ trace('[WARN] Variance: a test is technically wrong in javascript, but is expected to be wrong, because the compilation settings do not support it throughout the inheritance chain');
+ }
+
+ }
+
+ [Test]
+ public function testGetDynamicFieldsWithPredicate():void
+ {
+ const test:Object = {
+ 'test1': true,
+ 'test2': true,
+ '_underscore': true
+ };
+ const withoutUnderscores:Array = ['test1', 'test2'];
+ var excludeUnderscores:Function = function (prop:String):Boolean
+ {
+ return prop && prop.charAt(0) != '_';
+ };
+ Assert.assertTrue("dynamic fields should match reference list", contentStringsMatch(getDynamicFields(test, excludeUnderscores), withoutUnderscores));
+
+ }
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestUseCache.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestUseCache.as
index 6f4e5e0..096612e 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestUseCache.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/ReflectionTesterTestUseCache.as
@@ -19,26 +19,35 @@
package flexUnitTests.reflection
{
import flexunit.framework.Assert;
- import flexUnitTests.reflection.support.*;
+
+ import flexUnitTests.reflection.support.*;
+
import org.apache.royale.reflection.*;
+ /**
+ * @royalesuppresspublicvarwarning
+ */
public class ReflectionTesterTestUseCache
- {
-
+ {
+
public static var isJS:Boolean;
+
[BeforeClass]
public static function setUpBeforeClass():void
{
var js:Boolean = false;
- try {
+ try
+ {
var check:* = getDefinitionByName("flash.system.Capabilities");
- } catch (e:Error) {
+ } catch (e:Error)
+ {
js = true;
}
//if this next reference to 'check' is not included, then the above try/catch code
//appears to be optimized away in js-release mode
//a separate test has been created for this
- if (check == null) {
+ if (check == null)
+ {
js = true;
}
isJS = js;
@@ -48,8 +57,8 @@ package flexUnitTests.reflection
public static function tearDownAfterClass():void
{
}
-
- [Before]
+
+ [Before]
public function setUp():void
{
TypeDefinition.useCache = true;
@@ -62,32 +71,35 @@ package flexUnitTests.reflection
{
TypeDefinition.useCache = false;
}
-
- private static function retrieveItemWithName(collection:Array, name:String):DefinitionBase {
+
+ private static function retrieveItemWithName(collection:Array, name:String):DefinitionBase
+ {
var ret:DefinitionBase;
- var i:uint=0,l:uint=collection.length;
- for (;i<l;i++) {
- if (collection[i].name==name) {
+ var i:uint = 0, l:uint = collection.length;
+ for (; i < l; i++)
+ {
+ if (collection[i].name == name)
+ {
ret = collection[i];
break;
}
}
-
+
return ret;
}
-
-
+
+
[Test]
- public function testBasicCache():void {
+ public function testBasicCache():void
+ {
var def:TypeDefinition = describeType(TestClass2);
-
+
var def2:TypeDefinition = describeType(TestClass2);
-
- Assert.assertEquals("cache not working",def,def2);
-
+
+ Assert.assertEquals("cache not working", def, def2);
+
}
-
-
-
+
+
}
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass.as
index c1062a5..92b5c34 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass.as
@@ -18,72 +18,82 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
-
-
- dynamic public class DynamicTestClass
- {
- //Note: do not change this test class unless you change the related tests to
- //support any changes that might appear when testing reflection into it
-
- /*public function DynamicTestClass(){
-
- }*/
-
-
- [TestMeta(foo="instanceMethod")]
- public function method():void{
-
- }
-
- [TestMeta(foo="instanceMethod")]
- public function methodWithArgs(mandatory:String,optional:Boolean=true):void{
- _test = mandatory;
- }
-
- [TestMeta(foo="instanceVariable")]
- public var testVar:String;
-
- [TestMeta(foo="instanceAccessor")]
- public function get testGetter():String{
- return null
- }
-
- [TestMeta(foo="instanceAccessor")]
- public function set testSetter(value:String):void{
-
- }
-
- private var _test:String;
-
- [TestMeta(foo="staticMethod")]
- public static function method():void{
- }
-
- [TestMeta(foo="staticMethod")]
- public static function methodWithArgs(mandatory:String,optional:Boolean=true):void{
- }
-
- [TestMeta(foo="staticVariable")]
- public static var testVar:String;
-
- [TestMeta(foo="staticAccessor")]
- public static function get testGetter():String{
- return null
- }
-
- [TestMeta(foo="staticAccessor")]
- public static function set testSetter(value:String):void{
-
- }
-
- private var private_var:Boolean;
-
- protected var protected_var:Boolean;
-
- private static var private_var:Boolean;
-
- protected static var protected_var:Boolean;
-
- }
+
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ dynamic public class DynamicTestClass
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing reflection into it
+
+ /*public function DynamicTestClass(){
+
+ }*/
+
+
+ [TestMeta(foo="instanceMethod")]
+ public function method():void
+ {
+
+ }
+
+ [TestMeta(foo="instanceMethod")]
+ public function methodWithArgs(mandatory:String, optional:Boolean = true):void
+ {
+ _test = mandatory;
+ }
+
+ [TestMeta(foo="instanceVariable")]
+ public var testVar:String;
+
+ [TestMeta(foo="instanceAccessor")]
+ public function get testGetter():String
+ {
+ return null
+ }
+
+ [TestMeta(foo="instanceAccessor")]
+ public function set testSetter(value:String):void
+ {
+
+ }
+
+ private var _test:String;
+
+ [TestMeta(foo="staticMethod")]
+ public static function method():void
+ {
+ }
+
+ [TestMeta(foo="staticMethod")]
+ public static function methodWithArgs(mandatory:String, optional:Boolean = true):void
+ {
+ }
+
+ [TestMeta(foo="staticVariable")]
+ public static var testVar:String;
+
+ [TestMeta(foo="staticAccessor")]
+ public static function get testGetter():String
+ {
+ return null
+ }
+
+ [TestMeta(foo="staticAccessor")]
+ public static function set testSetter(value:String):void
+ {
+
+ }
+
+ private var private_var:Boolean;
+
+ protected var protected_var:Boolean;
+
+ private static var private_var:Boolean;
+
+ protected static var protected_var:Boolean;
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass2.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass2.as
index 2be6a15..75f7a50 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass2.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass2.as
@@ -18,42 +18,48 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
-
-
- dynamic public class DynamicTestClass2 extends TestClass1
- {
- //Note: do not change this test class unless you change the related tests to
- //support any changes that might appear when testing reflection into it
-
- public function DynamicTestClass2(){
- //his.constructorDynTest = 'constructorDynTest';
- }
-
- public var something:String;
-
- [TestMeta(foo="staticMethod")]
- public static function method():void{
- }
-
- [TestMeta(foo="staticMethod")]
- public static function methodWithArgs(mandatory:String,optional:Boolean=true):void{
- }
-
- [TestMeta(foo="staticVariable")]
- public static var testVar:String;
-
- [TestMeta(foo="staticAccessor")]
- public static function get testGetter():String{
- return null
- }
-
- [TestMeta(foo="staticAccessor")]
- public static function set testSetter(value:String):void{
-
- }
-
-
-
- }
+
+
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ dynamic public class DynamicTestClass2 extends TestClass1
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing reflection into it
+
+ public function DynamicTestClass2()
+ {
+ //his.constructorDynTest = 'constructorDynTest';
+ }
+
+ public var something:String;
+
+ [TestMeta(foo="staticMethod")]
+ public static function method():void
+ {
+ }
+
+ [TestMeta(foo="staticMethod")]
+ public static function methodWithArgs(mandatory:String, optional:Boolean = true):void
+ {
+ }
+
+ [TestMeta(foo="staticVariable")]
+ public static var testVar:String;
+
+ [TestMeta(foo="staticAccessor")]
+ public static function get testGetter():String
+ {
+ return null
+ }
+
+ [TestMeta(foo="staticAccessor")]
+ public static function set testSetter(value:String):void
+ {
+
+ }
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass3.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass3.as
index ce73e9d..4e86b91 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass3.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/DynamicTestClass3.as
@@ -18,19 +18,20 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
- import org.apache.royale.core.UIBase;
-
- dynamic public class DynamicTestClass3 extends UIBase
- {
- //Note: do not change this test class unless you change the related tests to
- //support any changes that might appear when testing reflection into it
-
- public function DynamicTestClass3(){
-
-
- }
-
-
- }
+
+ import org.apache.royale.core.UIBase;
+
+ dynamic public class DynamicTestClass3 extends UIBase
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing reflection into it
+
+ public function DynamicTestClass3()
+ {
+
+
+ }
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface.as
index bb814b7..05b66c7 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface.as
@@ -18,10 +18,10 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
- public interface ITestInterface
- {
- function someMethod(compulsoryArg:int, optArg:String=null):TestClass1;
-
- }
+
+ public interface ITestInterface
+ {
+ function someMethod(compulsoryArg:int, optArg:String = null):TestClass1;
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface2.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface2.as
index 1ce3081..a9e979e 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface2.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface2.as
@@ -18,12 +18,12 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
- public interface ITestInterface2 extends ITestInterface
- {
- function someMethod2(compulsoryArg:int, optArg:String=null):TestClass1;
-
- function get someValue2():Boolean;
-
- }
+
+ public interface ITestInterface2 extends ITestInterface
+ {
+ function someMethod2(compulsoryArg:int, optArg:String = null):TestClass1;
+
+ function get someValue2():Boolean;
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
index 05825f4..51f9ca4 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface3.as
@@ -18,10 +18,10 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
- public interface ITestInterface3
- {
- //empty
-
- }
+
+ public interface ITestInterface3
+ {
+ //empty
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface4.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface4.as
index 02d51cc..cd0a956 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface4.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/ITestInterface4.as
@@ -18,12 +18,12 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
- public interface ITestInterface4 extends ITestInterface2, ITestInterface3
- {
- function someMethod3(compulsoryArg:int, optArg:String=null):TestClass1;
-
- function get someValue3():Boolean;
-
- }
+
+ public interface ITestInterface4 extends ITestInterface2, ITestInterface3
+ {
+ function someMethod3(compulsoryArg:int, optArg:String = null):TestClass1;
+
+ function get someValue3():Boolean;
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass1.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass1.as
index 8132890..91b9f35 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass1.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass1.as
@@ -18,75 +18,86 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
- import org.apache.royale.reflection.TypeDefinition;
-
- [RemoteClass(alias="TestClass1_alias")]
- public class TestClass1 implements ITestInterface
- {
- public function TestClass1()
- {
- // var something:ITestInterface2;
- }
-
- [Bindable]
- [Event(name="foo", type="org.apache.royale.events.Event")]
- public var bindableVar:String;
-
- [Event(name="foo", type="org.apache.royale.events.Event")]
- public var temp:Boolean;
-
- public static var tempStatic:Boolean;
-
- public var typeDef:TypeDefinition;
-
- public var testVar:String="testVar_val";
-
- public static var staticTestVar:String="statictestVar_val";
-
- private var _atestval:String="accessorTest_val";
- public function get accessorTest():String{
- return _atestval;
- }
-
- public function set accessorTest(val:String):void{
- _atestval = val;
- }
-
- private static var _staticAtestval:String="staticAccessorTest_val";
- public static function get staticAccessorTest():String{
- return _staticAtestval;
- }
-
- public static function set staticAccessorTest(val:String):void{
- _staticAtestval = val;
- }
-
- [Bindable]
- public static var bindableStaticVar:String;
-
- [Bindable]
- public var bindableInstanceVar:String;
-
-
- public function someMethod(compulsoryArg:int, optArg:String=null):TestClass1{
- return null;
- }
-
- public static function someStaticMethod(compulsoryArg:int, optArg:String=null):TestClass1{
- return null;
- }
-
- public function get testAccessorType():TypeDefinition {
- return null;
- }
-
- public const instanceConstant:String="instanceConstant_val";
-
-
- public static const staticConstant:String="staticConstant_val";
-
-
-
- }
+
+ import org.apache.royale.reflection.TypeDefinition;
+
+ [RemoteClass(alias="TestClass1_alias")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class TestClass1 implements ITestInterface
+ {
+ public function TestClass1()
+ {
+ // var something:ITestInterface2;
+ }
+
+ [Bindable]
+ [Event(name="foo", type="org.apache.royale.events.Event")]
+ public var bindableVar:String;
+
+ [Event(name="foo", type="org.apache.royale.events.Event")]
+ public var temp:Boolean;
+
+ public static var tempStatic:Boolean;
+
+ public var typeDef:TypeDefinition;
+
+ public var testVar:String = "testVar_val";
+
+ public static var staticTestVar:String = "statictestVar_val";
+
+ private var _atestval:String = "accessorTest_val";
+
+ public function get accessorTest():String
+ {
+ return _atestval;
+ }
+
+ public function set accessorTest(val:String):void
+ {
+ _atestval = val;
+ }
+
+ private static var _staticAtestval:String = "staticAccessorTest_val";
+
+ public static function get staticAccessorTest():String
+ {
+ return _staticAtestval;
+ }
+
+ public static function set staticAccessorTest(val:String):void
+ {
+ _staticAtestval = val;
+ }
+
+ [Bindable]
+ public static var bindableStaticVar:String;
+
+ [Bindable]
+ public var bindableInstanceVar:String;
+
+
+ public function someMethod(compulsoryArg:int, optArg:String = null):TestClass1
+ {
+ return null;
+ }
+
+ public static function someStaticMethod(compulsoryArg:int, optArg:String = null):TestClass1
+ {
+ return null;
+ }
+
+ public function get testAccessorType():TypeDefinition
+ {
+ return null;
+ }
+
+ public const instanceConstant:String = "instanceConstant_val";
+
+
+ public static const staticConstant:String = "staticConstant_val";
+
+
+ }
}
diff --git a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass2.as b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass2.as
index c4baae5..375c95f 100644
--- a/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass2.as
+++ b/manualtests/UnitTests/src/main/royale/flexUnitTests/reflection/support/TestClass2.as
@@ -18,86 +18,103 @@
////////////////////////////////////////////////////////////////////////////////
package flexUnitTests.reflection.support
{
-
-
- [TestMeta(foo="class")]
- public class TestClass2
- {
- //Note: do not change this test class unless you change the related tests to
- //support any changes that might appear when testing reflection into it
-
- public function TestClass2(blah:String){
-
- }
-
-
- [TestMeta(foo="instanceMethod")]
- public function testMethod():void{
- _testReadWrite = "testMethod was called";
- }
-
- [TestMeta(foo="instanceMethod")]
- public function testMethodWithArgs(mandatory:String,optional:Boolean=true):Boolean{
- _testReadWrite = "testMethodWithArgs was called";
- return optional;
- }
-
- [TestMeta(foo="instanceVariable")]
- public var testVar:String = "testVar_val";
-
- [TestMeta(foo="instanceAccessor")]
- public function get testReadOnly():String{
- return _testReadWrite
- }
-
- [TestMeta(foo="instanceAccessor")]
- public function set testWriteOnly(value:String):void{
- _testReadWrite=value;
- }
-
- [TestMeta(foo="instanceAccessor")]
- public function get testReadWrite():String{
- return _testReadWrite
- }
- public function set testReadWrite(value:String):void{
- _testReadWrite=value;
- }
-
- [TestMeta(foo="staticMethod")]
- public static function testStaticMethod():void{
- _testStaticReadWrite = "testStaticMethod was called";
- }
-
- [TestMeta(foo="staticMethod")]
- public static function testStaticMethodWithArgs(mandatory:String,optional:Boolean=true):Boolean{
- _testStaticReadWrite = "testStaticMethodWithArgs was called";
- return optional;
- }
-
- [TestMeta(foo="staticVariable")]
- public static var testStaticVar:String = "testStaticVar_val";
-
- [TestMeta(foo="staticAccessor")]
- public static function get testStaticReadOnly():String{
- return _testStaticReadWrite
- }
-
- [TestMeta(foo="staticAccessor")]
- public static function set testStaticWriteOnly(value:String):void{
- _testStaticReadWrite = value;
- }
-
- [TestMeta(foo="staticAccessor")]
- public static function get testStaticReadWrite():String{
- return _testStaticReadWrite;
- }
- public static function set testStaticReadWrite(value:String):void{
- _testStaticReadWrite = value;
- }
-
-
-
- private static var _testStaticReadWrite:String = "staticAccessor_initial_value";
- private var _testReadWrite:String = "instanceAccessor_initial_value";
- }
+
+
+ [TestMeta(foo="class")]
+ /**
+ * @royalesuppresspublicvarwarning
+ */
+ public class TestClass2
+ {
+ //Note: do not change this test class unless you change the related tests to
+ //support any changes that might appear when testing reflection into it
+
+ public function TestClass2(blah:String)
+ {
+
+ }
+
+
+ [TestMeta(foo="instanceMethod")]
+ public function testMethod():void
+ {
+ _testReadWrite = "testMethod was called";
+ }
+
+ [TestMeta(foo="instanceMethod")]
+ public function testMethodWithArgs(mandatory:String, optional:Boolean = true):Boolean
+ {
+ _testReadWrite = "testMethodWithArgs was called";
+ return optional;
+ }
+
+ [TestMeta(foo="instanceVariable")]
+ public var testVar:String = "testVar_val";
+
+ [TestMeta(foo="instanceAccessor")]
+ public function get testReadOnly():String
+ {
+ return _testReadWrite
+ }
+
+ [TestMeta(foo="instanceAccessor")]
+ public function set testWriteOnly(value:String):void
+ {
+ _testReadWrite = value;
+ }
+
+ [TestMeta(foo="instanceAccessor")]
+ public function get testReadWrite():String
+ {
+ return _testReadWrite
+ }
+
+ public function set testReadWrite(value:String):void
+ {
+ _testReadWrite = value;
+ }
+
+ [TestMeta(foo="staticMethod")]
+ public static function testStaticMethod():void
... 1358 lines suppressed ...