"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _index = _interopRequireDefault(require("../../lib/stream/index"));
var _index2 = require("../../lib/parsec/index");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/*
  ======== A Handy Little Nodeunit Reference ========
  https://github.com/caolan/nodeunit

  Test methods:
    test.expect(numAssertions)
    test.done()
  Test assertions:
    test.ok(value, [message])
    test.equal(actual, expected, [message])
    test.notEqual(actual, expected, [message])
    test.deepEqual(actual, expected, [message])
    test.notDeepEqual(actual, expected, [message])
    test.strictEqual(actual, expected, [message])
    test.notStrictEqual(actual, expected, [message])
    test.throws(block, [error], [message])
    test.doesNotThrow(block, [error], [message])
    test.ifError(value)
*/
var _default = exports["default"] = {
  setUp: function setUp(done) {
    done();
  },
  'expect (map) to be accepted': function expect_Map_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').map(function (a) {
      return a + 'b';
    }).parse(_index["default"].ofString('a')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (map) to be rejected': function expect_Map_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').map(function (a) {
      return a + 'b';
    }).parse(_index["default"].ofString('b')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (map) to be return ab': function expect_Map_to_be_return_ab(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').map(function (a) {
      return a + 'b';
    }).parse(_index["default"].ofString('a')).value, 'ab', 'should be accepted.');
    test.done();
  },
  'expect (flatMap) to be accepted': function expect_FlatMap_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').flatMap(function () {
      return _index2.F.returns('b');
    }).parse(_index["default"].ofString('a')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (flatMap) to be rejected ': function expect_FlatMap_to_be_rejected_(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').flatMap(function () {
      return _index2.F.returns('b');
    }).parse(_index["default"].ofString('b')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (flatMap) to be return ab': function expect_FlatMap_to_be_return_ab(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').flatMap(function () {
      return _index2.C["char"]('b');
    }).parse(_index["default"].ofString('ab')).value, 'b', 'should be accepted.');
    test.done();
  },
  'expect (flatMap) to be return a-b-c': function expect_FlatMap_to_be_return_aBC(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').flatMap(function (aVal) {
      return _index2.C["char"]('b').then(_index2.C["char"]('c')).map(function (bcVal) {
        return aVal + '-' + bcVal.join('-');
      });
    }) //--> join 3 letters
    .parse(_index["default"].ofString('abc')).value, 'a-b-c', 'should be accepted.');
    test.done();
  },
  'expect (filter) to be accepted': function expect_Filter_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').filter(function (a) {
      return a === 'a';
    }).parse(_index["default"].ofString('a')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (filter) to be rejected': function expect_Filter_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').filter(function (a) {
      return a === 'b';
    }).parse(_index["default"].ofString('a')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (match) to be accepted': function expect_Match_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').match('a').parse(_index["default"].ofString('a')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (match) to be rejected': function expect_Match_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').match('b').parse(_index["default"].ofString('a')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (then) to be accepted': function expect_Then_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').then(_index2.C["char"]('b')).parse(_index["default"].ofString('ab')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (then) to be build [a,b]': function expect_Then_to_be_build_AB(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').then(_index2.C["char"]('b')).array().parse(_index["default"].ofString('ab')).value, ['a', 'b'], 'should be accepted.');
    test.done();
  },
  'expect (then) left to be rejected': function expect_Then_left_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').then(_index2.C["char"]('b')).parse(_index["default"].ofString('cb')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (then) right to be rejected': function expect_Then_right_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').then(_index2.C["char"]('b')).parse(_index["default"].ofString('ac')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (then) to return [a,b]': function expect_Then_to_return_AB(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').then(_index2.C["char"]('b')).array().parse(_index["default"].ofString('ab')).value, ['a', 'b'], 'should be accepted.');
    test.done();
  },
  'expect (thenLeft) to be accepted': function expect_ThenLeft_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').thenLeft(_index2.C["char"]('b')).parse(_index["default"].ofString('ab')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (thenLeft) to return a': function expect_ThenLeft_to_return_a(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').thenLeft(_index2.C["char"]('b')).single().parse(_index["default"].ofString('ab')).value, 'a', 'should be accepted.');
    test.done();
  },
  'expect (thenLeft) to be rejected': function expect_ThenLeft_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').thenLeft(_index2.C["char"]('b')).parse(_index["default"].ofString('b')).isAccepted(), false, 'should be accepted.');
    test.done();
  },
  'expect (thenRight) to be accepted': function expect_ThenRight_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').thenRight(_index2.C["char"]('b')).parse(_index["default"].ofString('ab')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (thenRight) to return a': function expect_ThenRight_to_return_a(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').thenRight(_index2.C["char"]('b')).single().parse(_index["default"].ofString('ab')).value, 'b', 'should be accepted.');
    test.done();
  },
  'expect (thenRight) to be rejected': function expect_ThenRight_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').thenRight(_index2.C["char"]('b')).parse(_index["default"].ofString('b')).isAccepted(), false, 'should be accepted.');
    test.done();
  },
  'expect (returns) to be accepted': function expect_Returns_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').returns('b').parse(_index["default"].ofString('ab')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (returns) to return b': function expect_Returns_to_return_b(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').returns('b').parse(_index["default"].ofString('ab')).value, 'b', 'should be accepted.');
    test.done();
  },
  'expect (returns) to be rejected': function expect_Returns_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').returns('b').parse(_index["default"].ofString('b')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (or) to be accepted': function expect_Or_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('a')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (or) bis to be accepted': function expect_Or_bis_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('b')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (or) to be rejected': function expect_Or_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('c')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (or) LL(1) to be rejected': function expect_Or_LL1_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').then(_index2.C["char"]('b')).or(_index2.C["char"]('a')).parse(_index["default"].ofString('ac')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (or) to return a': function expect_Or_to_return_a(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('a')).value, 'a', 'should be accepted.');
    test.done();
  },
  'expect (or) to return b': function expect_Or_to_return_b(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').or(_index2.C["char"]('b')).parse(_index["default"].ofString('b')).value, 'b', 'should be accepted.');
    test.done();
  },
  'expect (then.or) left to be rejected': function expect_ThenOr_left_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').then(_index2.C["char"]('b').or(_index2.C["char"]('c'))).parse(_index["default"].ofString('ad')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (then.or) left to be consumed': function expect_ThenOr_left_to_be_consumed(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').then(_index2.C["char"]('b').or(_index2.C["char"]('c'))).parse(_index["default"].ofString('ad')).consumed, true, 'should be consumed.');
    test.done();
  },
  'expect (opt) some to accepted': function expect_Opt_some_to_accepted(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').opt().parse(_index["default"].ofString('a')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (opt) some to return some a': function expect_Opt_some_to_return_some_a(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').opt().parse(_index["default"].ofString('a')).value.get(), 'a', 'should be a.');
    test.done();
  },
  'expect (opt) none to accepted': function expect_Opt_none_to_accepted(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').opt().parse(_index["default"].ofString('b')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (opt) none to return none': function expect_Opt_none_to_return_none(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').opt().parse(_index["default"].ofString('b')).value.isPresent(), false, 'should be accepted but none.');
    test.done();
  },
  'expect (opt) to come back if fail': function expect_Opt_to_come_back_if_fail(test) {
    test.expect(1);
    // tests here
    test.equals(_index2.C["char"]('b').then(_index2.C.string('aaFAIL').opt().drop()).then(_index2.C.string('aaab')).parse(_index["default"].ofString('baaab')).value.join(''), 'baaab');
    test.done();
  },
  'expect (rep) to accepted': function expect_Rep_to_accepted(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').rep().parse(_index["default"].ofString('a')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (rep) to rejected': function expect_Rep_to_rejected(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').rep().parse(_index["default"].ofString('b')).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (rep) mutiple to accepted': function expect_Rep_mutiple_to_accepted(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').rep().parse(_index["default"].ofString('aaaabbb')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (rep) mutiple to return [a,a,a,a]': function expect_Rep_mutiple_to_return_AAAA(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').rep().parse(_index["default"].ofString('aaaabbb')).value.array(), ['a', 'a', 'a', 'a'], 'should be accepted.');
    test.done();
  },
  'expect (optrep) to accepted': function expect_Optrep_to_accepted(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('a')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (optrep) none to accepted': function expect_Optrep_none_to_accepted(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('b')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (optrep) multiple to accepted': function expect_Optrep_multiple_to_accepted(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('aaaabbb')).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (optrep) multiple to return some [a,a,a,a]': function expect_Optrep_multiple_to_return_some_AAAA(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('aaaabbb')).value.array(), ['a', 'a', 'a', 'a'], 'should be accepted.');
    test.done();
  },
  'expect (optrep) to return none': function expect_Optrep_to_return_none(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C["char"]('a').optrep().parse(_index["default"].ofString('bbb')).value.array(), [], 'should be accepted.');
    test.done();
  },
  'expect (optrep) to return [b,b,b]': function expect_Optrep_to_return_BBB(test) {
    test.expect(1);
    // tests here
    test.deepEqual(_index2.C.notChar('a').optrep().parse(_index["default"].ofString('bbba')).value.array(), ['b', 'b', 'b'], 'should be accepted.');
    test.done();
  }
};
//# sourceMappingURL=parser_core_default_test.js.map