commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r996377 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: build-common.xml build.xml mvn-ant-build.xml pom.xml src/javascript/scxml/cgf/util/base.js
Date Sun, 12 Sep 2010 19:41:27 GMT
Author: jbeard
Date: Sun Sep 12 19:41:27 2010
New Revision: 996377

URL: http://svn.apache.org/viewvc?rev=996377&view=rev
Log:
Hooked maven build into run-unit-tests-with-rhino ant task via AntRun.
Also, removed dependency on Rhino 1.7_3RC, which was not in Maven. Now using Rhino 1.7_2,
from Maven. This involved refactoring use of Array.reduce in the compiler and build scripts.
Both maven and ant work well with this commit.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml?rev=996377&r1=996376&r2=996377&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml Sun Sep 12 19:41:27 2010
@@ -69,8 +69,6 @@
 	<property name="selenium_safari_id" value="*safari"/>
 
 	<!-- classpath configuration stuff -->
-	<property name="lib-rhino" location="${lib-java}/js.jar"/>
-	<path id="rhino-classpath" location="${lib-rhino}" />
 	<path id="closure-classpath" location="${lib-js}/requirejs/build/lib/closure/compiler.jar"/>
 
 	<path id="requirejs_bootstrap_paths">
@@ -183,25 +181,6 @@
 			</else>
 		</if>
 
-
-
-		<!-- latest rhino -->
-		<if>
-			<not>
-				<available file="${lib-rhino}"/>
-			</not>
-
-			<then>
-				<echo>Downloading Rhino...</echo>
-				<get dest="${tmp-dir}/rhino1_7R3pre.zip" usetimestamp="true" ignoreerrors="true" src="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3pre.zip"/>
-				<unzip src="${tmp-dir}/rhino1_7R3pre.zip" dest="${tmp-dir}"/>
-				<copy file="${tmp-dir}/rhino1_7R3pre/js.jar" tofile="${lib-java}/js.jar"/>
-			</then>
-			<else>
-				<echo>Rhino up-to-date</echo>
-			</else>
-		</if>
-
 		<delete dir="${tmp-dir}"/>
 	</target>
 
@@ -220,7 +199,6 @@
 			<!-- TODO: update classpath here -->
 			<script language="javascript" manager="bsf">
 				<classpath>
-					<path refid="rhino-classpath"/>
 					<path refid="maven.plugin.classpath"/>
 				</classpath><![CDATA[
 					var shell = org.mozilla.javascript.tools.shell.Main;
@@ -254,6 +232,45 @@
 						log : print,
 						debug : print
 					}
+
+					//add in built-in function reduce for js implementations that do not support it
+					//this code is from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce#Compatibility
+					//MIT licensed, according to https://developer.mozilla.org/Project:Copyrights
+					function reduce(arr,fun /*, initial*/) {
+						var len = arr.length >>> 0;
+						if (typeof fun != "function")
+							throw new TypeError();
+
+						// no value to return if no initial value and an empty array
+						if (len == 0 && arguments.length == 2)
+							throw new TypeError();
+
+						var i = 0;
+						if (arguments.length >= 3) {
+							var rv = arguments[2];
+						}
+						else {
+							do {
+								if (i in arr) {
+									var rv = arr[i++];
+									break;
+								}
+
+								// if array contains no values, no initial value to return
+								if (++i >= len)
+									throw new TypeError();
+							}
+							while (true);
+						}
+
+						for (; i < len; i++) {
+							if (i in arr)
+								rv = fun.call(undefined, rv, arr[i], i, arr);
+						}
+
+						return rv;
+					}
+					
 	
 					@{text}
 			]]></script>
@@ -268,9 +285,9 @@
 		<sequential>
 			<echo>Compiling @{test-path} to @{out-path} with backend @{backend} and flags for
IE...</echo>
 
-			<java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}">
+			<java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}" fork="true">
 				<classpath>
-					<path refid="rhino-classpath"/>
+					<path refid="maven.plugin.classpath"/>
 					<path refid="maven.compile.classpath"/>
 				</classpath>
 
@@ -294,9 +311,9 @@
 		<sequential>
 			<echo>Compiling @{test-path} to @{out-path} with backend @{backend}...</echo>
 
-			<java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}">
+			<java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}" fork="true">
 				<classpath>
-					<path refid="rhino-classpath"/>
+					<path refid="maven.plugin.classpath"/>
 					<path refid="maven.compile.classpath"/>
 				</classpath>
 
@@ -528,10 +545,10 @@
 					bSel.stop();
 				});
 
-				var totalTests = unitTestResults.reduce(function(a,b){return a + b.data.testCount},0);
-				var totalTestsFailed = unitTestResults.reduce(function(a,b){return a + b.data.errorCount},0);
-				var totalTestsErrored = unitTestResults.reduce(function(a,b){return a + b.data.failCount},0);
-				var totalTestsPassed = unitTestResults.reduce(function(a,b){return a + b.data.testsPassed},0);
+				var totalTests = reduce(unitTestResults,function(a,b){return a + b.data.testCount},0);
+				var totalTestsFailed = reduce(unitTestResults,function(a,b){return a + b.data.errorCount},0);
+				var totalTestsErrored = reduce(unitTestResults,function(a,b){return a + b.data.failCount},0);
+				var totalTestsPassed = reduce(unitTestResults,function(a,b){return a + b.data.testsPassed},0);
 
 				print("Test Results:");
 				print("Total Tests: " + totalTests);

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml?rev=996377&r1=996376&r2=996377&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml Sun Sep 12 19:41:27 2010
@@ -37,15 +37,57 @@
 	<artifact:remoteRepository id="openqa-releases" url="http://nexus.openqa.org/content/repositories/releases"
/>
 
 	<!-- TODO: attempt better integration with pom.xml, so we do not need to duplicate ant
plugin depencies here -->
+	<!-- TODO: add rhino dep -->
 	<artifact:dependencies pathId="maven.plugin.classpath">
-		<artifact:dependency groupId="bsf" artifactId="bsf" version="2.4.0"/>
-		<artifact:dependency groupId="commons-logging" artifactId="commons-logging" version="1.1.1"/>
 		<artifact:dependency groupId="ant-contrib" artifactId="ant-contrib" version="1.0b3">
 			<artifact:exclusion groupId="ant" artifactId="ant"/>
 		</artifact:dependency>
-		<!--<artifact:dependency groupId="org.apache.maven" artifactId="maven-ant-tasks"
version="2.1.1"/>-->
-		<artifact:dependency groupId="xalan" artifactId="xalan" version="2.7.0"/>
-		<artifact:dependency groupId="org.seleniumhq.selenium.client-drivers" artifactId="selenium-java-client-driver"
version="1.0.1"/>
+
+		<!-- dependencies for running Rhino JavaScript scripts in Ant -->
+		<artifact:dependency
+			groupId="bsf"
+			artifactId="bsf"
+			version="2.4.0"
+		/>
+		<artifact:dependency
+			groupId="org.apache.ant"
+			artifactId="ant-apache-bsf"
+			version="1.7.1"
+		/>
+		<artifact:dependency
+			groupId="org.apache.ant" 
+			artifactId="ant-nodeps" 
+			version="1.7.1" 
+		/>
+		<artifact:dependency
+			groupId="org.apache.ant"
+			artifactId="ant-trax"
+			version="1.7.1"
+		/>
+		<artifact:dependency
+			groupId="rhino" 
+			artifactId="js" 
+			version="1.7R2" 
+		/>
+
+		<!-- selenium dependencies -->
+		<artifact:dependency
+			groupId="org.seleniumhq.selenium.client-drivers"
+			artifactId="selenium-java-client-driver"
+			version="1.0.1"
+		/>
+
+		<!-- other dependencies -->
+		<artifact:dependency
+			groupId="commons-logging"
+			artifactId="commons-logging"
+			version="1.1.1"
+		/>
+		<artifact:dependency
+			groupId="xalan"
+			artifactId="xalan"
+			version="2.7.0"
+		/>
 
 		<artifact:remoteRepository refid="openqa-releases" />
 	</artifact:dependencies>
@@ -62,43 +104,7 @@
 	-->
 
 	<!-- run unit and performance tests -->
-	<target name="generate-javascript" depends="preprocess-stylesheets,setup-properties">
-		<mkdir dir="${build}/generate-javascript"/>
-	
-		<for list="${for-ie}" param="for-ie">
-			<sequential>
-				<for list="${backends}" param="backend">
-					<sequential>
-						<for param="test-path">
-							<path refid="scxml_tests_xml"/>
-							<sequential>
-
-								<echo>${@{for-ie}-@{backend}-@{test-path}-target-test-path}, ${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}</echo>

-
-								<mkdir dir="${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}"/>
-								
-								<if>
-									<equals arg1="@{for-ie}" arg2="is-for-ie"/>
-									<then>
-										<compile-with-scxml-js-ie
-											test-path="@{test-path}"
-											backend="@{backend}"
-											out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
-									</then>
-									<else>
-										<compile-with-scxml-js-no-ie
-											test-path="@{test-path}"
-											backend="@{backend}"
-											out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
-									</else>
-								</if>
-							</sequential>
-						</for>
-					</sequential>
-				</for>
-			</sequential>
-		</for>
-	</target>
+	<target name="generate-javascript" depends="setup-properties,preprocess-stylesheets,generate-javascript-mvn"/>
 
 	<target name="generate-unit-test-html" depends="setup-properties">
 		<mkdir dir="${build}/generate-unit-tests-html"/>
@@ -157,7 +163,7 @@
 		</for>
 	</target>
 
-	<target name="run-unit-tests-with-selenium" depends="generate-unit-test-html,generate-javascript"
if="isWindows">
+	<target name="run-unit-tests-with-selenium" depends="generate-javascript,generate-unit-test-html"
if="isWindows">
 		<run-unit-tests-with-selenium-macro 
 			unit-tests-html-property-name="unit-test-html-location"/>
 	</target>
@@ -168,99 +174,12 @@
 			unit-tests-html-property-name="in-browser-unit-test-html-location"/>
 	</target>
 
-	<!-- TODO: move rhino unit tests up -->
-	<target name="run-unit-tests-with-rhino" depends="generate-javascript">
-		<rhinoscript><![CDATA[
-			//load requirejs
-			Array.prototype.slice.call(requirejs_bootstrap_paths.list()).forEach(function(requireJsPath){
-				load(requireJsPath);
-			});
-
-
-			//this is a bit weird, but we define this here in case we need to load dojo later using
the RequireJS loader
-			djConfig = {
-				"baseUrl" : path_to_dojo_base+"/"
-			}
-
-			function tailRecurse(list,stepCallback,baseCaseCallback){
-				var target = list.pop();
-				
-				if(target){
-					stepCallback(target, 
-						function(){tailRecurse(list,stepCallback,baseCaseCallback)});
-				}else{
-					if(baseCaseCallback) baseCaseCallback();
-				}
-			}
-
-			var isComplete = false;
-
-			require(
-				{baseUrl:basedir},
-				[path_to_dojo, 
-					"lib/test-js/env.js",
-					"test/testHelpers.js"],
-				function(){
-
-					dojo.require("doh.runner");	
-
-					var forIE = "is-for-ie";
-					var scxmlXmlTestPathList = Array.prototype.slice.call(scxml_tests_xml.list());
-					var backendsList = backends.split(",");
-
-					var oldDohOnEnd = doh._onEnd;
-					doh._onEnd = function() { isComplete = true; oldDohOnEnd.apply(doh); };
-
-					//we use tailRecurse function because of asynchronous RequireJS call used to load the
unit test module
-					tailRecurse(scxmlXmlTestPathList,
-						function(scxmlXmlTestPath,step){
-							var jsUnitTestPathPropertyName = scxmlXmlTestPath + "-" + "unit-test-js-module";
-							var jsUnitTestPath = project.getProperty(jsUnitTestPathPropertyName);
-
-							require([jsUnitTestPath],
-								function(unitTestModule){
-
-									var jsUnitTestPathPropertyNames = 
-										[{forIE:forIE, backend:backend,test_path:scxmlXmlTestPath}
-											for each (backend in backendsList)];
-
-									jsUnitTestPathPropertyNames.forEach(function(target){
-
-										var jsTargetTestPathPropertyName =  
-											target.forIE + "-" + target.backend + "-" + target.test_path + "-" + "target-test-path";
-										var jsTargetTestPath = project.getProperty(jsTargetTestPathPropertyName);
-
-										//load and register
-										load(jsTargetTestPath);
-
-										unitTestModule.register(StatechartExecutionContext)
-										delete StatechartExecutionContext;
-									}) 
-
-									step();
-								});
-						},
-						function(){
-							//run with dojo
-							doh.run();
-						}
-					);
-
-				}
-			);
-
-			//hold up execution until doh completes
-			while(!isComplete){
-				java.lang.Thread.sleep(20);
-			}
-
-		]]></rhinoscript>
-	</target>
 
 	<!-- TODO: add OS check so we don't do selenium tests on non-Windows OS -->
 	<target name="run-all-unit-tests" 
 		depends="run-unit-tests-with-selenium,run-in-browser-unit-tests-with-selenium,run-unit-tests-with-rhino"
/>
 
+	<target name="run-unit-tests-with-rhino" depends="generate-javascript,run-unit-tests-with-rhino-mvn"/>
 
 	<!-- build standalone executable -->
 	<!-- delegate appropriately to the standalone maven tasks -->
@@ -285,8 +204,7 @@
 	<target name="run-single-class" depends="compile-single-class">
 		<java classname="${build-class-main-name}" output="${build}/out.js">
 			<classpath>
-				<path refid="rhino-classpath"/>
-				<path refid="maven.compile.classpath"/>
+				<path refid="maven.plugin.classpath"/>
 				<pathelement location="${build-class}"/>
 			</classpath>
 			<arg value="--backend"/>
@@ -299,8 +217,7 @@
 	<target name="run-single-jar" depends="jar-single-class">
 		<java classname="${build-class-main-name}" output="${build}/out.js">
 			<classpath>
-				<path refid="rhino-classpath"/>
-				<path refid="maven.compile.classpath"/>
+				<path refid="maven.plugin.classpath"/>
 				<pathelement location="${build-jar-main}"/>
 			</classpath>
 			<arg value="--backend"/>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml?rev=996377&r1=996376&r2=996377&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml Sun Sep 12 19:41:27 2010
@@ -38,7 +38,7 @@
 
 		<java classname="org.mozilla.javascript.tools.shell.Main">
 			<classpath>
-				<path refid="rhino-classpath"/>
+				<path refid="maven.plugin.classpath"/>
 				<path refid="closure-classpath"/>
 			</classpath>
 			<arg value="${js-build-script}"/>
@@ -60,7 +60,7 @@
 		<!-- TODO: set -opt -->
 		<java classname="org.mozilla.javascript.tools.jsc.Main">
 			<classpath>
-				<path refid="rhino-classpath"/>
+				<path refid="maven.plugin.classpath"/>
 			</classpath>
 			<arg value="-opt"/>
 			<arg value="9"/>
@@ -70,4 +70,134 @@
 		</java>
 		<move file="${build-js}/${build-class-main-name}.class" todir="${build-class}"/>
 	</target>
+
+	<!-- unit test stuff -->
+
+	<target name="generate-javascript-mvn" depends="setup-properties">
+		<mkdir dir="${build}/generate-javascript"/>
+	
+		<for list="${for-ie}" param="for-ie">
+			<sequential>
+				<for list="${backends}" param="backend">
+					<sequential>
+						<for param="test-path">
+							<path refid="scxml_tests_xml"/>
+							<sequential>
+
+								<echo>${@{for-ie}-@{backend}-@{test-path}-target-test-path}, ${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}</echo>

+
+								<mkdir dir="${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}"/>
+								
+								<if>
+									<equals arg1="@{for-ie}" arg2="is-for-ie"/>
+									<then>
+										<compile-with-scxml-js-ie
+											test-path="@{test-path}"
+											backend="@{backend}"
+											out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+									</then>
+									<else>
+										<compile-with-scxml-js-no-ie
+											test-path="@{test-path}"
+											backend="@{backend}"
+											out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+									</else>
+								</if>
+							</sequential>
+						</for>
+					</sequential>
+				</for>
+			</sequential>
+		</for>
+	</target>
+
+	<target name="run-unit-tests-with-rhino-mvn" depends="setup-properties">
+		<rhinoscript><![CDATA[
+			//load requirejs
+			Array.prototype.slice.call(requirejs_bootstrap_paths.list()).forEach(function(requireJsPath){
+				load(requireJsPath);
+			});
+
+			//this is a bit weird, but we define this here in case we need to load dojo later using
the RequireJS loader
+			djConfig = {
+				"baseUrl" : path_to_dojo_base+"/"
+			}
+
+			function tailRecurse(list,stepCallback,baseCaseCallback){
+				var target = list.pop();
+				
+				if(target){
+					stepCallback(target, 
+						function(){tailRecurse(list,stepCallback,baseCaseCallback)});
+				}else{
+					if(baseCaseCallback) baseCaseCallback();
+				}
+			}
+
+			var isComplete = false;
+
+			require(
+				{baseUrl:basedir},
+				[path_to_dojo, 
+					"lib/test-js/env.js",
+					"test/testHelpers.js"],
+				function(){
+
+					dojo.require("doh.runner");	
+
+					var forIE = "is-for-ie";
+					var scxmlXmlTestPathList = Array.prototype.slice.call(scxml_tests_xml.list());
+					var backendsList = backends.split(",");
+
+					print("backendsList : " + backendsList);
+					print("backendsList.length : " + backendsList.length);
+
+					var oldDohOnEnd = doh._onEnd;
+					doh._onEnd = function() { isComplete = true; oldDohOnEnd.apply(doh); };
+
+					//we use tailRecurse function because of asynchronous RequireJS call used to load the
unit test module
+					tailRecurse(scxmlXmlTestPathList,
+						function(scxmlXmlTestPath,step){
+							var jsUnitTestPathPropertyName = scxmlXmlTestPath + "-" + "unit-test-js-module";
+							var jsUnitTestPath = project.getProperty(jsUnitTestPathPropertyName);
+
+							require([jsUnitTestPath],
+								function(unitTestModule){
+
+									backendsList.forEach(function(backend){
+										var jsTargetTestPathPropertyName =  
+											forIE + "-" + backend + "-" + scxmlXmlTestPath + "-" + "target-test-path";
+
+										var jsTargetTestPath = project.getProperty(jsTargetTestPathPropertyName);
+
+										print("jsTargetTestPathPropertyName : " + jsTargetTestPathPropertyName);
+										print("jsTargetTestPath  : " + jsTargetTestPath);
+
+										//load and register
+										load(jsTargetTestPath);
+
+										unitTestModule.register(StatechartExecutionContext)
+										delete StatechartExecutionContext;
+									});
+
+
+									step();
+								});
+						},
+						function(){
+							//run with dojo
+							doh.run();
+						}
+					);
+
+				}
+			);
+
+			//hold up execution until doh completes
+			while(!isComplete){
+				java.lang.Thread.sleep(20);
+			}
+
+		]]></rhinoscript>
+	</target>
 </project>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml?rev=996377&r1=996376&r2=996377&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml Sun Sep 12 19:41:27 2010
@@ -235,8 +235,60 @@
               <goal>run</goal>
             </goals>
           </execution>
+          <execution>
+	    <id>generate-test-sources</id>
+            <phase>generate-test-sources</phase>
+            <configuration>
+              <tasks>
+		<ant target="generate-javascript-mvn" inheritRefs="true" antfile="mvn-ant-build.xml"/>
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+          <execution>
+	    <id>test</id>
+            <phase>test</phase>
+            <configuration>
+              <tasks>
+		<ant target="run-unit-tests-with-rhino-mvn" inheritRefs="true" antfile="mvn-ant-build.xml"/>
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
         </executions>
 	<dependencies>
+		<!-- dependencies for running Rhino JavaScript scripts in Ant -->
+		<dependency>
+			<groupId>bsf</groupId>
+			<artifactId>bsf</artifactId>
+			<version>2.4.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.ant</groupId>
+			<artifactId>ant-apache-bsf</artifactId>
+			<version>1.7.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.ant</groupId> 
+			<artifactId>ant-nodeps</artifactId> 
+			<version>1.7.1</version> 
+		</dependency>
+		<dependency>
+			<groupId>org.apache.ant</groupId>
+			<artifactId>ant-trax</artifactId>
+			<version>1.7.1</version>
+		</dependency>
+		<dependency>
+			<groupId>rhino</groupId> 
+			<artifactId>js</artifactId> 
+			<version>1.7R2</version> 
+		</dependency>
+
+		<!-- selenium dependencies -->
 		<dependency>
 			<groupId>org.seleniumhq.selenium.client-drivers</groupId>
 			<artifactId>selenium-java-client-driver</artifactId>
@@ -250,11 +302,8 @@
 		    <classifier>standalone</classifier>
 		</dependency>
 		-->
-		<dependency>
-			<groupId>bsf</groupId>
-			<artifactId>bsf</artifactId>
-			<version>2.4.0</version>
-		</dependency>
+
+		<!-- other dependencies -->
 		<dependency>
 			<groupId>commons-logging</groupId>
 			<artifactId>commons-logging</artifactId>
@@ -271,31 +320,19 @@
 				</exclusion>
 			</exclusions>
 		</dependency>
-		<!-- FIXME: this dependency was breaking the build somehow -->
-		<!--
-		<dependency>
-			<groupId>org.apache.maven</groupId>
-			<artifactId>maven-ant-tasks</artifactId>
-			<version>2.1.1</version>
-		</dependency>
-		-->
 		<dependency>
+			<!-- for preprocessing XSL from Ant -->
 			<groupId>xalan</groupId>
 			<artifactId>xalan</artifactId>
 			<version>2.7.0</version>
 		</dependency>
+
+		<!-- FIXME: this dependency was breaking the build somehow -->
 		<!--
 		<dependency>
-			<groupId>org.seleniumhq.selenium.client-drivers</groupId>
-			<artifactId>selenium-java-client-driver</artifactId>
-			<version>1.0.1</version>
-		</dependency>
-		-->
-		<!--
-		<dependency>
-			<groupId>rhino</groupId>
-			<artifactId>js</artifactId>
-			<version>1.7R2</version>
+			<groupId>org.apache.maven</groupId>
+			<artifactId>maven-ant-tasks</artifactId>
+			<version>2.1.1</version>
 		</dependency>
 		-->
 	</dependencies>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js?rev=996377&r1=996376&r2=996377&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/base.js Sun Sep
12 19:41:27 2010
@@ -40,5 +40,44 @@ function(){
 			return false;
 		}
 	}
+
+	//add in built-in function reduce for js implementations that do not support it
+	//this code is from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce#Compatibility
+	if (!Array.prototype.reduce) {
+		Array.prototype.reduce = function(fun /*, initial*/) {
+			var len = this.length >>> 0;
+			if (typeof fun != "function")
+				throw new TypeError();
+
+			// no value to return if no initial value and an empty array
+			if (len == 0 && arguments.length == 1)
+				throw new TypeError();
+
+			var i = 0;
+			if (arguments.length >= 2) {
+				var rv = arguments[1];
+			}
+			else {
+				do {
+					if (i in this) {
+						var rv = this[i++];
+						break;
+					}
+
+					// if array contains no values, no initial value to return
+					if (++i >= len)
+						throw new TypeError();
+				}
+				while (true);
+			}
+
+			for (; i < len; i++) {
+				if (i in this)
+					rv = fun.call(undefined, rv, this[i], i, this);
+			}
+
+			return rv;
+		};
+	}
 });
 



Mime
View raw message