commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r954069 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: src/scxml/cgf/SCXMLCompiler.js test/KitchenSink_executableContent_IR.xml test/testBrowserTransform.html
Date Sat, 12 Jun 2010 19:36:19 GMT
Author: jbeard
Date: Sat Jun 12 19:36:19 2010
New Revision: 954069

URL: http://svn.apache.org/viewvc?rev=954069&view=rev
Log:
Browser-based transformation test now works.

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/KitchenSink_executableContent_IR.xml   (with
props)
Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js?rev=954069&r1=954068&r2=954069&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js Sat Jun 12 19:36:19
2010
@@ -346,6 +346,7 @@ require.def("src/scxml/cgf/SCXMLCompiler
 
 				});
 				
+				print(scxmlRoot);
 				//return scxmlRoot;
 
 				//do transforms

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/KitchenSink_executableContent_IR.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/KitchenSink_executableContent_IR.xml?rev=954069&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/KitchenSink_executableContent_IR.xml (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/KitchenSink_executableContent_IR.xml Sat
Jun 12 19:36:19 2010
@@ -0,0 +1,359 @@
+<scxml xmlns="http://www.w3.org/2005/07/scxml" id="Root" profile="ecmascript" 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.
+	-->
+  <script>self.x=0;
+		self.y=0;</script>
+  <log expr="self.x" label="x"/>
+  <log expr="self.y" label="y"/>
+  <!-- its initial state is Test1 -->
+  <initial id="Root_Initial0" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true">
+    <transition ns0:exitsParallelRegion="true" target="Compound1">
+      <targets xmlns="http://msdl.cs.mcgill.ca/">
+        <target>
+          <targetState>Compound1_Initial1</targetState>
+          <enterpath>
+            <state>Compound1</state>
+            <state>Compound1_Initial1</state>
+          </enterpath>
+        </target>
+      </targets>
+      <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+        <state>Root_Initial0</state>
+      </exitpath>
+      <lca xmlns="http://msdl.cs.mcgill.ca/">Root</lca>
+    </transition>
+  </initial>
+  <!-- Really simple state showing the basic syntax. -->
+  <state id="Compound1">
+    <initial id="Compound1_Initial1" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true">
+      <transition ns0:exitsParallelRegion="true" target="ShallowHistory">
+        <targets xmlns="http://msdl.cs.mcgill.ca/">
+          <target>
+            <targetState>ShallowHistory</targetState>
+            <enterpath>
+              <state>ShallowHistory</state>
+            </enterpath>
+          </target>
+        </targets>
+        <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+          <state>Compound1_Initial1</state>
+        </exitpath>
+        <lca xmlns="http://msdl.cs.mcgill.ca/">Compound1</lca>
+      </transition>
+    </initial>
+    <onentry>
+      <script>self.x=Math.sqrt(self.x);
+				self.y=Math.sqrt(self.y);</script>
+      <log expr="self.x" label="x"/>
+      <log expr="self.y" label="y"/>
+    </onentry>
+    <history id="ShallowHistory" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true"
type="shallow">
+      <transition ns0:exitsParallelRegion="true" target="Basic1">
+        <targets xmlns="http://msdl.cs.mcgill.ca/">
+          <target>
+            <targetState>Basic1</targetState>
+            <enterpath>
+              <state>Basic1</state>
+            </enterpath>
+          </target>
+        </targets>
+        <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+          <state>ShallowHistory</state>
+        </exitpath>
+        <lca xmlns="http://msdl.cs.mcgill.ca/">Compound1</lca>
+      </transition>
+    </history>
+    <state id="Basic1" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true">
+      <transition event="t1" ns0:exitsParallelRegion="true" target="Basic2">
+        <script>self.x++;</script>
+        <log expr="self.x" label="x"/>
+        <log expr="self.y" label="y"/>
+        <targets xmlns="http://msdl.cs.mcgill.ca/">
+          <target>
+            <targetState>Basic2</targetState>
+            <enterpath>
+              <state>Basic2</state>
+            </enterpath>
+          </target>
+        </targets>
+        <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+          <state>Basic1</state>
+        </exitpath>
+        <lca xmlns="http://msdl.cs.mcgill.ca/">Compound1</lca>
+      </transition>
+    </state>
+    <state id="Basic2" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true">
+      <transition event="t5" ns0:exitsParallelRegion="true" target="Basic1">
+        <targets xmlns="http://msdl.cs.mcgill.ca/">
+          <target>
+            <targetState>Basic1</targetState>
+            <enterpath>
+              <state>Basic1</state>
+            </enterpath>
+          </target>
+        </targets>
+        <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+          <state>Basic2</state>
+        </exitpath>
+        <lca xmlns="http://msdl.cs.mcgill.ca/">Compound1</lca>
+      </transition>
+      <transition event="t2_7" ns0:exitsParallelRegion="true" target="Parallel1">
+        <targets xmlns="http://msdl.cs.mcgill.ca/">
+          <target>
+            <targetState>Parallel1_Initial2</targetState>
+            <enterpath>
+              <state>Parallel1</state>
+              <state>Parallel1_Initial2</state>
+            </enterpath>
+          </target>
+        </targets>
+        <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+          <state>Basic2</state>
+          <state>Compound1</state>
+        </exitpath>
+        <lca xmlns="http://msdl.cs.mcgill.ca/">Root</lca>
+      </transition>
+    </state>
+    <state id="Basic3" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true">
+      <onentry>
+        <send delay="1" event="t_after"/>
+      </onentry>
+      <transition event="t_after" ns0:exitsParallelRegion="true" target="FinalState">
+        <targets xmlns="http://msdl.cs.mcgill.ca/">
+          <target>
+            <targetState>FinalState</targetState>
+            <enterpath>
+              <state>FinalState</state>
+            </enterpath>
+          </target>
+        </targets>
+        <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+          <state>Basic3</state>
+          <state>Compound1</state>
+        </exitpath>
+        <lca xmlns="http://msdl.cs.mcgill.ca/">Root</lca>
+      </transition>
+    </state>
+    <transition event="t2_7" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:exitsParallelRegion="true"
target="DeepHistory">
+      <targets xmlns="http://msdl.cs.mcgill.ca/">
+        <target>
+          <targetState>DeepHistory</targetState>
+          <enterpath>
+            <state>Parallel1</state>
+            <state>DeepHistory</state>
+          </enterpath>
+        </target>
+      </targets>
+      <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+        <state>Compound1</state>
+      </exitpath>
+      <lca xmlns="http://msdl.cs.mcgill.ca/">Root</lca>
+    </transition>
+  </state>
+  <final id="FinalState" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true"/>
+  <parallel id="Parallel1">
+    <onentry>
+      <script>self.x*=3;</script>
+      <log expr="self.x" label="x"/>
+      <log expr="self.y" label="y"/>
+    </onentry>
+    <onexit>
+      <script>self.y=Math.pow(self.y,2);</script>
+      <log expr="self.x" label="x"/>
+      <log expr="self.y" label="y"/>
+    </onexit>
+    <initial id="Parallel1_Initial2" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true">
+      <transition ns0:exitsParallelRegion="true" target="DeepHistory">
+        <targets xmlns="http://msdl.cs.mcgill.ca/">
+          <target>
+            <targetState>DeepHistory</targetState>
+            <enterpath>
+              <state>DeepHistory</state>
+            </enterpath>
+          </target>
+        </targets>
+        <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+          <state>Parallel1_Initial2</state>
+        </exitpath>
+        <lca xmlns="http://msdl.cs.mcgill.ca/">Parallel1</lca>
+      </transition>
+    </initial>
+    <history id="DeepHistory" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true"
type="deep">
+      <transition ns0:exitsParallelRegion="true" target="ParallelRegion1 ParallelRegion2">
+        <targets xmlns="http://msdl.cs.mcgill.ca/">
+          <target>
+            <targetState>ParallelRegion1_Initial3</targetState>
+            <enterpath>
+              <state>ParallelRegion1</state>
+              <state>ParallelRegion1_Initial3</state>
+            </enterpath>
+          </target>
+          <target>
+            <targetState>ParallelRegion2_Initial4</targetState>
+            <enterpath>
+              <state>ParallelRegion2</state>
+              <state>ParallelRegion2_Initial4</state>
+            </enterpath>
+          </target>
+        </targets>
+        <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+          <state>DeepHistory</state>
+        </exitpath>
+        <lca xmlns="http://msdl.cs.mcgill.ca/">Parallel1</lca>
+      </transition>
+    </history>
+    <state id="ParallelRegion1">
+      <onentry>
+        <script>self.x = Math.pow(self.x,2);</script>
+        <log expr="self.x" label="x"/>
+        <log expr="self.y" label="y"/>
+      </onentry>
+      <state id="Basic4" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true" xmlns:ns1="http://msdl.cs.mcgill.ca/"
ns1:isParallelSubstate="true">
+        <transition event="t3" target="Basic5">
+          <send event="tgen"/>
+          <targets xmlns="http://msdl.cs.mcgill.ca/">
+            <target>
+              <targetState>Basic5</targetState>
+              <enterpath>
+                <state>Basic5</state>
+              </enterpath>
+            </target>
+          </targets>
+          <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+            <state>Basic4</state>
+          </exitpath>
+          <lca xmlns="http://msdl.cs.mcgill.ca/">ParallelRegion1</lca>
+        </transition>
+      </state>
+      <state id="Basic5" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true" xmlns:ns1="http://msdl.cs.mcgill.ca/"
ns1:isParallelSubstate="true">
+        <transition event="t8" target="Basic4">
+          <targets xmlns="http://msdl.cs.mcgill.ca/">
+            <target>
+              <targetState>Basic4</targetState>
+              <enterpath>
+                <state>Basic4</state>
+              </enterpath>
+            </target>
+          </targets>
+          <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+            <state>Basic5</state>
+          </exitpath>
+          <lca xmlns="http://msdl.cs.mcgill.ca/">ParallelRegion1</lca>
+        </transition>
+        <transition event="t4_9" ns0:exitsParallelRegion="true" ns1:isPreempted="true"
target="Compound1">
+          <targets xmlns="http://msdl.cs.mcgill.ca/">
+            <target>
+              <targetState>Compound1_Initial1</targetState>
+              <enterpath>
+                <state>Compound1</state>
+                <state>Compound1_Initial1</state>
+              </enterpath>
+            </target>
+          </targets>
+          <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+            <state>Basic5</state>
+            <state>ParallelRegion1</state>
+            <state>Parallel1</state>
+          </exitpath>
+          <lca xmlns="http://msdl.cs.mcgill.ca/">Root</lca>
+        </transition>
+      </state>
+      <initial id="ParallelRegion1_Initial3" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true"
xmlns:ns1="http://msdl.cs.mcgill.ca/" ns1:isParallelSubstate="true">
+        <transition target="Basic4">
+          <targets xmlns="http://msdl.cs.mcgill.ca/">
+            <target>
+              <targetState>Basic4</targetState>
+              <enterpath>
+                <state>Basic4</state>
+              </enterpath>
+            </target>
+          </targets>
+          <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+            <state>ParallelRegion1_Initial3</state>
+          </exitpath>
+          <lca xmlns="http://msdl.cs.mcgill.ca/">ParallelRegion1</lca>
+        </transition>
+      </initial>
+    </state>
+    <state id="ParallelRegion2">
+      <onexit>
+        <script>self.y *= 3;</script>
+        <log expr="self.x" label="x"/>
+        <log expr="self.y" label="y"/>
+      </onexit>
+      <state id="Basic6" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true" xmlns:ns1="http://msdl.cs.mcgill.ca/"
ns1:isParallelSubstate="true">
+        <transition event="tgen" target="Basic7">
+          <if cond="self.x==9">
+            <script>self.y++;</script>
+            <log label="if statement succeeded"/>
+            <executableContent xmlns="http://msdl.cs.mcgill.ca/">
+              
+              <script xmlns="http://www.w3.org/2005/07/scxml">self.y++;</script>
+              <log label="if statement succeeded" xmlns="http://www.w3.org/2005/07/scxml"/>
+            </executableContent>
+          </if>
+          <log expr="self.x" label="x"/>
+          <log expr="self.y" label="y"/>
+          <targets xmlns="http://msdl.cs.mcgill.ca/">
+            <target>
+              <targetState>Basic7</targetState>
+              <enterpath>
+                <state>Basic7</state>
+              </enterpath>
+            </target>
+          </targets>
+          <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+            <state>Basic6</state>
+          </exitpath>
+          <lca xmlns="http://msdl.cs.mcgill.ca/">ParallelRegion2</lca>
+        </transition>
+      </state>
+      <state id="Basic7" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true" xmlns:ns1="http://msdl.cs.mcgill.ca/"
ns1:isParallelSubstate="true"/>
+      <initial id="ParallelRegion2_Initial4" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:isBasic="true"
xmlns:ns1="http://msdl.cs.mcgill.ca/" ns1:isParallelSubstate="true">
+        <transition target="Basic6">
+          <targets xmlns="http://msdl.cs.mcgill.ca/">
+            <target>
+              <targetState>Basic6</targetState>
+              <enterpath>
+                <state>Basic6</state>
+              </enterpath>
+            </target>
+          </targets>
+          <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+            <state>ParallelRegion2_Initial4</state>
+          </exitpath>
+          <lca xmlns="http://msdl.cs.mcgill.ca/">ParallelRegion2</lca>
+        </transition>
+      </initial>
+    </state>
+    <transition event="t4_9" xmlns:ns0="http://msdl.cs.mcgill.ca/" ns0:exitsParallelRegion="true"
xmlns:ns1="http://msdl.cs.mcgill.ca/" ns1:isPreempted="true" target="Basic3">
+      <targets xmlns="http://msdl.cs.mcgill.ca/">
+        <target>
+          <targetState>Basic3</targetState>
+          <enterpath>
+            <state>Compound1</state>
+            <state>Basic3</state>
+          </enterpath>
+        </target>
+      </targets>
+      <exitpath xmlns="http://msdl.cs.mcgill.ca/">
+        <state>Parallel1</state>
+      </exitpath>
+      <lca xmlns="http://msdl.cs.mcgill.ca/">Root</lca>
+    </transition>
+  </parallel>
+</scxml>

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/KitchenSink_executableContent_IR.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html?rev=954069&r1=954068&r2=954069&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/testBrowserTransform.html Sat Jun 12 19:36:19
2010
@@ -1,12 +1,13 @@
 <html>
 <head>
+	<script djConfig="isDebug:true" src="../lib/test-js/dojo-release-1.4.2-src/dojo/dojo.js"
type="text/javascript">true;</script>
+	<script src="testHelpers.js" type="text/javascript">true;</script>
+	<script src="kitchen_sink/scripts/unitTest_executableContent.js" type="text/javascript">true;</script>
 	<script>
 		function doXHR(url, callback) {
 			var xhr = new XMLHttpRequest();
-			xhr.open('GET', url, true);
+			xhr.open('GET', url, true);	//synchronous
 			xhr.onreadystatechange = function (evt) {
-				//Do not explicitly handle errors, those should be
-				//visible via console output in the browser.
 				if (xhr.readyState === 4) {
 					callback(xhr.responseXML);
 				}
@@ -15,19 +16,24 @@
 		};
 
 		//load xml
+		var resultText;
+
 		doXHR( "http://localhost:8081/test/xslt/StatePatternStatechartGenerator.xsl", function(statePatternStatechartGeneratorXSL){
-			doXHR( "http://localhost:8081/test/kitchen_sink/KitchenSink.xml", function(kitchenSinkXML){
+			doXHR( "http://localhost:8081/test/KitchenSink_executableContent_IR.xml", function(kitchenSinkXML){
 				//transform to js
 				var processor = new XSLTProcessor();  
 				processor.importStylesheet(statePatternStatechartGeneratorXSL); 
 
 				var newDocument = processor.transformToDocument(kitchenSinkXML);  
 
-				var resultText = newDocument.documentElement.firstChild.textContent;
+				resultText = newDocument.documentElement.firstChild.textContent;
 				console.log(resultText);
 				
 				//eval
 				eval(resultText);
+				window.StatechartExecutionContext = StatechartExecutionContext;
+				dojo.require("doh.runner"); 
+				doh.run();
 			});
 		});
 	</script>



Mime
View raw message