Skip to content

Commit

Permalink
comment testing
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed Sep 4, 2017
1 parent 124c265 commit 25a9bb8
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
* [[`124c2654c7`](https://github.com/StoneCypher/jssm/commit/124c2654c7)] - Merge pull request #304 from msmorgan/bugfix/comment-grammar (John Haugeland)
* [[`8fc29115f5`](https://github.com/StoneCypher/jssm/commit/8fc29115f5)] - **grammar**: Fix whitespace and comment rules (Michael Morgan)
* [[`d1cac9b592`](https://github.com/StoneCypher/jssm/commit/d1cac9b592)] - Merge branch 'master' of github.com:StoneCypher/jssm (John Haugeland)
* [[`e87f48c1a1`](https://github.com/StoneCypher/jssm/commit/e87f48c1a1)] - tooling bumps, example code, eslint stuff (John Haugeland)
* [[`406d01dff7`](https://github.com/StoneCypher/jssm/commit/406d01dff7)] - Update README.md (John Haugeland)
* [[`3e34c40ce4`](https://github.com/StoneCypher/jssm/commit/3e34c40ce4)] - update tests (John Haugeland)
* [[`b31b7b3a89`](https://github.com/StoneCypher/jssm/commit/b31b7b3a89)] - fsl version, author contributor comment definition license, license types, urls, filename changes (John Haugeland)
* [[`b96cda04cc`](https://github.com/StoneCypher/jssm/commit/b96cda04cc)] - rename fsl files (John Haugeland)
Expand Down
4 changes: 2 additions & 2 deletions build/jssm-dot.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/jssm.es5.cjs.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

63 changes: 47 additions & 16 deletions build/tests/comment.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/js/jssm-dot.peg
Expand Up @@ -152,9 +152,9 @@ LineComment
= "//" LineCommentTail

WS
= Whitespace
/ BlockComment
/ LineComment
= BlockComment WS?
/ LineComment WS?
/ [ \t\r\n\v]+ WS?

String "string"
= QuoteMark chars:Char* QuoteMark { return chars.join(""); }
Expand Down
130 changes: 130 additions & 0 deletions src/js/tests/comment.js
@@ -0,0 +1,130 @@

/* eslint-disable max-len */

import {test, describe} from 'ava-spec';

const jssm = require('../../../build/jssm.es5.js');





describe('block strategies', async it => {

const AtoB = [{"key": "transition", "from": "a", "se": {"kind": "->","to": "b"}}],
is_AB = str => it(test, t => t.deepEqual(AtoB, jssm.parse(str))),

ABCD = [{"key": "transition", "from": "a", "se": {"kind": "->","to": "b"}},
{"key": "transition", "from": "c", "se": {"kind": "->","to": "d"}}],

is_ABCD = str => it(test, t => t.deepEqual(ABCD, jssm.parse(str)));

describe('empty block comments in left middle', async _it => {
is_AB('a/**/->b;');
is_AB('a /**/->b;');
is_AB('a/**/ ->b;');
is_AB('a /**/ ->b;');
is_AB('a\n/**/->b;');
is_AB('a/**/\n->b;');
is_AB('a\n/**/\n->b;');
});

describe('empty block comments in right middle', async _it => {
is_AB('a->/**/b;');
is_AB('a-> /**/b;');
is_AB('a->/**/ b;');
is_AB('a-> /**/ b;');
is_AB('a->\n/**/b;');
is_AB('a->/**/\nb;');
is_AB('a->\n/**/\nb;');
});

describe('non-empty block comments in left middle', async _it => {
is_AB('a/* hello */->b;');
is_AB('a /* hello */->b;');
is_AB('a/* hello */ ->b;');
is_AB('a /* hello */ ->b;');
is_AB('a\n/* hello */ ->b;');
is_AB('a/* hello */\n->b;');
is_AB('a\n/* hello */\n->b;');
});

describe('empty block comments before', async _it => {
is_AB('/**/a->b;');
is_AB('/**/ a->b;');
});

describe('empty block comments inbetween', async _it => {
is_ABCD('a->b;/**/c->d;');
is_ABCD('a->b; /**/c->d;');
is_ABCD('a->b;/**/ c->d;');
is_ABCD('a->b; /**/ c->d;');
});

describe('empty block comments after / at end', async _it => {
is_AB('a->b;/**/');
is_AB('a->b; /**/');
});

describe('block commented code', async _it => {
is_AB('a->b;/* c->d; */');
is_AB('a->b;\n/*c -> d;*/\n');
is_ABCD('a->b;/* e->f; */c->d;');
is_ABCD('a->b;\n/*e -> f;*/\nc->d;');
is_ABCD('a->b;\n/*e -> f;*/\nc->d;\n');
});

});





describe('line strategies', async it => {

const AtoB = [{"key": "transition", "from": "a", "se": {"kind": "->","to": "b"}}],
is_AB = str => it(test, t => t.deepEqual(AtoB, jssm.parse(str))),

ABCD = [{"key": "transition", "from": "a", "se": {"kind": "->","to": "b"}},
{"key": "transition", "from": "c", "se": {"kind": "->","to": "d"}}],

is_ABCD = str => it(test, t => t.deepEqual(ABCD, jssm.parse(str)));

describe('empty line comments at end', async _it => {
is_AB('a->b;//');
is_AB('a->b; //');
is_AB('a->b;//\n');
is_AB('a->b; //\n');
});

describe('non-empty line comments at end', async _it => {
is_AB('a->b;// hello');
is_AB('a->b; // hello');
is_AB('a->b;// hello\n');
is_AB('a->b; // hello\n');
});

describe('empty line comments at beginning', async _it => {
is_AB('//\na->b;');
});

describe('non-empty line comments at beginning', async _it => {
is_AB('// hello\na->b;');
});

describe('empty line comments inbetween', async _it => {
is_ABCD('a->b;//\nc->d;');
});

describe('non-empty line comments inbetween', async _it => {
is_ABCD('a->b;// hello\nc->d;');
});

describe('line commented code', async _it => {
is_AB('a->b;// c->d;');
is_AB('a->b;\n//c -> d;\n');
is_ABCD('a->b;// e->f;\nc->d;');
is_ABCD('a->b;\n//e -> f;\nc->d;');
});

});

0 comments on commit 25a9bb8

Please sign in to comment.