Giter VIP home page Giter VIP logo

scion's Introduction

Overview

Backers on Open Collective Sponsors on Open Collective

SCION is an industrial-strength implementation of W3C SCXML in JavaScript.

SCXML provides a declarative markup for Statecharts, a powerful modelling language for developing complex, timed, event-driven, state-based systems.

Installation

node.js

npm install scxml

browser

Script tag with cdnjs

Add the following script tags to your HTML:

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.min.js">
<script src="https://cdnjs.cloudflare.com/ajax/libs/scion/4.3.1/scxml.min.js">

Then SCION API available as global singleton object scxml.

npm and browserify

Install babel-polyfill and scxml with npm:

npm install --save scxml babel-polyfill

Then add to your application entry point:

require('babel-polyfill');
let scxml = require('scxml');

Quickstart

scxml.urlToModel("drag-and-drop.xml",function(err,model){

  if(err) throw err;

  model.prepare(function(err, fnModel) {

    if(err) throw err;

    //instantiate the interpreter
    var sc = new scxml.scion.Statechart(fnModel);

    //start the interpreter
    sc.start();

    //send the init event
    sc.gen({name:"init",data:rect});

  });
})

API

See the API docs here.

Backwards-compatibility with [email protected]

See the note here.

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! ๐Ÿ™ [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

Support

To report a bug: file an issue on GitHub.

For general questions: Join the chat at https://gitter.im/SCION-SCXML/Lobby

Build Status

Build status

scion's People

Contributors

feyzo avatar jbeard4 avatar mogsie avatar monkeywithacupcake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scion's Issues

fail test/w3c-ecma/test504.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test504.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1441,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that an external transition exits all states up the the LCCA -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s1" version="1.0" datamodel="ecmascript">
<datamodel>
  <data id="Var1" expr="0"/>  <!-- how often we have exited p -->
  <data id="Var2" expr="0"/>  <!-- how often we have exited ps1 -->
  <data id="Var3" expr="0"/>  <!-- how often we have exited ps2 -->
  <data id="Var4" expr="0"/>  <!-- how often the transition for foo has been taken -->
  <data id="Var5" expr="0"/>  <!-- how often we have exited s2  -->
  </datamodel>

 <state id="s1">
   <onentry>
    <raise event="foo"/>
    <raise event="bar"/>
    </onentry>
   <transition target="p"/>
   </state>

<state id="s2">
     <onexit>
        <assign location="Var5" expr="Var5 + 1"/>
        </onexit>

<parallel id="p">
  <onexit>
    <assign location="Var1" expr="Var1 + 1"/>
    </onexit>
  <transition event="foo" target="ps1">
     <assign location="Var4" expr="Var4 + 1"/>
     </transition>

   <!-- make sure the transition on foo was actually taken --> 
  <transition event="bar" cond="Var4==1" target="s3"/>
  <transition event="bar" target="fail"/>

 <state id="ps1">
   <onexit>
   <assign location="Var2" expr="Var2 + 1"/>
   </onexit>
  </state>
  <state id="ps2">
   <onexit>
   <assign location="Var3" expr="Var3 + 1"/>
   </onexit>
  </state>
</parallel>
</state>

<state id="s3">
  <!-- make sure that p was exited twice -->
    <transition cond="Var1==2" target="s4"/>
    <transition target="fail"/>
 </state> 

<state id="s4">
  <!-- make sure that ps1 was exited twice -->
    <transition cond="Var2==2" target="s5"/>
    <transition target="fail"/>
 </state> 

<state id="s5">
  <!-- make sure that ps2 was exited twice -->
    <transition cond="Var3==2" target="s6"/>
    <transition target="fail"/>
 </state>

<state id="s6">
    <!-- make sure that s1 was exited once -->
    <transition cond="Var5==1" target="pass"/>
    <transition target="fail"/>
    </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

Bubble up external script fetch failures

Hi, Jacob,

In our scenarios, a failure to fetch an externally referenced script is considered fatal. We'd like to handle this at fetch failure time rather than when the FSM attempts to execute something from the missing .js.

Would you be willing to modify SCION behavior in docToModel.js:31 to instead invoke the callback with the error(s) rather than drop it/them on the floor?

error test/w3c-ecma/test576.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test576.txml.scxml

Error

null

Data:
"Unable to locate initial state for composite state: undefined"

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that the 'initial' value of scxml is respected.  We set the value to deeply nested non-default parallel siblings and
test that both are entered. -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s11p112 s11p122" datamodel="ecmascript" version="1.0">


<state id="s0">
  <transition target="fail"/>
</state>

<state id="s1">
  <onentry>
    <send event="timeout" delay="1s"/>
    </onentry>
  <transition event="timeout" target="fail"/>
  <state id="s11" initial="s111">
    <state id="s111"/>
    <parallel id="s11p1">
       <state id="s11p11" initial="s11p111">
         <state id="s11p111"/>
         <state id="s11p112">
           <onentry>
             <raise event="In-s11p112"/>
             </onentry>
         </state>
       </state>
       <state id="s11p12" initial="s11p121">
        <state id="s11p121"/>
        <state id="s11p122">
          <transition event="In-s11p112" target="pass"/>
          </state>
       </state>
      </parallel>
  </state>
</state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test533.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test533.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1432,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that an internal transition whose source state is not compound does  exit its source state -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s1" version="1.0" datamodel="ecmascript">
<datamodel>
  <data id="Var1" expr="0"/>  <!-- how often we have exited p -->
  <data id="Var2" expr="0"/>  <!-- how often we have exited ps1 -->
  <data id="Var3" expr="0"/>  <!-- how often we have exited ps2 -->
  <data id="Var4" expr="0"/>  <!-- how often the transition for foo has been taken -->
  </datamodel>

 <state id="s1">
   <onentry>
    <raise event="foo"/>
    <raise event="bar"/>
    </onentry>
   <transition target="p"/>
   </state>

<parallel id="p">
  <onexit>
    <assign location="Var1" expr="Var1 + 1"/>
    </onexit>
  <transition event="foo" type="internal" target="ps1">
     <assign location="Var4" expr="Var4 + 1"/>
     </transition>

   <!-- make sure the transition on foo was actually taken --> 
  <transition event="bar" cond="Var4==1" target="s2"/>
  <transition event="bar" target="fail"/>

 <state id="ps1">
   <onexit>
   <assign location="Var2" expr="Var2 + 1"/>
   </onexit>
  </state>
  <state id="ps2">
   <onexit>
   <assign location="Var3" expr="Var3 + 1"/>
   </onexit>
  </state>
</parallel>

<state id="s2">
  <!-- make sure that p was exited twice -->
    <transition cond="Var1==2" target="s3"/>
    <transition target="fail"/>
 </state> 

<state id="s3">
  <!-- make sure that ps1 was exited twice -->
    <transition cond="Var2==2" target="s4"/>
    <transition target="fail"/>
 </state> 

<state id="s4">
  <!-- make sure that ps2 was exited twice -->
    <transition cond="Var3==2" target="pass"/>
    <transition target="fail"/>
 </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test562.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test562.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s0"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s0"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1424,
"nextConfiguration": [
"s0"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- in the ECMA data model, test that processor creates space normalized string in
 _event.data when receiving anything other than KVPs or XML in an event -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">


<state id="s0">
   <onentry>
    <send event="foo">
    <content>
this is  a  
string
</content>
    </send>
  </onentry>
  <transition event="foo" cond="_event.data == 'this is a string'" target="pass"/>
  <transition event="*" target="fail"/>
  </state>


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>  

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test530.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test530.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"$generated-final-0"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["$generated-final-0"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1433,
"nextConfiguration": [
"$generated-final-0"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that <content> child is evaluated when <invoke> is. Var1 is initialized
with an integer value, then set to an scxml script in the onentry to s0.  If <content>
is evaluated at the right time, we should get invoke.done, otherwise an error  -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">
  <datamodel>
    <data id="Var1" expr="1"/>
    </datamodel>

    <state id="s0">
      <onentry>
        <assign location="Var1">
           <scxml version="1.0"><final/></scxml>
           </assign>
        <send event="timeout" delay="2s"/>
        </onentry>

      <invoke type="http://www.w3.org/TR/scxml/">
        <content expr="Var1"/>
        </invoke>

        <transition event="done.invoke" target="pass"/>
        <transition event="*" target="fail"/>
    </state>

    <final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
    <final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
  </scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test422.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test422.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"subFinal2"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["subFinal2"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1453,
"nextConfiguration": [
"subFinal2"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Test that at the end of a macrostep, the processor executes all invokes in states
that have been entered and not exited during the step.  (The invokes are supposed to be executed
in document order, but we can test that since each invocation is separate and they may take
different amounts to time to start up.)  In this case, there are three invoke statements,
in states s1, s11 and s12.  Each invoked process returns an event named after its parent state.
The invokes in s1 and s12 should execute, but not the one
in s11. So we should receive invokeS1, invokeS12, but not invokeS12.  Furthermore, when the timeout fires, var1 should equal 2.-->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" initial="s1" datamodel="ecmascript">
<datamodel>
     <data id="Var1" expr="0"/>
    </datamodel>
 <state id="s1" initial="s11">
     <onentry>
        <send event="timeout" delay="5s"/>
        </onentry>
       <transition event="invokeS1 invokeS12">
        <assign location="Var1" expr="Var1 + 1"/>
        </transition>
        <transition event="invokeS11" target="fail"/>

      <transition event="timeout" cond="Var1==2" target="pass"/>
      <transition event="timeout" target="fail"/>
     <invoke>
          <content>
        <!-- when invoked, send 'foo' to parent, then terminate.   -->
          <scxml initial="sub0" version="1.0" datamodel="ecmascript">
            <state id="sub0">
                 <onentry>
                <send target="#_parent" event="invokeS1"/>
               </onentry>
                <transition target="subFinal0"/>
              </state>
           <final id="subFinal0"/>
        </scxml>
      </content>
         </invoke>

   <state id="s11">
    <invoke>
                  <content>
        <!-- when invoked, send 'foo' to parent, then terminate.   -->
          <scxml initial="sub1" version="1.0" datamodel="ecmascript">
            <state id="sub1">
             <onentry>
                <send target="#_parent" event="invokeS11"/>
               </onentry>
                <transition target="subFinal1"/>
              </state>
           <final id="subFinal1"/>
            </scxml>
      </content>
      </invoke>
      <transition target="s12"/>
    </state>
  <state id="s12">
    <invoke>
     <content>
        <!-- when invoked, send 'foo' to parent, then terminate.   -->
          <scxml initial="sub2" version="1.0" datamodel="ecmascript">
            <state id="sub2">
                 <onentry>
                <send target="#_parent" event="invokeS12"/>
               </onentry>
                <transition target="subFinal2"/>
              </state>
           <final id="subFinal2"/>
            </scxml>
      </content>
        </invoke>
    </state>
 </state>


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test525.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test525.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1437,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that <foreach> does a shallow copy, so that modifying the array does not change
the iteration behavior. -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" datamodel="ecmascript" version="1.0">
  <datamodel>
    <data id="Var1">
      [1,2,3]
      </data>
    <data id="Var2" expr="0"/>  <!-- counts the number of iterations -->
    </datamodel>

<state id="s0">
  <onentry>
  <foreach item="Var3" array="Var1">
    <assign location="Var1" expr="[].concat(Var1, [4])"/>
    <assign location="Var2" expr="Var2 + 1"/>
    </foreach>
   </onentry>

   <transition cond="Var2==3" target="pass"/>
   <transition target="fail"/>
</state>



<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

error test/w3c-ecma/test569.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test569.txml.scxml

Error

null

Data:
"Cannot read property 'scxml' of undefined"

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that location field is found inside entry for SCXML Event I/O processor in the ECMAScript
data model.  The tests for the relevant event i/o processors will test that it can be used to
send events. -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">


<state id="s0">
  <transition cond="_ioprocessors['scxml'].location" target="pass"/>
  <transition target="fail"/>

 </state>

   <final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
   <final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

error test/w3c-ecma/test557.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test557.txml.scxml

Error

null

Data:
"Cannot call method 'getElementsByTagName' of undefined"

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- in the ECMA data model, test that if the child of <data> is XML, or if XML is loaded via src=, the processor
 assigns it as the value of the var -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">
 <datamodel>
   <data id="var1">
   <books xmlns="">
     <book title="title1"/>
     <book title="title2"/>
   </books>  
</data>
 <data id="var2" src="file:test557.txt"/> 
  </datamodel>

<state id="s0">
   <transition cond="var1.getElementsByTagName('book')[0].getAttribute('title') == 'title1'" target="s1"/>
   <transition target="fail"/>
  </state>

<state id="s1">
   <transition cond="var2.getElementsByTagName('book')[1].getAttribute('title') == 'title2'" target="pass"/>
   <transition target="fail"/>
   </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>  

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test419.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test419.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1455,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that eventless transitions take precedence over event-driven ones -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" initial="s1" datamodel="ecmascript">

 <state id="s1">
   <onentry>
     <raise event="internalEvent"/>
     <send event="externalEvent"/>
     </onentry>

   <transition event="*" target="fail"/>
   <transition target="pass"/>

</state> 


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test554.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test554.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"subFinal"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["subFinal"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1428,
"nextConfiguration": [
"subFinal"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that if the evaluation of <invoke>'s args causes an error, the 
invocation is cancelled.  In this test, that means that we don't get done.invoke 
before the timer goes off.  -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">


<state id="s0">
  <onentry>
    <send event="timer" delay="2s"/>
    </onentry>

  <!-- namelist references an undeclared variable -->
   <invoke type="http://www.w3.org/TR/scxml/" namelist="Var2">
      <content>
       <scxml initial="subFinal" version="1.0" datamodel="ecmascript">
             <final id="subFinal"/>
            </scxml>
            </content>
            </invoke>
     <transition event="timer" target="pass"/>
     <transition event="done.invoke" target="fail"/>
   </state>   

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test552.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test552.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1429,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that src content can be used to assign a value to a var. Edit
test552.txt to have a value that's legal for the datamodel in question -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">
  <datamodel>
    <data id="Var1" src="file:test552.txt"/>
    </datamodel>

   <state id="s0">

       <transition cond="Var1" target="pass"/>
       <transition target="fail"/>
   </state>

   <final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
   <final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>



</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test528.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test528.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s02"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s02"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1435,
"nextConfiguration": [
"s02"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!--  test that illegal 'expr' produces error.execution and empty event.data -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" datamodel="ecmascript" initial="s0">


 <state id="s0" initial="s01">
   <!-- we should get the error before the done event -->
   <transition event="error.execution" target="s1"/>
   <transition event="done.state.s0" target="fail"/>     

      <transition event="done.state.s0" target="fail">
     </transition>

   <state id="s01">
   <transition target="s02"/>
   </state>
   <final id="s02">
     <donedata>
      <content expr="return"/>
      </donedata>
     </final>
  </state>


 <!-- if we get here, we received the error event. Now check that the done
 event has empty event.data -->

 <state id="s1">
   <transition event="done.state.s0" cond="_event.data == null" target="pass"/>
   <transition event="*" target="fail"/>
   </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test551.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test551.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1430,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that inline content can be used to assign a value to a var.  -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" binding="early" datamodel="ecmascript">


   <state id="s0">

       <transition cond="Var1" target="pass"/>
       <transition target="fail"/>
   </state>

<state id="s1">
      <datamodel>
    <data id="Var1">
     [1,2,3]
     </data>
    </datamodel>
    </state>

   <final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
   <final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>



</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

Breaks on more-parallel/test3

Probably due to an error In https://github.com/jbeard4/scxml-test-framework/blob/master/test/more-parallel/test3.scxml (e.g. transition to 'a2' is defined on state 'a' and not on state 'a1' as probably intended) statechart ends up in ['a1', 'b2'] and not ['a2', 'b2'].

This exposes a curious bug:

  • transition to 'a2' defined in test3 as it is now (e.g. on state 'a') has LCA 'p'
  • transition defined on 'b1' has LCA 'b'
  • when determining inconsistent transitions in small step these transitions end up conflicting (since their LCA-s are ancestrally related)
  • this causes transition to 'b2' to take priority over transition to 'a1', which ends up in final configuration ['a1', 'b2'] and not ['a2', 'b2']

fail test/w3c-ecma/test521.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test521.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s0"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s0"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1438,
"nextConfiguration": [
"s0"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- we test that the processor raises error.communication if it cannot dispatch the event.
(To create an undispatchable event, we choose a non-existent session as target).  If it raises
the error event, we succeed.  Otherwise we eventually timeout and fail.  -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" datamodel="ecmascript" version="1.0">


<state id="s0">
  <onentry>
   <!-- should cause an error -->
   <send target="#_scxml_foo" event="event2"/>
   <!-- this will get added to the external event queue after the error has been raised -->
   <send event="timeout"/>
    </onentry>

 <!-- once we've entered the state, we should check for internal events first -->   
  <transition event="error.communication" target="pass"/>
  <transition event="*" target="fail"/>
 </state>


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

Drag and drop demo bug

Hi Jacob, cool project!

When I view the drag and drop demo http://jbeard4.github.com/SCION/demos/drag-and-drop/drag-and-drop.xhtml it works as described - except when I'm dragging the square and I move my mouse very quickly.

If I drag the mouse fast enough it will move outside the square before the square has updated to the new mouse position, and the square no longer changes position to match the mouse.

However, when I bring the mouse back into focus on the square it thinks I still have mousedown and will resume tracking until I do the move-the-mouse-too-fast trick again. I have to click to trigger the mouseup event to get the square to stop tracking my mouse.

fail test/w3c-ecma/test506.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test506.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1439,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that an internal transition whose targets are not proper descendants of its source state
behaves like an external transition -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s1" version="1.0" datamodel="ecmascript">
<datamodel>
  <data id="Var1" expr="0"/>  <!-- how often we have exited s2 -->
  <data id="Var2" expr="0"/>  <!-- how often we have exited s21 -->
  <data id="Var3" expr="0"/>  <!-- how often the transition for foo has been taken -->
  </datamodel>

 <state id="s1">
   <onentry>
    <raise event="foo"/>
    <raise event="bar"/>
    </onentry>
   <transition target="s2"/>
   </state>

<state id="s2" initial="s21">
  <onexit>
    <assign location="Var1" expr="Var1 + 1"/>
    </onexit>
  <transition event="foo" type="internal" target="s2">
     <assign location="Var3" expr="Var3 + 1"/>
     </transition>

   <!-- make sure the transition on foo was actually taken --> 
  <transition event="bar" cond="Var3==1" target="s3"/>
  <transition event="bar" target="fail"/>

 <state id="s21">
   <onexit>
   <assign location="Var2" expr="Var2 + 1"/>
   </onexit>
  </state>

</state>

<state id="s3">
  <!-- make sure that s2 was exited twice -->
    <transition cond="Var1==2" target="s4"/>
    <transition target="fail"/>
 </state> 

<state id="s4">
  <!-- make sure that s21 was exited twice -->
    <transition cond="Var2==2" target="pass"/>
    <transition target="fail"/>
 </state> 


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test560.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test560.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s0"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s0"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1425,
"nextConfiguration": [
"s0"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- in the ECMA data model, test that processor creates correct structure in
 _event.data when receiving KVPs in an event -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">


<state id="s0">
   <onentry>
    <send event="foo">
    <param name="aParam" expr="1"/>
    </send>
  </onentry>
  <transition event="foo" cond="_event.data.aParam == 1" target="pass"/>
  <transition event="*" target="fail"/>
  </state>


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>  

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test456.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test456.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1444,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- we can't test that _any_ ecmascript is valid inside <script>, so we
just run a simple one and check that it can update the data model. -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">
<datamodel>
  <data id="Var1"/>
  </datamodel>

 <state id="s0">
  <onentry>
    <script>
      Var1+=1
      </script>
   </onentry> 
   <transition cond="Var1==1" target="pass"/>
   <transition target="fail"/>
   </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test488.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test488.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s02"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s02"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1443,
"nextConfiguration": [
"s02"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!--  test that illegal expr in <param> produces error.execution and empty event.data -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" datamodel="ecmascript" initial="s0">


 <state id="s0" initial="s01">
   <!-- we should get the error before the done event -->
   <transition event="error.execution" target="s1"/>
   <transition event="done.state.s0" target="fail"/>     

      <transition event="done.state.s0" target="fail">
     </transition>

   <state id="s01">
   <transition target="s02"/>
   </state>
   <final id="s02">
     <donedata>
      <param expr="return" name="someParam"/>
      </donedata>
     </final>
  </state>


 <!-- if we get here, we received the error event. Now check that the done
 event has empty event.data -->

 <state id="s1">
   <transition event="done.state.s0" cond="_event.data === ''" target="pass"/>
   <transition event="*" target="fail"/>
   </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test423.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test423.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s1"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s1"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1452,
"nextConfiguration": [
"s1"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that we keep pulling external events off the queue till we find one that matches a transition. -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">


 <state id="s0">
  <onentry>
    <send event="externalEvent1"/>
    <send event="externalEvent2" delay="1s"/>
    <raise event="internalEvent"/>
    </onentry>
    <!-- in this state we should process only internalEvent -->
   <transition event="internalEvent" target="s1"/>
    <transition event="*" target="fail"/>
   </state>

 <state id="s1">
 <!-- in this state we ignore externalEvent1 and wait for externalEvent2 -->
   <transition event="externalEvent2" target="pass"/>
   <transition event="internalEvent" target="fail"/>
   </state>  


   <final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
   <final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test503.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test503.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1442,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that a targetless transition does not exit and reenter its source state -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s1" version="1.0" datamodel="ecmascript">
<datamodel>
  <data id="Var1" expr="0"/>  <!-- how often we have exited s2 -->
  <data id="Var2" expr="0"/>  <!-- how often the targetless transition in s2 has been executed -->
  </datamodel>

 <state id="s1">
   <onentry>
    <raise event="foo"/>
    <raise event="bar"/>
    </onentry>
   <transition target="s2"/>
   </state>

 <state id="s2">
   <onexit>
   <assign location="Var1" expr="Var1 + 1"/>
   </onexit>
   <transition event="foo">
     <assign location="Var2" expr="Var2 + 1"/>
     </transition>
   <!-- make sure the transition on foo was actually taken --> 
  <transition event="bar" cond="Var2==1" target="s3"/>
  <transition event="bar" target="fail"/>
  </state>

  <state id="s3">
  <!-- make sure that s2 was exited only once -->
    <transition cond="Var1==1" target="pass"/>
    <transition target="fail"/>
    </state> 


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

scion incompatible with requireJS?

First of all, thank you for an excellent tool.
Then my issue.
My project is built with requireJS. I would like to load scion by making it a dependency for some module, like so:
define([ "http://jbeard4.github.com/SCION/builds/latest/scion.js"]) function( scion ) { ...})
This will not work.
But I then found that I could not even load requireJS into the same page before scion. For scion will then notice a 'require' object and subsequently tries to apply 'require.define'. However, requireJS has no require.define. It does have a (global) define, however.
But when I make scion use that global define, requireJS complains about your module definitions.
So I am stuck.
I can probably figure out a way to hide requireJS from scion and still use it for my own code, but it is not a workaround I like very much.
Can you help me out?
Thanks in advance,
Joop Ringelberg

Tests actionSend broken on 2.0.0

To replicate, run:

jbeard4@Jacobs-MacBook-Pro:~/workspace/scion/scion/test$ node node-test-server.js 
Loading new statechart http://localhost:9999/scxml-test-framework/test/basic/basic1.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'b' ]
Loading new statechart http://localhost:9999/scxml-test-framework/test/actionSend/send8.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'b2' ]
Loading new statechart http://localhost:9999/scxml-test-framework/test/actionSend/send7.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'b2' ]
Loading new statechart http://localhost:9999/scxml-test-framework/test/actionSend/send6.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'f1' ]
Loading new statechart http://localhost:9999/scxml-test-framework/test/actionSend/send5.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'f2' ]
Loading new statechart http://localhost:9999/scxml-test-framework/test/actionSend/send4.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'd' ]
Loading new statechart http://localhost:9999/scxml-test-framework/test/actionSend/send3.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'c' ]
Loading new statechart http://localhost:9999/scxml-test-framework/test/actionSend/send2.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'c' ]
Loading new statechart http://localhost:9999/scxml-test-framework/test/actionSend/send1.scxml
sending event to statechart { name: 't' }
nextConfiguration [ 'c' ]
jbeard4@Jacobs-MacBook-Pro:~/workspace/scion/scion/test$ node scxml-test-framework/lib/test-client.js
 scxml-test-framework/test/actionSend/send*.scxml
File server listing on  9999
Passed: scxml-test-framework/test/actionSend/send8.scxml
Failed: scxml-test-framework/test/actionSend/send7.scxml
Failed: scxml-test-framework/test/actionSend/send6.scxml
Failed: scxml-test-framework/test/actionSend/send5.scxml
Passed: scxml-test-framework/test/actionSend/send4.scxml
Passed: scxml-test-framework/test/actionSend/send3.scxml
Passed: scxml-test-framework/test/actionSend/send2.scxml
Passed: scxml-test-framework/test/actionSend/send1.scxml
TEST RESULTS
Passed: 5, Error: 0, Failed: 3

unexptected behaviour

Hello Jakob,
Could you help me out with this one?

<scxml version="0.9" xmlns="http://www.w3.org/2005/07/scxml">
    <parallel id="clock">
        <parallel id="ticker">
            <state id="timer">
                <onentry>
                    <send event="tick" delay="1s"/>
                    <log expr="'entering timer'"/>
                </onentry>
                <transition event="tick" target="timer">
                    <log expr="'tick'"/>
                </transition>
            </state>
        </parallel>
        <parallel id="display">
            <state id="minutesDisplay">
                <state id="time_m">
                    <transition event="tick">
                        <log expr="'time_m picks up tick'"/>
                    </transition>
                </state>
            </state>
        </parallel>
    </parallel>
</scxml>

The above is a stripped version of a larger chart (to explain the rather pointless nesting).
I would expect that each second, a tick event is fired and that the transition in state time_m is executed as it is triggered by this event.
However, only one tick is generated and the transition in time_m is only followed once.

There are several ways I can make it work; however, I understand none of them.

First, if we change "ticker" to a compound state, it will work (I tested each variant with your simulator at http://live.echo-flow.com/scion-web-simulation-environment/).

<scxml version="0.9" xmlns="http://www.w3.org/2005/07/scxml">
    <parallel id="clock">
        <state id="ticker">
            <state id="timer">
                <onentry>
                    <send event="tick" delay="1s"/>
                    <log expr="'entering timer'"/>
                </onentry>
                <transition event="tick" target="timer">
                    <log expr="'tick'"/>
                </transition>
            </state>
        </state>
        <parallel id="display">
            <state id="minutesDisplay">
                <state id="time_m">
                    <transition event="tick">
                        <log expr="'time_m picks up tick'"/>
                    </transition>
                </state>
            </state>
        </parallel>
    </parallel>
</scxml>

Second, if I omit the transition in time_m, it will work, too:

<scxml version="0.9" xmlns="http://www.w3.org/2005/07/scxml">
    <parallel id="clock">
        <parallel id="ticker">
            <state id="timer">
                <onentry>
                    <send event="tick" delay="1s"/>
                    <log expr="'entering timer'"/>
                </onentry>
                <transition event="tick" target="timer">
                    <log expr="'tick'"/>
                </transition>
            </state>
        </parallel>
        <parallel id="display">
            <state id="minutesDisplay">
                <state id="time_m">
                </state>
            </state>
        </parallel>
    </parallel>
</scxml>

Finally, by adding a send tick expression in the transition in "timer", it will tick on, too:

<scxml version="0.9" xmlns="http://www.w3.org/2005/07/scxml">
    <parallel id="clock">
        <parallel id="ticker">
            <state id="timer">
                <onentry>
                    <send event="tick" delay="1s"/>
                    <log expr="'entering timer'"/>
                </onentry>
                <transition event="tick">
                                    <send event="tick" delay="1s"/>
                    <log expr="'tick'"/>
                </transition>
            </state>
        </parallel>
        <parallel id="display">
            <state id="minutesDisplay">
                <state id="time_m">
                    <transition event="tick">
                        <log expr="'time_m picks up tick'"/>
                    </transition>
                </state>
            </state>
        </parallel>
    </parallel>
</scxml>

I tried to reason it through using the W3 SCXML draft, but, as said above, I do not understand this behaviour; nor do I understand why the first variant will not work as expected.
Thanks in advance,

Joop Ringelberg

fail test/w3c-ecma/test416.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test416.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s11final"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s11final"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1457,
"nextConfiguration": [
"s11final"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that the done.state.id gets generated when we enter the final state of a compound state -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" initial="s1" datamodel="ecmascript">

 <state id="s1" initial="s11">
   <onentry>
     <send event="timeout" delay="1s"/>
     </onentry>
   <transition event="timeout" target="fail"/>

   <state id="s11" initial="s111">
     <transition event="done.state.s11" target="pass"/>
     <state id="s111">
       <transition target="s11final"/>
       </state>
     <final id="s11final"/>
   </state>
 </state>      


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test529.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test529.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s02"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s02"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1434,
"nextConfiguration": [
"s02"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- simple test that children workn with <content> -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" datamodel="ecmascript" initial="s0">


 <state id="s0" initial="s01">

   <transition event="done.state.s0" cond="_event.data === '21'" target="pass">
     </transition>

      <transition event="done.state.s0" target="fail">
     </transition>

   <state id="s01">
   <transition target="s02"/>
   </state>
   <final id="s02">
     <donedata>
      <content>21</content>
      </donedata>
     </final>
 </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

error test/w3c-ecma/test441a.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test441a.txml.scxml

Error

null

Data:
"Unexpected identifier"

scxml:

<?xml version="1.0" encoding="UTF-8"?><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" datamodel="null" version="1.0" exmode="lax" initial="s01">


<!-- since exmode=lax, the processor should ignore all datamodel elements and complete without an error -->

<datamodel>
  <data id="Var1" expr="1"/>
  </datamodel>

<state id="s0">
   <onentry>
     <assign location="foo" expr="2"/>
     <script>
       x = y
       </script>
     <foreach array="baz" item="bat">
       <log expr="this is a mistake"/>
       </foreach>
     </onentry>

   <state id="s01" initial="s01final">
       <final id="s01final">
        <donedata>
       <param name="result" expr="foo"/>
       </donedata>
       </final>   
   </state>

   <transition cond="Var1==1" target="fail"/>
   <transition event="error" target="fail"/>   
   <transition event="done" target="s1"/>
 </state>

<state id="s1"> 
  <onentry>
   <raise event="noerror"/>
   </onentry>
     <transition event="error" target="fail"/>
     <transition event="noerror" target="pass"/>
 </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>


</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

Demo page not working on internet explorer and Firefox android.

Hello Jacob,

I'm trying to use your library in a project, which would be based on a statemachine, so I found the SCXML format and your SCION which seems to do what I want :)
BUT, the demo page doesn't seem to work on Internet Explorer 8 and 9 and in Firefox on Android.
Do you know why it wouldn't work, and would it be easy to fix ?

Thank you.

fail test/w3c-ecma/test570.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test570.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"p0s1final",
"p0s2final"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["p0s1final","p0s2final"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1422,
"nextConfiguration": [
"p0s1final",
"p0s2final"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that we generate done.state.id when all a parallel state's children are in final states -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="p0" datamodel="ecmascript" version="1.0">
  <datamodel>
    <data id="Var1" expr="0"/>
    </datamodel>
<parallel id="p0">
  <onentry>
   <send event="timeout" delay="2s"/>
   <raise event="e1"/>
   <raise event="e2"/>
   </onentry>
   <!-- record that we get the first done event -->
   <transition event="done.state.p0s1">
     <assign location="Var1" expr="1"/>
     </transition>
   <!-- we should get the second done event before done.state.p0 -->
   <transition event="done.state.p0s2" target="s1"/>
   <transition event="timeout" target="fail"/>


   <state id="p0s1" initial="p0s11">
    <state id="p0s11">
      <transition event="e1" target="p0s1final"/>
      </state>
    <final id="p0s1final"/>
   </state>

  <state id="p0s2" initial="p0s21">
    <state id="p0s21">
       <transition event="e2" target="p0s2final"/>
     </state>
    <final id="p0s2final"/>
   </state>

 </parallel>

 <state id="s1">
  <!-- if we get done.state.p0, success -->
  <transition event="done.state.p0" cond="Var1==1" target="pass"/>
  <transition event="*" target="fail"/>
  </state>

   <final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
   <final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

error test/w3c-ecma/test413.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test413.txml.scxml

Error

null

Data:
"Unable to locate initial state for composite state: undefined"

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that the state machine is put into the configuration specified by the initial element, without regard
to any other defaults.  we should start off in s2p111 and s2p122.  the atomic
states we should not enter all have immediate transitions to failure in them -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s2p112 s2p122" version="1.0" datamodel="ecmascript">

 <state id="s1">
   <transition target="fail"/>
   </state>

<state id="s2" initial="s2p1">

<parallel id="s2p1">
  <!-- this transition will be triggered only if we end up in an illegal configuration where we're in
  either s2p112 or s2p122, but not both of them -->
  <transition target="fail"/>

  <state id="s2p11" initial="s2p111">
    <state id="s2p111">
      <transition target="fail"/>
    </state>

    <state id="s2p112">
      <transition cond="In('s2p122')" target="pass"/>
      </state>

  </state> <!-- end s2p11 -->

  <state id="s2p12" initial="s2p121">
    <state id="s2p121">
       <transition target="fail"/>
     </state>

    <state id="s2p122">
      <transition cond="In('s2p112')" target="pass"/>
    </state>
  </state>

</parallel>

</state>  <!-- end s2 -->


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test421.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test421.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s11"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s11"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1454,
"nextConfiguration": [
"s11"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that internal events take priority over external ones, and that the processor
keeps pulling off internal events until it finds one that triggers a transition -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" initial="s1" datamodel="ecmascript">

 <state id="s1" initial="s11">
   <onentry>
      <send event="externalEvent"/>
     <raise event="internalEvent1"/>
     <raise event="internalEvent2"/>
     <raise event="internalEvent3"/>
     <raise event="internalEvent4"/>
     </onentry>

   <transition event="externalEvent" target="fail"/>

   <state id="s11">
     <transition event="internalEvent3" target="s12"/>
     </state>

   <state id="s12">
     <transition event="internalEvent4" target="pass"/>
    </state>

</state> 


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test527.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test527.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s02"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s02"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1436,
"nextConfiguration": [
"s02"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- simple test that 'expr' works with <content> -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" datamodel="ecmascript" initial="s0">


 <state id="s0" initial="s01">

   <transition event="done.state.s0" cond="_event.data === 'foo'" target="pass">
     </transition>

      <transition event="done.state.s0" target="fail">
     </transition>

   <state id="s01">
   <transition target="s02"/>
   </state>
   <final id="s02">
     <donedata>
      <content expr="'foo'"/>
      </donedata>
     </final>
 </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

more-parallel/test0

https://github.com/jbeard4/scxml-test-framework/blob/master/test/more-parallel/test0.scxml breaks with final configuration being [a] instead of expected [a, b].

The issue is caused by how exited and entered states are determined:

  • LCA for transition a -> a is p
  • LCA descendants are [a, b]
  • The current logic implies that b therefore is exited
  • b is then never entered due to getAncestors implementation that (perhaps erroneously?) doesn't include root node in the list of returned ancestors when one is specified (e.g.: index = s.ancestors.indexOf(root); return s.ancestors.slice(0, index);)

There's a bit of ambiguity here. E.g. either b shouldn't be exited when a is or b should be entered when a is. Overall implementation suggests that the latter was intended and then the actual issue with the test might be caused by mentioned above behavior of getAncestors. In this case changing the logic to return s.ancestors.slice(0, index + 1) will resolve the issue with the test.

Interestingly enough SCXML algorithm seems to be getting around the ambiguity by assigning different ancestor to transition depending on whether transition is internal or external:

let the transition's ancestor state be the source state (in the case of internal transitions)
or (in the case of external transitions) the least common compound ancestor

Just wondering what was the rational for dropping transition types?

fail test/w3c-ecma/test558.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test558.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"fail"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["fail"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1426,
"nextConfiguration": [
"fail"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- in the ECMA data model, test that if the child of <data> is not XML, or if XML is loaded via src=, 
 the processor treats the value as a string, does whitespace normalization and assigns it to the var.-->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript">
 <datamodel>
   <data id="var1">
this  is 
a string 
</data>
  <data id="var2" src="file:test558.txt"/> 
  </datamodel>

<state id="s0">
   <transition cond="var1 == 'this is a string'" target="s1"/>
   <transition target="fail"/>
  </state>

<state id="s1">
   <transition cond="var2 == 'this is a string'" target="pass"/>
   <transition target="fail"/>
   </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>  

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

error test/w3c-ecma/test441b.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test441b.txml.scxml

Error

null

Data:
"Unexpected identifier"

scxml:

<?xml version="1.0" encoding="UTF-8"?><scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" datamodel="null" version="1.0" exmode="strict" initial="s01">


<!-- since exmode=strict, the processor should reject this document. Therefore this is a manual test -->

<datamodel>
  <data id="Var1" expr="1"/>
  </datamodel>

<state id="s0">
   <onentry>
     <assign location="foo" expr="2"/>
     <script>
       x = y
       </script>
     <foreach array="baz" item="bat">
       <log expr="this is a mistake"/>
       </foreach>
     </onentry>


   <state id="s01" initial="s01final">
       <final id="s01final">
        <donedata>
       <param name="result" expr="foo"/>
       </donedata>
       </final>   
   </state>

   <transition target="fail"/>   

 </state>

<state id="s1"> 
  <onentry>
   <raise event="noerror"/>
   </onentry>
     <transition event="error" target="fail"/>
     <transition event="noerror" target="pass"/>
 </state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>


</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

error test/w3c-ecma/test487.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test487.txml.scxml

Error

null

Data:
"Unexpected token return"

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test illegal assignment.  error.execution should be raised.  -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" datamodel="ecmascript" version="1.0">
<datamodel>
  <data id="Var1" expr="return"/>
  </datamodel>

<state id="s0">
  <onentry>
   <raise event="event"/>
   </onentry>

  <transition event="error.execution" target="pass"/>
  <transition event="*" target="fail"/>
</state>

<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>
</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

fail test/w3c-ecma/test417.txml.scxml

https://github.com/jbeard4/scxml-test-framework/tree/master/test/w3c-ecma/test417.txml.scxml

Error

{
"name": "AssertionError",
"actual": [
"s1p11final",
"s1p12final"
],
"expected": [
"pass"
],
"operator": "deepEqual",
"message": "["s1p11final","s1p12final"] deepEqual ["pass"]"
}

Data:
{
"sessionToken": 1456,
"nextConfiguration": [
"s1p11final",
"s1p12final"
]
}

scxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- test that we get the done.state.id event when all of a 
parallel elements children enter final states.  -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" version="1.0" initial="s1" datamodel="ecmascript">

 <state id="s1" initial="s1p1">
   <onentry>
     <send event="timeout" delay="1s"/>
     </onentry>
   <transition event="timeout" target="fail"/>

  <parallel id="s1p1">
     <transition event="done.state.s1p1" target="pass"/>

     <state id="s1p11" initial="s1p111">
        <state id="s1p111">
         <transition target="s1p11final"/>
        </state>
        <final id="s1p11final"/>
     </state>

     <state id="s1p12" initial="s1p121">
       <state id="s1p121">
         <transition target="s1p12final"/>
       </state>
       <final id="s1p12final"/>
     </state>

  </parallel>
</state> 


<final id="pass"><onentry><log label="Outcome" expr="'pass'"/></onentry></final>
<final id="fail"><onentry><log label="Outcome" expr="'fail'"/></onentry></final>

</scxml>

JSON:

{
"initialConfiguration": [
"pass"
],
"events": []
}

Karma tests broken on 2.0.0

Replicate by running: ./node_modules/.bin/karma start test/platform-tests/browser/scxml.conf.js --single-run

This is the last test that is run:

DEBUG [web server]: serving: /Users/jbeard4/workspace/scion/scion/test/platform-tests/browser/scxml-test-framework/test/script/test1.json
Firefox 31.0 (Mac) LOG: [ 'model',
  'function (_x,_sessionid,_name,_ioprocessors,In){\n"use strict";\n\n    \n    \n    \n    \n    var x;\n    \n    var $scion_early_binding_datamodel_has_fired = false;\n    function $initEarlyBindingDatamodel(_event){\n        if(!$scion_early_binding_datamodel_has_fired){\n            $scion_early_binding_datamodel_has_fired = true; \n        }\n    }\n    \n    function $script_line_27_column_20(_event){\n        x = 0;\n    }\n    \n    function $script_line_35_column_20(_event){\n        x = x + 1;\n    }\n    \n    function $cond_line_34_column_49(_event){\n        return x < 100;\n    }\n    \n    function $cond_line_39_column_49(_event){\n        return x === 100;\n    }\n    \n    return {\n        "": "http://www.w3.org/2005/07/scxml",\n        "type": "scxml",\n        "states": [\n            {\n                "id": "a",\n                "transitions": [\n                    {\n                        "target": "b",\n                        "event": "t",\n                        "onTransition": $script_line_27_column_20\n                    }\n                ]\n            },\n            {\n                "id": "b",\n                "transitions": [\n                    {\n                        "target": "b",\n                        "cond": $cond_line_34_column_49,\n                        "onTransition": $script_line_35_column_20\n                    },\n                    {\n                        "target": "c",\n                        "cond": $cond_line_39_column_49\n                    }\n                ]\n            },\n            {\n                "id": "c"\n            }\n        ],\n        "onEntry": [\n            $initEarlyBindingDatamodel\n        ]\n    };}' ]
Firefox 31.0 (Mac) LOG: [ 'initial configuration', [ 'a' ] ]
Firefox 31.0 (Mac) LOG: [ 'sending event', { name: 't' } ]
Firefox 31.0 (Mac) LOG: [ 'next configuration', [ 'c' ] ]
Firefox 31.0 (Mac): Executed 93 of 0

Then it freezes.

npm install issues

Hi, Jacob,

Following the second set of installation instructions under 'Usage in node.js', npm reports:

41 error git clone git://github.com/jbeard4/xmldom.git CreateProcessW: The system cannot find the file specified.

Removing 'xmldom' in the dependencies section of package.json, the next error is:

39 error Error: git "clone" "git://github.com/jbeard4/stitch.git" "C:\\Users\\matto\\AppData\\Local\\Temp\\npm-1112\\1357233034301-0.7431445950642228" failed with 127

Removing 'stitch' in the devDependencies section of package.json that appears to be the last of it.

Are these no longer relevant?

Matt

isRhino() evaluates to true in Firefox 15.0.1

When defining the platform, scion's isRhino() function evaluates to true in Firefox 15.0.1, which caused my implementation to halt on require('./rhino/platform').

Forcing isRhino() to evaluate to false solved my problem. Maybe isBrowser() should take precedence to isRhino()?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.