Added example which uses debugging functions

Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/0cd271bf
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/0cd271bf
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/0cd271bf

Branch: refs/heads/feature/strand-work
Commit: 0cd271bf7db0b04e2072dbd80f2587af8611d896
Parents: a43fac3
Author: Harbs <ha...@in-tools.com>
Authored: Sun Jul 16 15:40:22 2017 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Sun Jul 16 15:40:22 2017 +0300

----------------------------------------------------------------------
 examples/flexjs/DebuggingExample/README.txt     |  37 +++++++
 examples/flexjs/DebuggingExample/build.xml      |  55 ++++++++++
 examples/flexjs/DebuggingExample/pom.xml        |  73 +++++++++++++
 .../src/main/config/compile-app-config.xml      |  23 +++++
 .../src/main/flex/DebuggingExample.mxml         |  34 ++++++
 .../src/main/flex/MyInitialView.mxml            | 103 +++++++++++++++++++
 .../org/apache/flex/debugging/assertType.as     |   6 +-
 .../flex/org/apache/flex/debugging/notNull.as   |   6 +-
 8 files changed, 333 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0cd271bf/examples/flexjs/DebuggingExample/README.txt
----------------------------------------------------------------------
diff --git a/examples/flexjs/DebuggingExample/README.txt 
b/examples/flexjs/DebuggingExample/README.txt
new file mode 100644
index 0000000..628187f
--- /dev/null
+++ b/examples/flexjs/DebuggingExample/README.txt
@@ -0,0 +1,37 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+DESCRIPTION
+
+The DebuggingExample shows how to use the debugging package.
+
+This Flex application may be run as a Flash SWF or cross-compiled (using 
Falcon JX)
+into JavaScript and HTML and run without Flash.
+
+
+COMPONENTS and BEADS
+
+- TextButton
+- Label
+- TextArea
+
+
+NOTES
+
+The Changing the content of the TextArea will reverse the passing and failing 
asserts.

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0cd271bf/examples/flexjs/DebuggingExample/build.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DebuggingExample/build.xml 
b/examples/flexjs/DebuggingExample/build.xml
new file mode 100644
index 0000000..a97723d
--- /dev/null
+++ b/examples/flexjs/DebuggingExample/build.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+
+  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.
+
+-->
+
+
+<project name="debuggingexample" default="main" basedir=".">
+    <property name="FLEXJS_HOME" location="../../.."/>
+    <property name="example" value="DebuggingExample" />
+    
+    <property file="${FLEXJS_HOME}/env.properties"/>
+    <property environment="env"/>
+    <property file="${FLEXJS_HOME}/build.properties"/>
+    <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+    <property name="opt1_arg" value="-js-output-optimization=skipAsCoercions" 
/>
+
+    <include file="${basedir}/../../build_example.xml" />
+    
+    <target name="main" depends="clean,build_example.compile" 
description="Clean build of ${example}">
+    </target>
+    
+    <target name="clean">
+        <delete dir="${basedir}/bin" failonerror="false" />
+        <delete dir="${basedir}/bin-debug" failonerror="false" />
+        <delete dir="${basedir}/bin-release" failonerror="false" />
+        <delete dir="${basedir}/target" failonerror="false" />
+    </target>
+
+    <target name="examine" depends="build_example.get.browser">
+        <property name="which" value="debug" />
+        <echo message="Choose from dropdown, get quote, click on checkbox to 
see if TextArea appears and disappears, click on radio buttons to see if other 
labels change via data binding"/>
+        <exec executable="${browser}" dir="${basedir}/bin-${which}" 
failonerror="true">
+            <arg value="${basedir}/bin-${which}/${example}.html"/>
+        </exec>
+        <exec executable="${browser}" dir="${basedir}/bin/js-${which}" 
failonerror="true">
+            <arg value="${basedir}/bin/js-${which}/index.html"/>
+        </exec>
+    </target>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0cd271bf/examples/flexjs/DebuggingExample/pom.xml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DebuggingExample/pom.xml 
b/examples/flexjs/DebuggingExample/pom.xml
new file mode 100644
index 0000000..82ce380
--- /dev/null
+++ b/examples/flexjs/DebuggingExample/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.flex.flexjs.examples</groupId>
+    <artifactId>examples-flexjs</artifactId>
+    <version>0.9.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>DataBindingExample</artifactId>
+  <version>0.9.0-SNAPSHOT</version>
+  <packaging>swf</packaging>
+
+  <name>Apache Flex - FlexJS: Examples: FlexJS: DebuggingExample</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.flex.flexjs.compiler</groupId>
+        <artifactId>flexjs-maven-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <mainClass>DebuggingExample.mxml</mainClass>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>com.adobe.flash.framework</groupId>
+      <artifactId>playerglobal</artifactId>
+      <version>${flash.version}</version>
+      <type>swc</type>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.flex.flexjs.framework</groupId>
+      <artifactId>Network</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <type>swc</type>
+      <classifier>swf</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.flex.flexjs.framework</groupId>
+      <artifactId>Network</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <type>swc</type>
+      <classifier>js</classifier>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0cd271bf/examples/flexjs/DebuggingExample/src/main/config/compile-app-config.xml
----------------------------------------------------------------------
diff --git 
a/examples/flexjs/DebuggingExample/src/main/config/compile-app-config.xml 
b/examples/flexjs/DebuggingExample/src/main/config/compile-app-config.xml
new file mode 100644
index 0000000..b4290dc
--- /dev/null
+++ b/examples/flexjs/DebuggingExample/src/main/config/compile-app-config.xml
@@ -0,0 +1,23 @@
+<!--
+
+  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.
+
+-->
+<flex-config>
+    <js-output-optimization>
+        <optimization>skipFunctionCoercions</optimization>
+    </js-output-optimization>
+</flex-config>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0cd271bf/examples/flexjs/DebuggingExample/src/main/flex/DebuggingExample.mxml
----------------------------------------------------------------------
diff --git 
a/examples/flexjs/DebuggingExample/src/main/flex/DebuggingExample.mxml 
b/examples/flexjs/DebuggingExample/src/main/flex/DebuggingExample.mxml
new file mode 100644
index 0000000..3e8dcf3
--- /dev/null
+++ b/examples/flexjs/DebuggingExample/src/main/flex/DebuggingExample.mxml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+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.
+
+-->
+<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
+                   xmlns:local="*"
+                   xmlns:js="library://ns.apache.org/flexjs/basic" 
+                   >
+       <fx:Style>
+       </fx:Style>
+    <js:valuesImpl>
+        <js:SimpleCSSValuesImpl />
+    </js:valuesImpl>
+    <js:initialView>
+        <local:MyInitialView />
+    </js:initialView>
+    <js:beads>
+    </js:beads>
+</js:Application>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0cd271bf/examples/flexjs/DebuggingExample/src/main/flex/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DebuggingExample/src/main/flex/MyInitialView.mxml 
b/examples/flexjs/DebuggingExample/src/main/flex/MyInitialView.mxml
new file mode 100644
index 0000000..16841d9
--- /dev/null
+++ b/examples/flexjs/DebuggingExample/src/main/flex/MyInitialView.mxml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+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.
+
+-->
+<js:View xmlns:fx="http://ns.adobe.com/mxml/2009";
+                               xmlns:js="library://ns.apache.org/flexjs/basic"
+                           initComplete="init()">
+    <fx:Script>
+        <![CDATA[
+                       import org.apache.flex.debugging.assert;
+                       import org.apache.flex.debugging.assertType;
+                       import org.apache.flex.debugging.check;
+                       // import org.apache.flex.debugging.conditionalBreak;
+                       import org.apache.flex.debugging.notNull;
+                       import org.apache.flex.utils.callLater;
+
+                       import org.apache.flex.html.TextButton;
+
+                       [Bindable]private var taText:String = "Some Text Area 
Text";
+                       private function init():void
+                       {
+                               // callLater(assert1);
+                               // callLater(assert2);
+                               // callLater(assertType1);
+                               // callLater(assertType2);
+                               // callLater(check1);
+                               // callLater(check2);
+                       }
+                       private function assert1():void{
+                               assert(ta.text == taText,"Text doesn't match!");
+                               
+                               
+                       }
+                       private function assert2():void{
+                               assert(ta.text != taText,"Text matches!");
+                               
+                       }
+                       private function assertType1():void{
+                               assertType(ta,TextArea,"ta is not a TextArea!");
+                               
+                       }
+                       private function assertType2():void{
+                               assertType(ta,TextButton,"ta is not a 
TextButton!");
+                               
+                       }
+                       private function check1():void{
+                               check(ta is TextArea,"ta is a TextArea!");
+                               
+                       }
+                       private function check2():void{
+                               check(!(ta is TextArea),"ta is not a 
TextArea!");
+                               
+                       }
+                       private function notNull1():void{
+                               notNull(ta);
+                               
+                       }
+                       private function notNull2():void{
+                               notNull(null);                          
+                       }
+                       private function notNull3():void{
+                               notNull(undefined);                             
+                       }
+            
+               ]]>
+    </fx:Script>
+       <fx:Style>
+       </fx:Style>
+       
+    <js:beads>
+        <js:ViewDataBinding />
+               <js:VerticalLayout />
+    </js:beads>
+               
+    <js:Label text="Just a Label" />
+       
+       <js:TextArea id="ta" width="300" height="100" 
+                                text="{taText}" />
+       <js:TextButton width="120" text="assert() pass" click="assert1()"/>
+       <js:TextButton width="120" text="assert() fail" click="assert2()"/>
+       <js:TextButton width="120" text="assertType() pass" 
click="assertType1()"/>
+       <js:TextButton width="120" text="assertType() fail" 
click="assertType2()"/>
+       <js:TextButton width="120" text="check() pass" click="check1()"/>
+       <js:TextButton width="120" text="check() fail" click="check2()"/>
+       <js:TextButton width="120" text="notNull() pass" click="notNull1()"/>
+       <js:TextButton width="120" text="notNull() fail null" 
click="notNull2()"/>
+       <js:TextButton width="120" text="notNull() fail undefined" 
click="notNull3()"/>
+</js:View>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0cd271bf/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as
 
b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as
index 53bf4b5..f5fc367 100644
--- 
a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as
+++ 
b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/assertType.as
@@ -27,16 +27,16 @@ package org.apache.flex.debugging
     /**
      * asserts an object is of the desired type.
      */
-    public function assertType(obj:Object,type:Class):void
+    public function assertType(obj:Object,type:Class,message:String):void
     {
         COMPILE::SWF
         {
-            assert((obj is type),"object is not the correct type"); 
+            assert((obj is type),message); 
         }
         COMPILE::JS
         {
             if(goog.DEBUG)
-                assert((obj is type),"object is not the correct type"); 
+                assert((obj is type),message); 
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0cd271bf/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as 
b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as
index eb4ba89..d5fe1f1 100644
--- 
a/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as
+++ 
b/frameworks/projects/Core/src/main/flex/org/apache/flex/debugging/notNull.as
@@ -36,7 +36,11 @@ package org.apache.flex.debugging
         COMPILE::JS
         {
             if(goog.DEBUG && obj == null)
-                throw new Error(typeof obj +" not allowed");
+            {
+                var name:String = obj === null ? "null" : "undefined"
+                throw new Error(name +" not allowed");
+
+            }
         }
     }
 }
\ No newline at end of file

Reply via email to