@masala/parser
Advanced tools
Comparing version 0.5.0-alpha3 to 0.5.0
@@ -45,3 +45,2 @@ 'use strict'; | ||
// For performance, we do not factorize mainstream letters in function | ||
@@ -66,3 +65,3 @@ if (symbol === null || symbol === OCCIDENTAL_LETTER) { | ||
throw 'Parameter ' + symbol + ' has wrong type : Should be C.OCCIDENTAL_LETTER, C.ASCII_LETTER or C.UTF8_LETTER'; | ||
throw 'Parameter ' + symbol.toString() + ' has wrong type : Should be C.OCCIDENTAL_LETTER, C.ASCII_LETTER or C.UTF8_LETTER'; | ||
} | ||
@@ -69,0 +68,0 @@ |
@@ -105,3 +105,3 @@ 'use strict'; | ||
var result = (0, _list2.default)(a).append((0, _list2.default)(b)).array(); | ||
if (result.length == 1) { | ||
if (result.length === 1) { | ||
return result[0]; | ||
@@ -122,3 +122,3 @@ } else { | ||
value: function drop() { | ||
return this.map(function (item) { | ||
return this.map(function () { | ||
return []; | ||
@@ -125,0 +125,0 @@ }); |
@@ -56,3 +56,3 @@ 'use strict'; | ||
test.equal((0, _list2.default)(1).filter(function (i) { | ||
return i != 1; | ||
return i !== 1; | ||
}).isEmpty(), true, 'should be empty.'); | ||
@@ -66,3 +66,3 @@ test.done(); | ||
test.equal((0, _list2.default)(1).filter(function (i) { | ||
return i == 1; | ||
return i === 1; | ||
}).isEmpty(), false, 'should not be empty.'); | ||
@@ -69,0 +69,0 @@ test.done(); |
@@ -17,11 +17,2 @@ 'use strict'; | ||
var value = undefined; | ||
function testParser(parser, string) { | ||
var myStream = _index2.default.ofString(string); | ||
var parsing = parser.parse(myStream); | ||
value = parsing.value; | ||
} | ||
exports.default = { | ||
@@ -162,3 +153,2 @@ setUp: function setUp(done) { | ||
'expect occidental letter to be accepted': function expectOccidentalLetterToBeAccepted(test) { | ||
test.ok(_index3.C.letter.parse(_index2.default.ofString('a'), 0).isAccepted()); | ||
@@ -174,3 +164,2 @@ test.ok(_index3.C.letterAs().parse(_index2.default.ofString('a'), 0).isAccepted()); | ||
'expect occidental letters to be accepted': function expectOccidentalLettersToBeAccepted(test) { | ||
test.ok(_index3.C.letters.then(_index3.F.eos).parse(_index2.default.ofString('aéÉ'), 0).isAccepted()); | ||
@@ -185,3 +174,2 @@ test.ok(_index3.C.lettersAs().then(_index3.F.eos).parse(_index2.default.ofString('aéÉ'), 0).isAccepted()); | ||
'expect ascii letter to be accepted': function expectAsciiLetterToBeAccepted(test) { | ||
test.ok(_index3.C.letterAs(_index3.C.ASCII_LETTER).parse(_index2.default.ofString('a'), 0).isAccepted()); | ||
@@ -194,3 +182,2 @@ test.ok(!_index3.C.letterAs(_index3.C.ASCII_LETTER).parse(_index2.default.ofString('é')).isAccepted()); | ||
'expect ascii letters to be accepted': function expectAsciiLettersToBeAccepted(test) { | ||
test.ok(_index3.C.lettersAs(_index3.C.ASCII_LETTER).then(_index3.F.eos).parse(_index2.default.ofString('a')).isAccepted()); | ||
@@ -203,3 +190,2 @@ test.ok(!_index3.C.lettersAs(_index3.C.ASCII_LETTER).then(_index3.F.eos).parse(_index2.default.ofString('éA')).isAccepted()); | ||
'expect utf8 letter to be accepted': function expectUtf8LetterToBeAccepted(test) { | ||
test.ok(_index3.C.letterAs(_index3.C.UTF8_LETTER).parse(_index2.default.ofString('a')).isAccepted()); | ||
@@ -212,3 +198,2 @@ test.ok(_index3.C.letterAs(_index3.C.UTF8_LETTER).parse(_index2.default.ofString('é')).isAccepted()); | ||
'expect utf8 letters to be accepted': function expectUtf8LettersToBeAccepted(test) { | ||
test.ok(_index3.C.lettersAs(_index3.C.UTF8_LETTER).then(_index3.F.eos).parse(_index2.default.ofString('a')).isAccepted()); | ||
@@ -221,2 +206,15 @@ test.ok(_index3.C.lettersAs(_index3.C.UTF8_LETTER).then(_index3.F.eos).parse(_index2.default.ofString('éA')).isAccepted()); | ||
'expect unknown letters to be rejected': function expectUnknownLettersToBeRejected(test) { | ||
var line = _index2.default.ofString('a'); | ||
var errorFound = false; | ||
try { | ||
var combinator = _index3.C.lettersAs(Symbol('UNKNOWN')).then(_index3.F.eos); | ||
combinator.parse(line); | ||
} catch (error) { | ||
errorFound = true; | ||
} | ||
test.ok(errorFound); | ||
test.done(); | ||
}, | ||
'expect (letters) to be accepted': function expectLettersToBeAccepted(test) { | ||
@@ -382,4 +380,3 @@ test.expect(2); | ||
} | ||
}; | ||
//# sourceMappingURL=chars-bundle-test.js.map |
@@ -330,3 +330,3 @@ 'use strict'; | ||
try { | ||
var parsing = combinator.parse(line); | ||
combinator.parse(line); | ||
} catch (e) { | ||
@@ -349,3 +349,3 @@ if (e === 'Input source must be a String') { | ||
try { | ||
var parsing = combinator.parse(line); | ||
combinator.parse(line); | ||
} catch (e) { | ||
@@ -352,0 +352,0 @@ if (e === 'Input source must be a String') { |
@@ -1,3 +0,2 @@ | ||
Deprecate in docs thenLeft, thenRight | ||
Create npm repo by publishing | ||
-> release | ||
@@ -9,2 +8,3 @@ | ||
lotech | ||
@@ -18,1 +18,7 @@ -> release | ||
>>>> Make a response with next Masala version | ||
Questions Didier | ||
- perdu lien coveralls | ||
- flatmap or flatMap ? |
@@ -42,2 +42,11 @@ This document is for contributors who want to publish. You must have | ||
* Set tag on github. On branch master : | ||
* Change version on package.json | ||
* commit & push | ||
* `git tag v0.5.0 master` | ||
* `git push origin v0.5.0` | ||
* `npm publish --access=public` | ||
# careful, especially for major release | ||
@@ -49,3 +58,3 @@ # YOU CANNOT UNPUBLISH easily !!!! | ||
# change version to to 0.4.0 | ||
npm publish | ||
npm publish --access=public | ||
@@ -11,3 +11,3 @@ Recursion | ||
const {stream, F, N, C, X} = require('parser-combinator'); | ||
const {stream, F, N, C, X} = require('@masala/parser'); | ||
@@ -14,0 +14,0 @@ function A(){ |
@@ -5,3 +5,3 @@ { | ||
"license": "LGPL-2.1", | ||
"version": "0.5.0-alpha3", | ||
"version": "0.5.0", | ||
"keywords": [ | ||
@@ -53,3 +53,4 @@ "parser", | ||
"format": "prettier-eslint --prettier.tab-width 4 --write \"src/**/*.js\"", | ||
"lint": "eslint src/**/*.js", | ||
"safeformat": "prettier-eslint --prettier.tab-width 4 \"src/**/*.js\"", | ||
"lint": "eslint \"src/**/*.js\"", | ||
"test": "npm run compile && nodeunit build/test/index.js", | ||
@@ -59,6 +60,6 @@ "cover": "rimraf ./coverage && mkdirp coverage && babel-node ./node_modules/.bin/babel-istanbul cover --dir coverage/istanbul node_modules/.bin/nodeunit src/test/index.js", | ||
"check": "npm run lint && npm run test && npm run cover", | ||
"concat": "rimraf dist/ && mkdirp dist && npm run compile && browserify build/lib/index.js --standalone masala -o dist/parser-combinator.js", | ||
"dist": "rimraf dist/ && mkdirp dist && npm run compile && browserify -t uglifyify build/lib/index.js --standalone masala -o dist/parser-combinator.min.js", | ||
"postpublish": "cd integration-npm && rm -rf node_modules && npm install && node integrate.js" | ||
"concat": "rimraf dist/ && mkdirp dist && npm run compile && browserify build/lib/index.js --standalone masala -o dist/masala-parser.js", | ||
"dist": "rimraf dist/ && mkdirp dist && npm run compile && browserify -t uglifyify build/lib/index.js --standalone masala-parser -o dist/masala-parser.min.js", | ||
"prepublish": "npm run check && npm run dist && node tasks/integrate.js && echo 'prepuplished OK'", | ||
"postpublish": "cd integration-npm && rimraf node_modules && sleep 5 && npm install && node integrate.js" | ||
}, | ||
@@ -65,0 +66,0 @@ "devDependencies": { |
@@ -12,3 +12,3 @@ # Masala Parser: Javascript Parser Combinators | ||
Masala Parser is a Javascript implementation of the Haskell **Parsec**. | ||
It is plain Javascript that works in the browser, is tested with more than 400 unit tests, covering 100% of code lines. | ||
It is plain Javascript that works in the browser, is tested with more than 450 unit tests, covering 100% of code lines. | ||
@@ -20,2 +20,3 @@ ### Use cases | ||
* It can validate complete structure with variations | ||
* It can parse and execute custom operations | ||
@@ -25,4 +26,14 @@ Masala Parser keywords are **variations** and **maintainability**. You won't | ||
# Usage | ||
With Node Js or modern build | ||
npm install -S @masala/parser | ||
Or in the browser | ||
* [download Release](https://github.com/d-plaindoux/masala-parser/releases) | ||
* `<script src="masala-parser.min.js"/>` | ||
# Quick Examples | ||
@@ -29,0 +40,0 @@ |
@@ -20,3 +20,2 @@ /* | ||
function isExtendedOccidental(v) { | ||
@@ -26,9 +25,12 @@ return /(?![\u00F7\u00D7])[\u00C0-\u017F^\u00F7]/.test(v); | ||
// unit -> Parser char char | ||
function letter(symbol = null) { | ||
// For performance, we do not factorize mainstream letters in function | ||
if (symbol === null || symbol === OCCIDENTAL_LETTER) { | ||
return F.satisfy(c => ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || isExtendedOccidental(c)); | ||
return F.satisfy( | ||
c => | ||
('a' <= c && c <= 'z') || | ||
('A' <= c && c <= 'Z') || | ||
isExtendedOccidental(c) | ||
); | ||
} | ||
@@ -41,9 +43,15 @@ | ||
if (symbol === UTF8_LETTER) { | ||
return F.satisfy(c => ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || isUtf8Letter(c)); | ||
return F.satisfy( | ||
c => | ||
('a' <= c && c <= 'z') || | ||
('A' <= c && c <= 'Z') || | ||
isUtf8Letter(c) | ||
); | ||
} | ||
throw 'Parameter ' + symbol + ' has wrong type : Should be C.OCCIDENTAL_LETTER, C.ASCII_LETTER or C.UTF8_LETTER'; | ||
throw 'Parameter ' + | ||
symbol.toString() + | ||
' has wrong type : Should be C.OCCIDENTAL_LETTER, C.ASCII_LETTER or C.UTF8_LETTER'; | ||
} | ||
function utf8Letter() { | ||
@@ -58,3 +66,5 @@ return F.satisfy(isUtf8Letter); | ||
function letters(symbolOrTestFunctionOrRegex) { | ||
return letter(symbolOrTestFunctionOrRegex).rep().map(values => values.join('')); | ||
return letter(symbolOrTestFunctionOrRegex) | ||
.rep() | ||
.map(values => values.join('')); | ||
} | ||
@@ -163,3 +173,3 @@ | ||
lettersAs: letters, | ||
emoji:emoji(), | ||
emoji: emoji(), | ||
notChar, | ||
@@ -179,3 +189,3 @@ char, | ||
OCCIDENTAL_LETTER, | ||
ASCII_LETTER | ||
ASCII_LETTER, | ||
}; | ||
@@ -185,4 +195,3 @@ | ||
function isEmojiRegex() { | ||
return (/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]\uFE0F|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDEB(?:\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]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])?|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])\uFE0F/ | ||
); | ||
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74)\uDB40\uDC7F|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]\uFE0F|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]))|\uD83D\uDC69\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83D\uDC69\u200D[\u2695\u2696\u2708])\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC68(?:\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDFD\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E4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])?|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])\uFE0F/; | ||
} |
@@ -109,3 +109,3 @@ /* | ||
parse, | ||
nop:nop, | ||
nop: nop, | ||
try: doTry, | ||
@@ -112,0 +112,0 @@ any: any(), |
@@ -64,3 +64,3 @@ /* | ||
let result = list(a).append(list(b)).array(); | ||
if (result.length == 1) { | ||
if (result.length === 1) { | ||
return result[0]; | ||
@@ -79,3 +79,3 @@ } else { | ||
drop() { | ||
return this.map(item => []); | ||
return this.map(() => []); | ||
} | ||
@@ -82,0 +82,0 @@ |
@@ -102,4 +102,2 @@ import {F, C, N} from '../../index'; | ||
_wordSequence(stop) { | ||
@@ -106,0 +104,0 @@ return F.not(stop); |
@@ -1,2 +0,2 @@ | ||
import {F, C, N} from '../parsec/index'; | ||
import {C, N} from '../parsec/index'; | ||
@@ -3,0 +3,0 @@ function _inQuote() { |
@@ -46,3 +46,3 @@ import list from '../../lib/data/list'; | ||
test.equal( | ||
list(1).filter(i => i != 1).isEmpty(), | ||
list(1).filter(i => i !== 1).isEmpty(), | ||
true, | ||
@@ -58,3 +58,3 @@ 'should be empty.' | ||
test.equal( | ||
list(1).filter(i => i == 1).isEmpty(), | ||
list(1).filter(i => i === 1).isEmpty(), | ||
false, | ||
@@ -61,0 +61,0 @@ 'should not be empty.' |
import stream from '../../lib/stream/index'; | ||
import {F, C} from '../../lib/parsec/index'; | ||
let value = undefined; | ||
function testParser(parser, string) { | ||
let myStream = stream.ofString(string); | ||
let parsing = parser.parse(myStream); | ||
value = parsing.value; | ||
} | ||
export default { | ||
setUp: function (done) { | ||
setUp: function(done) { | ||
done(); | ||
}, | ||
'expect (char) to be accepted': function (test) { | ||
'expect (char) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -29,3 +20,3 @@ // tests here | ||
'expect (char) to be rejected': function (test) { | ||
'expect (char) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -41,6 +32,6 @@ // tests here | ||
'expect (char) to be refused': function (test) { | ||
'expect (char) to be refused': function(test) { | ||
test.expect(1); | ||
// tests here | ||
test.throws(function () { | ||
test.throws(function() { | ||
C.char('aa'); | ||
@@ -51,3 +42,3 @@ }); | ||
'expect (notChar) to be accepted': function (test) { | ||
'expect (notChar) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -63,3 +54,3 @@ // tests here | ||
'expect (notChar) to be rejected': function (test) { | ||
'expect (notChar) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -75,6 +66,6 @@ // tests here | ||
'expect (notChar) to be refused': function (test) { | ||
'expect (notChar) to be refused': function(test) { | ||
test.expect(1); | ||
// tests here | ||
test.throws(function () { | ||
test.throws(function() { | ||
C.notChar('aa'); | ||
@@ -85,3 +76,3 @@ }); | ||
'expect (charNotIn) to be accepted': function (test) { | ||
'expect (charNotIn) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -97,3 +88,3 @@ // tests here | ||
'expect (charNotIn) to be rejected': function (test) { | ||
'expect (charNotIn) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -109,3 +100,3 @@ // tests here | ||
'expect (charIn) to be accepted': function (test) { | ||
'expect (charIn) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -121,3 +112,3 @@ // tests here | ||
'expect (charIn) to be rejected': function (test) { | ||
'expect (charIn) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -133,4 +124,3 @@ // tests here | ||
'expect (lowerCase) to be accepted': function (test) { | ||
'expect (lowerCase) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -146,3 +136,3 @@ // tests here | ||
'expect (lowerCase) to be rejected': function (test) { | ||
'expect (lowerCase) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -158,3 +148,3 @@ // tests here | ||
'expect (upperCase) to be accepted': function (test) { | ||
'expect (upperCase) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -170,3 +160,3 @@ // tests here | ||
'expect (upperCase) to be rejected': function (test) { | ||
'expect (upperCase) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -182,3 +172,3 @@ // tests here | ||
'expect upper (letter) to be accepted': function (test) { | ||
'expect upper (letter) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -194,3 +184,3 @@ // tests here | ||
'expect lower (letter) to be accepted': function (test) { | ||
'expect lower (letter) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -205,3 +195,3 @@ // tests here | ||
}, | ||
'expect space (letter) to be rejected': function (test) { | ||
'expect space (letter) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -217,3 +207,3 @@ // tests here | ||
'expect non (letter) to be rejected': function (test) { | ||
'expect non (letter) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -229,59 +219,152 @@ // tests here | ||
'expect occidental letter to be accepted': function (test) { | ||
'expect occidental letter to be accepted': function(test) { | ||
test.ok(C.letter.parse(stream.ofString('a'), 0).isAccepted()); | ||
test.ok(C.letterAs().parse(stream.ofString('a'), 0).isAccepted()); | ||
test.ok(C.letterAs(C.OCCIDENTAL_LETTER).parse(stream.ofString('a')).isAccepted()); | ||
test.ok(C.letterAs(C.OCCIDENTAL_LETTER).parse(stream.ofString('é')).isAccepted()); | ||
test.ok(!C.letterAs(C.OCCIDENTAL_LETTER).parse(stream.ofString('Б')).isAccepted()); | ||
test.ok(!C.letterAs(C.OCCIDENTAL_LETTER).parse(stream.ofString('÷')).isAccepted()); | ||
test.ok( | ||
C.letterAs(C.OCCIDENTAL_LETTER) | ||
.parse(stream.ofString('a')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
C.letterAs(C.OCCIDENTAL_LETTER) | ||
.parse(stream.ofString('é')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
!C.letterAs(C.OCCIDENTAL_LETTER) | ||
.parse(stream.ofString('Б')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
!C.letterAs(C.OCCIDENTAL_LETTER) | ||
.parse(stream.ofString('÷')) | ||
.isAccepted() | ||
); | ||
test.done(); | ||
}, | ||
'expect occidental letters to be accepted': function (test) { | ||
test.ok(C.letters.then(F.eos).parse(stream.ofString('aéÉ'), 0).isAccepted()); | ||
test.ok(C.lettersAs().then(F.eos).parse(stream.ofString('aéÉ'), 0).isAccepted()); | ||
test.ok(C.lettersAs(C.OCCIDENTAL_LETTER).parse(stream.ofString('a')).isAccepted()); | ||
test.ok(C.lettersAs(C.OCCIDENTAL_LETTER).then(F.eos).parse(stream.ofString('éA')).isAccepted()); | ||
test.ok(!C.lettersAs(C.OCCIDENTAL_LETTER).then(F.eos).parse(stream.ofString('БAs')).isAccepted()); | ||
'expect occidental letters to be accepted': function(test) { | ||
test.ok( | ||
C.letters.then(F.eos).parse(stream.ofString('aéÉ'), 0).isAccepted() | ||
); | ||
test.ok( | ||
C.lettersAs() | ||
.then(F.eos) | ||
.parse(stream.ofString('aéÉ'), 0) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
C.lettersAs(C.OCCIDENTAL_LETTER) | ||
.parse(stream.ofString('a')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
C.lettersAs(C.OCCIDENTAL_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('éA')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
!C.lettersAs(C.OCCIDENTAL_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('БAs')) | ||
.isAccepted() | ||
); | ||
test.done(); | ||
}, | ||
'expect ascii letter to be accepted': function (test) { | ||
test.ok(C.letterAs(C.ASCII_LETTER).parse(stream.ofString('a'), 0).isAccepted()); | ||
test.ok(!C.letterAs(C.ASCII_LETTER).parse(stream.ofString('é')).isAccepted()); | ||
test.ok(!C.letterAs(C.ASCII_LETTER).parse(stream.ofString('Б')).isAccepted()); | ||
'expect ascii letter to be accepted': function(test) { | ||
test.ok( | ||
C.letterAs(C.ASCII_LETTER) | ||
.parse(stream.ofString('a'), 0) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
!C.letterAs(C.ASCII_LETTER).parse(stream.ofString('é')).isAccepted() | ||
); | ||
test.ok( | ||
!C.letterAs(C.ASCII_LETTER).parse(stream.ofString('Б')).isAccepted() | ||
); | ||
test.done(); | ||
}, | ||
'expect ascii letters to be accepted': function (test) { | ||
test.ok(C.lettersAs(C.ASCII_LETTER).then(F.eos).parse(stream.ofString('a')).isAccepted()); | ||
test.ok(!C.lettersAs(C.ASCII_LETTER).then(F.eos).parse(stream.ofString('éA')).isAccepted()); | ||
test.ok(!C.lettersAs(C.ASCII_LETTER).then(F.eos).parse(stream.ofString('БAs')).isAccepted()); | ||
'expect ascii letters to be accepted': function(test) { | ||
test.ok( | ||
C.lettersAs(C.ASCII_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('a')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
!C.lettersAs(C.ASCII_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('éA')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
!C.lettersAs(C.ASCII_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('БAs')) | ||
.isAccepted() | ||
); | ||
test.done(); | ||
}, | ||
'expect utf8 letter to be accepted': function (test) { | ||
test.ok(C.letterAs(C.UTF8_LETTER).parse(stream.ofString('a')).isAccepted()); | ||
test.ok(C.letterAs(C.UTF8_LETTER).parse(stream.ofString('é')).isAccepted()); | ||
test.ok(C.letterAs(C.UTF8_LETTER).parse(stream.ofString('Б')).isAccepted()); | ||
test.ok(!C.letterAs(C.UTF8_LETTER).parse(stream.ofString('÷')).isAccepted()); | ||
'expect utf8 letter to be accepted': function(test) { | ||
test.ok( | ||
C.letterAs(C.UTF8_LETTER).parse(stream.ofString('a')).isAccepted() | ||
); | ||
test.ok( | ||
C.letterAs(C.UTF8_LETTER).parse(stream.ofString('é')).isAccepted() | ||
); | ||
test.ok( | ||
C.letterAs(C.UTF8_LETTER).parse(stream.ofString('Б')).isAccepted() | ||
); | ||
test.ok( | ||
!C.letterAs(C.UTF8_LETTER).parse(stream.ofString('÷')).isAccepted() | ||
); | ||
test.done(); | ||
}, | ||
'expect utf8 letters to be accepted': function (test) { | ||
'expect utf8 letters to be accepted': function(test) { | ||
test.ok( | ||
C.lettersAs(C.UTF8_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('a')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
C.lettersAs(C.UTF8_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('éA')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
C.lettersAs(C.UTF8_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('БAs')) | ||
.isAccepted() | ||
); | ||
test.ok( | ||
!C.letterAs(C.UTF8_LETTER) | ||
.then(F.eos) | ||
.parse(stream.ofString('Б÷As')) | ||
.isAccepted() | ||
); | ||
test.done(); | ||
}, | ||
test.ok(C.lettersAs(C.UTF8_LETTER).then(F.eos).parse(stream.ofString('a')).isAccepted()); | ||
test.ok(C.lettersAs(C.UTF8_LETTER).then(F.eos).parse(stream.ofString('éA')).isAccepted()); | ||
test.ok(C.lettersAs(C.UTF8_LETTER).then(F.eos).parse(stream.ofString('БAs')).isAccepted()); | ||
test.ok(!C.letterAs(C.UTF8_LETTER).then(F.eos).parse(stream.ofString('Б÷As')).isAccepted()); | ||
'expect unknown letters to be rejected': function(test) { | ||
const line = stream.ofString('a'); | ||
let errorFound = false; | ||
try { | ||
const combinator = C.lettersAs(Symbol('UNKNOWN')).then(F.eos); | ||
combinator.parse(line); | ||
} catch (error) { | ||
errorFound = true; | ||
} | ||
test.ok(errorFound); | ||
test.done(); | ||
}, | ||
'expect (letters) to be accepted': function (test) { | ||
'expect (letters) to be accepted': function(test) { | ||
test.expect(2); | ||
@@ -297,3 +380,3 @@ // tests here | ||
'expect (letters) with space to be rejected': function (test) { | ||
'expect (letters) with space to be rejected': function(test) { | ||
test.expect(2); | ||
@@ -309,3 +392,3 @@ // tests here | ||
'expect (letters) with number to be rejected': function (test) { | ||
'expect (letters) with number to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -320,3 +403,5 @@ // tests here | ||
'expect (letters) to return a string, not an array of letters': function (test) { | ||
'expect (letters) to return a string, not an array of letters': function( | ||
test | ||
) { | ||
test.expect(1); | ||
@@ -331,4 +416,3 @@ // tests here | ||
'expect (string) to be accepted': function (test) { | ||
'expect (string) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -344,3 +428,3 @@ // tests here | ||
'expect (string) to be rejected': function (test) { | ||
'expect (string) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -373,5 +457,5 @@ // tests here | ||
const value = parsing.value; | ||
test.equal(typeof value , 'string'); | ||
test.equal(value , 'Jack'); | ||
test.equal(parsing.offset, 'Jack'.length) | ||
test.equal(typeof value, 'string'); | ||
test.equal(value, 'Jack'); | ||
test.equal(parsing.offset, 'Jack'.length); | ||
test.done(); | ||
@@ -408,3 +492,3 @@ }, | ||
'expect (notString) to be accepted': function (test) { | ||
'expect (notString) to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -420,3 +504,3 @@ // tests here | ||
'expect (notString) to be h': function (test) { | ||
'expect (notString) to be h': function(test) { | ||
test.expect(1); | ||
@@ -432,3 +516,3 @@ // tests here | ||
'expect (notString) to be rejected': function (test) { | ||
'expect (notString) to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -444,4 +528,3 @@ // tests here | ||
'expect accent to be accepted': function (test) { | ||
'expect accent to be accepted': function(test) { | ||
test.expect(1); | ||
@@ -456,3 +539,3 @@ // tests here | ||
}, | ||
'expect cyriliq to be accepted': function (test) { | ||
'expect cyriliq to be accepted': function(test) { | ||
test.expect(2); | ||
@@ -474,3 +557,3 @@ // tests here | ||
}, | ||
'expect dash to be rejected': function (test) { | ||
'expect dash to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -485,3 +568,3 @@ // tests here | ||
}, | ||
'expect "nothing" to be rejected': function (test) { | ||
'expect "nothing" to be rejected': function(test) { | ||
test.expect(1); | ||
@@ -497,16 +580,22 @@ // tests here | ||
'expect emoji to be accepted': function (test) { | ||
'expect emoji to be accepted': function(test) { | ||
// It's super important for emoji to test there is EOS just after, | ||
// because some emoji takes two \uWXYZ codes, where utf_8 does not | ||
test.ok(! C.emoji.then(F.eos).parse(stream.ofString('б'), 0).isAccepted()); | ||
test.ok(! C.emoji.then(F.eos).parse(stream.ofString('a'), 0).isAccepted()); | ||
test.ok( | ||
!C.emoji.then(F.eos).parse(stream.ofString('б'), 0).isAccepted() | ||
); | ||
test.ok( | ||
!C.emoji.then(F.eos).parse(stream.ofString('a'), 0).isAccepted() | ||
); | ||
// multiple emojis are also accepted as one | ||
test.ok(C.emoji.then(F.eos).parse(stream.ofString('🐵🐵✈️'), 0).isAccepted()); | ||
test.ok(C.emoji.then(F.eos).parse(stream.ofString('✈️'), 0).isAccepted()); | ||
test.ok( | ||
C.emoji.then(F.eos).parse(stream.ofString('🐵🐵✈️'), 0).isAccepted() | ||
); | ||
test.ok( | ||
C.emoji.then(F.eos).parse(stream.ofString('✈️'), 0).isAccepted() | ||
); | ||
// Emoji 5.0 released in June 2017. | ||
test.ok(C.emoji.then(F.eos).parse(stream.ofString('🥪')).isAccepted()); | ||
test.done(); | ||
} | ||
}, | ||
}; |
@@ -115,4 +115,2 @@ import X from '../../../lib/standard/extractor/extractor-bundle'; | ||
'test wordsIn': function(test) { | ||
@@ -369,3 +367,3 @@ let line = stream.ofString('James Bond by Ian Fleming'); | ||
try { | ||
const parsing = combinator.parse(line); | ||
combinator.parse(line); | ||
} catch (e) { | ||
@@ -388,3 +386,3 @@ if (e === 'Input source must be a String') { | ||
try { | ||
const parsing = combinator.parse(line); | ||
combinator.parse(line); | ||
} catch (e) { | ||
@@ -391,0 +389,0 @@ if (e === 'Input source must be a String') { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1957422
21715
401