Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Fixed startsAt bug; thanks to GH user pirque for finding it
Browse files Browse the repository at this point in the history
  • Loading branch information
soney committed Jun 5, 2014
1 parent e178873 commit d836c7a
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 182 deletions.
334 changes: 167 additions & 167 deletions api/index.html

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions build/cjs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ConstraintJS (CJS) 0.9.6-beta
// ConstraintJS (CJS) 0.9.6-beta1
// ConstraintJS may be freely distributed under the MIT License
// http://cjs.from.so/

Expand Down Expand Up @@ -2074,7 +2074,7 @@ extend(cjs, {
* @property {string} cjs.version
* @see cjs.toString
*/
version: "0.9.6-beta", // This template will be filled in by the builder
version: "0.9.6-beta1", // This template will be filled in by the builder

/**
* Print out the name and version of ConstraintJS
Expand Down Expand Up @@ -5160,8 +5160,8 @@ var FSM = function() {
* @return {FSM} - `this`
* @example
*
* var x = cjs.fsm("a", "b");
* x.addTransition("a", "b", cjs.on("click"));
* var my_fsm = cjs.fsm("state_a", "state_b");
* my_fsm.startsAt("state_b");
*/
proto.startsAt = function(state_name) {
var state = getStateWithName(this, state_name); // Get existing state
Expand All @@ -5172,6 +5172,7 @@ var FSM = function() {
if(!this.did_transition) {
// If no transitions have occurred, set the current state to the one they specified
this._curr_state = state;
this.state.invalidate();
}
this._chain_state = state;
return this;
Expand All @@ -5185,8 +5186,8 @@ var FSM = function() {
* @return {boolean} - `true` if the name of the active state is `state_name`. `false` otherwise
* @example
*
* var x = cjs.fsm("a", "b");
* fsm.is("a"); // true, because a is the starting state
* var my_fsm = cjs.fsm("a", "b");
* my_fsm.is("a"); // true, because a is the starting state
*/
proto.is = function(state_name) {
// get the current state name & compare
Expand Down
6 changes: 3 additions & 3 deletions build/cjs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/cjs.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "constraintjs",
"version": "0.9.6-beta",
"version": "0.9.6-beta1",
"description": "Constraint library for JavaScript",
"author": "Stephen Oney <[email protected]> (http://from.so/)",
"homepage": "http://cjs.from.so/",
Expand Down
9 changes: 5 additions & 4 deletions src/state_machine/cjs_fsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ var FSM = function() {
* @return {FSM} - `this`
* @example
*
* var x = cjs.fsm("a", "b");
* x.addTransition("a", "b", cjs.on("click"));
* var my_fsm = cjs.fsm("state_a", "state_b");
* my_fsm.startsAt("state_b");
*/
proto.startsAt = function(state_name) {
var state = getStateWithName(this, state_name); // Get existing state
Expand All @@ -482,6 +482,7 @@ var FSM = function() {
if(!this.did_transition) {
// If no transitions have occurred, set the current state to the one they specified
this._curr_state = state;
this.state.invalidate();
}
this._chain_state = state;
return this;
Expand All @@ -495,8 +496,8 @@ var FSM = function() {
* @return {boolean} - `true` if the name of the active state is `state_name`. `false` otherwise
* @example
*
* var x = cjs.fsm("a", "b");
* fsm.is("a"); // true, because a is the starting state
* var my_fsm = cjs.fsm("a", "b");
* my_fsm.is("a"); // true, because a is the starting state
*/
proto.is = function(state_name) {
// get the current state name & compare
Expand Down
10 changes: 10 additions & 0 deletions test/unit_tests/fsm_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,13 @@ dt("FSM on", 42, function() {

fsm.destroy();
});

dt("FSM startsAt bug", 2, function() {
var fsm = cjs .fsm()
.addState("state_1");
ok(fsm.is("state_1"));
fsm.startsAt("state_2");
ok(fsm.is("state_2"));

fsm.destroy();
});

0 comments on commit d836c7a

Please sign in to comment.