Skip to content

Commit

Permalink
Tests to ensure empty state names are forbidden in string and datastr…
Browse files Browse the repository at this point in the history
…ucture, fixes StoneCypher/fsl#598
  • Loading branch information
StoneCypher committed Oct 29, 2021
1 parent d078888 commit f0869e0
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -10,7 +10,7 @@ Readable, useful state machines as one-liner strings.

# <a href="https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html" target="_blank" rel="noopener noreferrer">TRY THE LIVE EDITOR</a>

<a href="https://discord.gg/cPmDa4JBGS">Discord community</a>
<a href="https://discord.gg/cPmDa4JBGS">Discord community</a> - <a href="https://stonecypher.github.io/jssm/docs/">Documentation</a> - <a href="https://github.com/StoneCypher/fsl/issues">Issue tracker</a> - <a href="https://github.com/StoneCypher/jssm/actions">CI build history</a>

<br/><br/>

Expand Down
2 changes: 1 addition & 1 deletion dist/es6/version.js
@@ -1,2 +1,2 @@
const version = "5.38.0";
const version = "5.39.0";
export { version };
2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.nonmin.js
Expand Up @@ -15736,7 +15736,7 @@ function peg$parse(input, options) {
}
}

const version = "5.38.0";
const version = "5.39.0";

// whargarbl lots of these return arrays could/should be sets
/* eslint-disable complexity */
Expand Down
2 changes: 1 addition & 1 deletion dist/jssm.es5.iife.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jssm.es5.iife.nonmin.js
Expand Up @@ -15735,7 +15735,7 @@ var jssm = (function (exports) {
}
}

const version = "5.38.0";
const version = "5.39.0";

// whargarbl lots of these return arrays could/should be sets
/* eslint-disable complexity */
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/assets/js/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/docs/classes/Machine.html
Expand Up @@ -7,6 +7,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
<script async src="../assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/index.html
Expand Up @@ -7,6 +7,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
<script async src="assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
Expand Down Expand Up @@ -83,7 +84,7 @@ <h1>jssm</h1>
<a href="#try-the-live-editor" id="try-the-live-editor" style="color: inherit; text-decoration: none;">
<h1><a href="https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html" target="_blank" rel="noopener noreferrer">TRY THE LIVE EDITOR</a></h1>
</a>
<p><a href="https://discord.gg/cPmDa4JBGS">Discord community</a></p>
<p><a href="https://discord.gg/cPmDa4JBGS">Discord community</a> - <a href="https://stonecypher.github.io/jssm/docs/">Documentation</a> - <a href="https://github.com/StoneCypher/fsl/issues">Issue tracker</a> - <a href="https://github.com/StoneCypher/jssm/actions">CI build history</a></p>
<p><br/><br/></p>
<p>Wouldn&#39;t it be nice if your TypeScript and Javascript state machines were simple and readable one-liners?</p>
<pre><code class="language-javascript"><span style="color: #AF00DB">import</span><span style="color: #000000"> { </span><span style="color: #001080">sm</span><span style="color: #000000"> } </span><span style="color: #AF00DB">from</span><span style="color: #000000"> </span><span style="color: #A31515">&#039;jssm&#039;</span><span style="color: #000000">;</span>
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/modules.html
Expand Up @@ -7,6 +7,7 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
<script async src="assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
Expand Down Expand Up @@ -132,7 +133,7 @@ <h3><span class="tsd-flag ts-flagConst">Const</span> seq</h3>
<section class="tsd-panel tsd-member tsd-kind-variable">
<a name="version" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> version</h3>
<div class="tsd-signature tsd-kind-icon">version<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = &quot;5.38.0&quot;</span></div>
<div class="tsd-signature tsd-kind-icon">version<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = &quot;5.39.0&quot;</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in version.ts:2</li>
Expand Down
28 changes: 21 additions & 7 deletions src/ts/tests/state_declaration.spec.ts
Expand Up @@ -182,13 +182,6 @@ describe('error catchery', () => {
.toThrow()
);

test.todo('These two catch the uncovered line on 656, but cause missing coverage errors on 803,936-952');

// test('Cannot generate an existing state', () =>
// expect( () => { sm`a->c;state c:{};`._new_state({name:'c'} as any); } )
// .toThrow()
// );

test('Cannot generate an existing state', () =>
expect( () => {
const errM = sm`a->c;state c:{};`;
Expand All @@ -197,4 +190,25 @@ describe('error catchery', () => {
.toThrow()
);

test('Cannot generate an empty state name as string', () =>
expect( () => {
const errM = sm`state "":{};`;
} )
.toThrow()
);

describe('Cannot generate an empty state name as datastructure', () => {

const prestate = {
"start_states":["b"],
"transitions":[{"from":"b","to":"c","kind":"legal","forced_only":false,"main_path":false}],
"state_declaration":[{"state":""}]
};

test('throws', () =>
expect( () => { const _m0 = new jssm.Machine(prestate as any); } )
.toThrow() );

});

});
2 changes: 1 addition & 1 deletion src/ts/version.ts
@@ -1,3 +1,3 @@

const version: string = "5.38.0";
const version: string = "5.39.0";
export { version };

0 comments on commit f0869e0

Please sign in to comment.