You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jb...@apache.org on 2010/06/25 13:40:53 UTC

svn commit: r957895 - in /commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137: build.js test/conditional_transition/TestConditionalTransition.xml test/conditional_transition/scripts/ test/conditional_transition/scripts/unitTest.js

Author: jbeard
Date: Fri Jun 25 11:40:53 2010
New Revision: 957895

URL: http://svn.apache.org/viewvc?rev=957895&view=rev
Log:
Added additional comments to conditional transition test xml, checked in unit test, and modified build.js to include the new test, as well as temporarily to not run the old tests.

Added:
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js   (with props)
Modified:
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/TestConditionalTransition.xml

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js?rev=957895&r1=957894&r2=957895&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js Fri Jun 25 11:40:53 2010
@@ -73,9 +73,12 @@ require.def("build",
 
 			//paths to all of the SCXML files we want to compile
 			var scxmlTests = {
+/*
 				KitchenSink :"test/kitchen_sink/KitchenSink.xml",
 				KitchenSink_performance :"test/kitchen_sink/KitchenSink_performance.xml",
-				KitchenSink_executableContent :"test/kitchen_sink/KitchenSink_executableContent.xml"
+				KitchenSink_executableContent :"test/kitchen_sink/KitchenSink_executableContent.xml",
+*/
+				ConditionalTransition :"test/conditional_transition/TestConditionalTransition.xml"
 			}
 
 			//FIXME: this violates Don't Repeat Yourself; these paths are written here and in the module
@@ -104,6 +107,7 @@ require.def("build",
 
 
 			var unitTestScripts = [
+/*
 				{ 
 					path : "test/kitchen_sink/scripts/unitTest.js",
 					scxmlTest : scxmlTests.KitchenSink		//back-link
@@ -111,8 +115,12 @@ require.def("build",
 				{ 
 					path : "test/kitchen_sink/scripts/unitTest_executableContent.js",
 					scxmlTest : scxmlTests.KitchenSink_executableContent		//back-link
-				}
-				
+				},
+*/
+				{ 
+					path : "test/conditional_transition/scripts/unitTest.js",
+					scxmlTest : scxmlTests.ConditionalTransition 		//back-link
+				}				
 			]
 
 			//gets populated at run-time

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/TestConditionalTransition.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/TestConditionalTransition.xml?rev=957895&r1=957894&r2=957895&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/TestConditionalTransition.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/TestConditionalTransition.xml Fri Jun 25 11:40:53 2010
@@ -15,6 +15,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
 -->
+<!-- 
+This is to test transitions with guard conditions, and multiple
+transitions originating from the same state. 
+-->
 <scxml 
 	xmlns="http://www.w3.org/2005/07/scxml"
 	version="1.0"
@@ -24,19 +28,23 @@
 		<transition target="a"/>
 	</initial>
 
+	<!-- default transition -->
 	<state id="a">
 		<transition target="b"/>
 	</state>
 
+	<!-- regular transition -->
 	<state id="b">
 		<transition target="c" event="t1"/>
 	</state>
 
+	<!-- two default transitions, first should get priority (based on document order), end in d1 -->
 	<state id="c">
 		<transition target="d1"/>
 		<transition target="d2"/>
 	</state>
 
+	<!-- two regular transitions, first should get priority, end in e1 -->
 	<state id="d1">
 		<transition target="e1" event="t2"/>
 		<transition target="e2" event="t2"/>
@@ -44,6 +52,9 @@
 
 	<state id="d2"/>
 
+	<!-- two transitions with guard conditions; 
+		first has priority, but will fail, so second transition should be taken,
+		end in f2 -->
 	<state id="e1">
 		<transition target="f1" event="t3" cond="false"/>
 		<transition target="f2" event="t3" cond="true"/>
@@ -53,6 +64,7 @@
 
 	<state id="f1"/>
 
+	<!-- like above, but with three transitions -->
 	<state id="f2">
 		<transition target="g1" event="t4" cond="false"/>
 		<transition target="g2" event="t4" cond="false"/>

Added: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js?rev=957895&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js Fri Jun 25 11:40:53 2010
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+
+dojo.require("doh.runner");
+
+//we assume statechart is imported here. should probably do registermodulepath instead
+
+(function(){
+	var sc;
+	doh.register("testConditionalTransitionSuite",[
+			{
+				name:"testAll",
+				//timeout:5000,
+				setUp:function(){
+					sc = new StatechartExecutionContext()
+					sc.initialize();
+				},
+				runTest:function(){
+					var $ = function(conf){return conf.map(function(s){return s.toString()})};
+
+					var conf0 = sc.getCurrentConfiguration();
+					console.log($(conf0));
+					doh.assertTrue(setwiseEqual(conf0,[sc._states.b]));
+
+					//should enter into c and take first default transition to d1
+					console.info("sending event t1")
+					sc.t1()
+					var conf1 = sc.getCurrentConfiguration();
+					console.log($(conf1));
+					doh.assertTrue(setwiseEqual(conf1,[sc._states.d1]));
+
+
+					console.info("sending event t2")
+					sc.t2()
+					var conf2 = sc.getCurrentConfiguration();
+					console.log($(conf2));
+					doh.assertTrue(setwiseEqual(conf2,[sc._states.e1]));
+
+
+					console.info("sending event t3")
+					sc.t3()
+					var conf3 = sc.getCurrentConfiguration();
+					console.log($(conf3));
+					doh.assertTrue(setwiseEqual(conf3,[sc._states.f2]));
+
+					console.info("sending event t4")
+					sc.t4()
+					var conf4 = sc.getCurrentConfiguration();
+					console.log($(conf4));
+					doh.assertTrue(setwiseEqual(conf4,[sc._states.h]));
+
+					console.info("sending event t5")
+					sc.t5()
+					var conf5 = sc.getCurrentConfiguration();
+					console.log($(conf5));
+					doh.assertTrue(setwiseEqual(conf5,[sc._states.i]));
+
+					console.info("sending event t5")
+					sc.t5()
+					var conf6 = sc.getCurrentConfiguration();
+					console.log($(conf6));
+					doh.assertTrue(setwiseEqual(conf6,[sc._states.final]));
+				},
+				tearDown:function(){
+					 sc.destroy();
+				}
+			}
+	]);
+})()
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/test/conditional_transition/scripts/unitTest.js
------------------------------------------------------------------------------
    svn:eol-style = native