"use strict";

var _vitest = require("vitest");
var _index = _interopRequireDefault(require("../../lib/stream/index"));
var _index2 = require("../../lib/parsec/index");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
(0, _vitest.describe)('Parser Core Default Tests', function () {
  (0, _vitest.it)('expect (map) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').map(function (a) {
      return a + 'b';
    }).parse(_index["default"].ofString('a')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (map) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').map(function (a) {
      return a + 'b';
    }).parse(_index["default"].ofString('b')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (map) to be return ab', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').map(function (a) {
      return a + 'b';
    }).parse(_index["default"].ofString('a')).value).toBe('ab');
  });
  (0, _vitest.it)('expect (flatMap) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').flatMap(function () {
      return _index2.F.returns('b');
    }).parse(_index["default"].ofString('a')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (flatMap) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').flatMap(function () {
      return _index2.F.returns('b');
    }).parse(_index["default"].ofString('b')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (flatMap) to be return ab', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').flatMap(function () {
      return _index2.C["char"]('b');
    }).parse(_index["default"].ofString('ab')).value).toBe('b');
  });
  (0, _vitest.it)('expect (flatMap) to be return a-b-c', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').flatMap(function (aVal) {
      return _index2.C["char"]('b').then(_index2.C["char"]('c')).map(function (bcVal) {
        return aVal + '-' + bcVal.join('-');
      });
    }).parse(_index["default"].ofString('abc')).value).toBe('a-b-c');
  });
  (0, _vitest.it)('expect (filter) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').filter(function (a) {
      return a === 'a';
    }).parse(_index["default"].ofString('a')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (filter) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').filter(function (a) {
      return a === 'b';
    }).parse(_index["default"].ofString('a')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (match) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').match('a').parse(_index["default"].ofString('a')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (match) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').match('b').parse(_index["default"].ofString('a')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (then) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').then(_index2.C["char"]('b')).parse(_index["default"].ofString('ab')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (then) to be build [a,b]', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').then(_index2.C["char"]('b')).array().parse(_index["default"].ofString('ab')).value).toEqual(['a', 'b']);
  });
  (0, _vitest.it)('expect (then) left to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').then(_index2.C["char"]('b')).parse(_index["default"].ofString('cb')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (then) right to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').then(_index2.C["char"]('b')).parse(_index["default"].ofString('ac')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (then) to return [a,b]', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').then(_index2.C["char"]('b')).array().parse(_index["default"].ofString('ab')).value).toEqual(['a', 'b']);
  });
  (0, _vitest.it)('expect (thenLeft) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').thenLeft(_index2.C["char"]('b')).parse(_index["default"].ofString('ab')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (thenLeft) to return a', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').thenLeft(_index2.C["char"]('b')).single().parse(_index["default"].ofString('ab')).value).toBe('a');
  });
  (0, _vitest.it)('expect (thenLeft) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').thenLeft(_index2.C["char"]('b')).parse(_index["default"].ofString('b')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (thenRight) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').thenRight(_index2.C["char"]('b')).parse(_index["default"].ofString('ab')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (thenRight) to return a', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').thenRight(_index2.C["char"]('b')).single().parse(_index["default"].ofString('ab')).value).toBe('b');
  });
  (0, _vitest.it)('expect (thenRight) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').thenRight(_index2.C["char"]('b')).parse(_index["default"].ofString('b')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (returns) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').returns('b').parse(_index["default"].ofString('ab')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (returns) to return b', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').returns('b').parse(_index["default"].ofString('ab')).value).toBe('b');
  });
  (0, _vitest.it)('expect (returns) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').returns('b').parse(_index["default"].ofString('b')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (or) to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('a')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (or) bis to be accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('b')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (or) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('c')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (or) LL(1) to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').then(_index2.C["char"]('b')).or(_index2.C["char"]('a')).parse(_index["default"].ofString('ac')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (or) to return a', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('a')).value).toBe('a');
  });
  (0, _vitest.it)('expect (or) to return b', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('b')).value).toBe('b');
  });
  (0, _vitest.it)('expect (then.or) left to be rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').then(_index2.C["char"]('b').or(_index2.C["char"]('c'))).parse(_index["default"].ofString('ad')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (then.or) left to be consumed', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').then(_index2.C["char"]('b').or(_index2.C["char"]('c'))).parse(_index["default"].ofString('ad')).consumed).toBe(true);
  });
  (0, _vitest.it)('expect (opt) some to accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').opt().parse(_index["default"].ofString('a')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (opt) some to return some a', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').opt().parse(_index["default"].ofString('a')).value.get()).toBe('a');
  });
  (0, _vitest.it)('expect (opt) none to accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').opt().parse(_index["default"].ofString('b')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (opt) none to return none', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').opt().parse(_index["default"].ofString('b')).value.isPresent()).toBe(false);
  });
  (0, _vitest.it)('expect (opt) to come back if fail', function () {
    (0, _vitest.expect)(_index2.C["char"]('b').then(_index2.C.string('aaFAIL').opt().drop()).then(_index2.C.string('aaab')).parse(_index["default"].ofString('baaab')).value.join('')).toBe('baaab');
  });
  (0, _vitest.it)('expect (rep) to accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').rep().parse(_index["default"].ofString('a')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (rep) to rejected', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').rep().parse(_index["default"].ofString('b')).isAccepted()).toBe(false);
  });
  (0, _vitest.it)('expect (rep) mutiple to accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').rep().parse(_index["default"].ofString('aaaabbb')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (rep) mutiple to return [a,a,a,a]', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').rep().parse(_index["default"].ofString('aaaabbb')).value.array()).toEqual(['a', 'a', 'a', 'a']);
  });
  (0, _vitest.it)('expect (optrep) to accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('a')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (optrep) none to accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('b')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (optrep) multiple to accepted', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('aaaabbb')).isAccepted()).toBe(true);
  });
  (0, _vitest.it)('expect (optrep) multiple to return some [a,a,a,a]', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('aaaabbb')).value.array()).toEqual(['a', 'a', 'a', 'a']);
  });
  (0, _vitest.it)('expect (optrep) to return none', function () {
    (0, _vitest.expect)(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('bbb')).value.array()).toEqual([]);
  });
  (0, _vitest.it)('expect (optrep) to return [b,b,b]', function () {
    (0, _vitest.expect)(_index2.C.notChar('a').optrep().parse(_index["default"].ofString('bbba')).value.array()).toEqual(['b', 'b', 'b']);
  });
});
//# sourceMappingURL=parser_core_default_test.spec.js.map