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/28 01:00:30 UTC

svn commit: r958434 - in /commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink: KitchenSink_dataModule.xml scripts/unitTest_dataModel.js

Author: jbeard
Date: Sun Jun 27 23:00:30 2010
New Revision: 958434

URL: http://svn.apache.org/viewvc?rev=958434&view=rev
Log:
Created new unit tests for testing parts of the data module.

Added:
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml
      - copied, changed from r958433, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_executableContent.xml
    commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js   (with props)

Copied: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml (from r958433, commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_executableContent.xml)
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml?p2=commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml&p1=commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_executableContent.xml&r1=958433&r2=958434&rev=958434&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_executableContent.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/KitchenSink_dataModule.xml Sun Jun 27 23:00:30 2010
@@ -21,12 +21,13 @@
 	 * limitations under the License.
 	-->
 
-	<script>
-		self.x=0;
-		self.y=0;
-	</script>
-	<log label="x" expr="self.x"/>
-	<log label="y" expr="self.y"/>
+	<datamodel>
+		<data name="x" expr="0"/>
+		<data name="y" expr="0"/>
+	</datamodel>
+
+	<log label="x" expr="x"/>
+	<log label="y" expr="y"/>
 
 	<!-- its initial state is Test1 -->
 	<initial>
@@ -40,12 +41,10 @@
 		</initial>
 
 		<onentry>
-			<script>
-				self.x=Math.sqrt(self.x);
-				self.y=Math.sqrt(self.y);
-			</script>
-			<log label="x" expr="self.x"/>
-			<log label="y" expr="self.y"/>
+			<assign location="x" expr="Math.sqrt(x)"/>
+			<assign location="y" expr="Math.sqrt(y)"/>
+			<log label="x" expr="x"/>
+			<log label="y" expr="y"/>
 		</onentry>
 
 		<history id="ShallowHistory" type="shallow">
@@ -53,47 +52,38 @@
 		</history>
 
 		<state id="Basic1">
-			<transition event="t1" target="Basic2"> 
-				<script>
-					self.x++;
-				</script>
-				<log label="x" expr="self.x"/>
-				<log label="y" expr="self.y"/>
+			<transition event="t1" target="Basic2" cond="x==0 && y==0"> 
+				<assign location="x" expr="x+1"/>
+				<log label="x" expr="x"/>
+				<log label="y" expr="y"/>
 			</transition>
 		</state>
 
 		<state id="Basic2">
-			<transition event="t5" target="Basic1"/> 
-			<transition event="t2_7" target="Parallel1"/> 
+			<transition event="t5" target="Basic1" cond="x==3 && y==3"/> 
+			<transition event="t2_7" target="Parallel1" cond="x==1 && y==0"/> 
 		</state>
 
 		<state id="Basic3">
-			<onentry>
-				<send event="t_after" delay="1"/>
-			</onentry>
-			<transition event="t_after" target="FinalState"/>
+			<transition event="t10" target="FinalState" cond="x==9 && y==9"/>
 		</state>
 
-		<transition event="t2_7" target="DeepHistory"/> 
+		<transition event="t2_7" target="DeepHistory" cond="x==81 && y==3"/> 
 	</state>
 
 	<final id="FinalState"/>
 
 	<parallel id="Parallel1">
 		<onentry>
-			<script>
-				self.x*=3;
-			</script>
-			<log label="x" expr="self.x"/>
-			<log label="y" expr="self.y"/>
+			<assign location="x" expr="x*3"/>
+			<log label="x" expr="x"/>
+			<log label="y" expr="y"/>
 		</onentry>
 
 		<onexit>
-			<script>
-				self.y=Math.pow(self.y,2);
-			</script>
-			<log label="x" expr="self.x"/>
-			<log label="y" expr="self.y"/>
+			<assign location="y" expr="Math.pow(y,2)"/>
+			<log label="x" expr="x"/>
+			<log label="y" expr="y"/>
 		</onexit>
 
 		<initial>
@@ -107,22 +97,20 @@
 		<state id="ParallelRegion1" initial="Basic4">
 
 			<onentry>
-				<script>
-					self.x = Math.pow(self.x,2);
-				</script>
-				<log label="x" expr="self.x"/>
-				<log label="y" expr="self.y"/>
+				<assign location="x" expr="Math.pow(x,2)"/>
+				<log label="x" expr="x"/>
+				<log label="y" expr="y"/>
 			</onentry>
 
 			<state id="Basic4">
-				<transition event="t3" target="Basic5">
+				<transition event="t3" target="Basic5" cond="x==9 && y==0">
 					<send event="tgen"/>
 				</transition>
 			</state>
 
 			<state id="Basic5">
 				<transition event="t8" target="Basic4"/>
-				<transition event="t4_9" target="Compound1"/>
+				<transition event="t4_9" target="Compound1" cond="x==9 && y==1"/>
 			</state>
 
 		</state>
@@ -130,23 +118,19 @@
 		<state id="ParallelRegion2" initial="Basic6">
 			
 			<onexit>
-				<script>
-					self.y *= 3;
-				</script>
-				<log label="x" expr="self.x"/>
-				<log label="y" expr="self.y"/>
+				<assign location="y" expr="y*3"/>
+				<log label="x" expr="x"/>
+				<log label="y" expr="y"/>
 			</onexit>
 
 			<state id="Basic6">
 				<transition event="tgen" target="Basic7">
-					<if cond="self.x==9">
-						<script>
-							self.y++;
-						</script>
+					<if cond="x==9">
+						<assign location="y" expr="y+1"/>
 						<log label="if statement succeeded"/>
 					</if>
-					<log label="x" expr="self.x"/>
-					<log label="y" expr="self.y"/>
+					<log label="x" expr="x"/>
+					<log label="y" expr="y"/>
 				</transition>
 			</state>
 

Added: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js?rev=958434&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js Sun Jun 27 23:00:30 2010
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+require.def( "test/kitchen_sink/scripts/unitTest_dataModel",
+{
+	scxmlTest:"test/kitchen_sink/KitchenSink_dataModel.xml",
+
+	register:function(scConstructor){
+
+		//TODO: can load this using RequireJS, so we don't need to use the dojo module system?
+		dojo.require("doh.runner");
+
+		var sc;
+		doh.register("testKitchenSinkSuite",[
+				{
+					name:"testAll",
+					//timeout:5000,
+					setUp:function(){
+						sc = new scConstructor()
+						sc.initialize();
+					},
+					runTest:function(){
+						var conf0 = sc.getCurrentConfiguration();
+						console.log(conf0);
+						doh.assertTrue(setwiseEqual(conf0,[sc._states.Basic1]));
+
+						console.info("sending event t1")
+						sc.t1()
+						var conf1 = sc.getCurrentConfiguration();
+						console.log(conf1);
+						doh.assertTrue(setwiseEqual(conf1,[sc._states.Basic2]));
+
+						console.info("sending event t2_7")
+						sc.t2_7()
+						var conf2 = sc.getCurrentConfiguration();
+						console.log(conf2);
+						doh.assertTrue(setwiseEqual(conf2,[sc._states.Basic4,sc._states.Basic6]));
+
+						console.info("sending event t3")
+						sc.t3()
+						var conf3 = sc.getCurrentConfiguration();
+						console.log(conf3);
+						doh.assertTrue(setwiseEqual(conf3,[sc._states.Basic5,sc._states.Basic7]));
+
+						console.info("sending event t4_9")
+						sc.t4_9()
+						var conf4 = sc.getCurrentConfiguration();
+						console.log(conf4);
+						doh.assertTrue(setwiseEqual(conf4,[sc._states.Basic2]));
+
+						console.info("sending event t5")
+						sc.t5()
+						var conf5 = sc.getCurrentConfiguration();
+						console.log(conf5);
+						doh.assertTrue(setwiseEqual(conf5,[sc._states.Basic1]));
+
+						console.info("sending event t2_7")
+						sc.t2_7()
+						var conf6 = sc.getCurrentConfiguration();
+						console.log(conf6);
+						doh.assertTrue(setwiseEqual(conf6,[sc._states.Basic5,sc._states.Basic7]));
+
+						console.info("sending event t8")
+						sc.t8()
+						var conf7 = sc.getCurrentConfiguration();
+						console.log(conf7);
+						doh.assertTrue(setwiseEqual(conf7,[sc._states.Basic4,sc._states.Basic7]));
+
+						console.info("sending event t4_9")
+						sc.t4_9()
+						var conf8 = sc.getCurrentConfiguration();
+						console.log(conf8);
+						doh.assertTrue(setwiseEqual(conf8,[sc._states.Basic3]));
+
+						console.info("sending event t10")
+						sc.t10()
+						var conf9 = sc.getCurrentConfiguration();
+						console.log(conf9);
+						doh.assertTrue(setwiseEqual(conf9,[sc._states.FinalState]));
+
+						//TODO: hook this up with doh.Deferred...
+						/*
+						var deferred = new doh.Deferred();
+						window.setTimeout(function(){
+							var conf9 = sc.getCurrentConfiguration();
+							console.log(conf9);
+							deferred.callback(setwiseEqual(conf9,[sc._states.FinalState]));
+						},1500);
+						return deferred;
+						*/
+					},
+					tearDown:function(){
+						 sc.destroy();
+					}
+				}
+		]);
+	}
+});
+
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/branches/SCXML-141-148/test/kitchen_sink/scripts/unitTest_dataModel.js
------------------------------------------------------------------------------
    svn:eol-style = native