"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 }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _default = exports["default"] = {
  setUp: function setUp(done) {
    done();
  },
  'expect (char) to be accepted': function expect_Char_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').parse(_index["default"].ofString('a'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (char) to be rejected': function expect_Char_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C["char"]('a').parse(_index["default"].ofString('b'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (char) to be refused': function expect_Char_to_be_refused(test) {
    test.expect(1);
    // tests here
    test["throws"](function () {
      _index2.C["char"]('aa');
    });
    test.done();
  },
  'expect (notChar) to be accepted': function expect_NotChar_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.notChar('a').parse(_index["default"].ofString('b'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (notChar) to be rejected': function expect_NotChar_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.notChar('a').parse(_index["default"].ofString('a'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (notChar) to be refused': function expect_NotChar_to_be_refused(test) {
    test.expect(1);
    // tests here
    test["throws"](function () {
      _index2.C.notChar('aa');
    });
    test.done();
  },
  'expect (charNotIn) to be accepted': function expect_CharNotIn_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.charNotIn('a').parse(_index["default"].ofString('b'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (charNotIn) to be rejected': function expect_CharNotIn_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.charNotIn('a').parse(_index["default"].ofString('a'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (charIn) to be accepted': function expect_CharIn_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.charIn('a').parse(_index["default"].ofString('a'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (charIn) to be rejected': function expect_CharIn_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.charIn('a').parse(_index["default"].ofString('b'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (lowerCase) to be accepted': function expect_LowerCase_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.lowerCase().parse(_index["default"].ofString('a'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (lowerCase) to be rejected': function expect_LowerCase_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.lowerCase().parse(_index["default"].ofString('A'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect (upperCase) to be accepted': function expect_UpperCase_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.upperCase().parse(_index["default"].ofString('A'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (upperCase) to be rejected': function expect_UpperCase_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.upperCase().parse(_index["default"].ofString('z'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect upper (letter) to be accepted': function expect_upper_Letter_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.letter().parse(_index["default"].ofString('A'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect lower (letter) to be accepted': function expect_lower_Letter_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.letter().parse(_index["default"].ofString('z'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect space (letter) to be rejected': function expect_space_Letter_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.letter().parse(_index["default"].ofString(' '), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect non (letter) to be rejected': function expect_non_Letter_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.letter().parse(_index["default"].ofString('0'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect occidental letter to be accepted': function expect_occidental_letter_to_be_accepted(test) {
    test.ok(_index2.C.letter().parse(_index["default"].ofString('a'), 0).isAccepted());
    test.ok(_index2.C.letterAs().parse(_index["default"].ofString('a'), 0).isAccepted());
    test.ok(_index2.C.letterAs(_index2.C.OCCIDENTAL_LETTER).parse(_index["default"].ofString('a')).isAccepted());
    test.ok(_index2.C.letterAs(_index2.C.OCCIDENTAL_LETTER).parse(_index["default"].ofString('é')).isAccepted());
    test.ok(!_index2.C.letterAs(_index2.C.OCCIDENTAL_LETTER).parse(_index["default"].ofString('Б')).isAccepted());
    test.ok(!_index2.C.letterAs(_index2.C.OCCIDENTAL_LETTER).parse(_index["default"].ofString('÷')).isAccepted());
    test.done();
  },
  'expect occidental letters to be accepted': function expect_occidental_letters_to_be_accepted(test) {
    test.ok(_index2.C.letters().then(_index2.F.eos()).parse(_index["default"].ofString('aéÉ'), 0).isAccepted());
    test.ok(_index2.C.lettersAs().then(_index2.F.eos()).parse(_index["default"].ofString('aéÉ'), 0).isAccepted());
    test.ok(_index2.C.lettersAs(_index2.C.OCCIDENTAL_LETTER).parse(_index["default"].ofString('a')).isAccepted());
    test.ok(_index2.C.lettersAs(_index2.C.OCCIDENTAL_LETTER).then(_index2.F.eos()).parse(_index["default"].ofString('éA')).isAccepted());
    test.ok(!_index2.C.lettersAs(_index2.C.OCCIDENTAL_LETTER).then(_index2.F.eos()).parse(_index["default"].ofString('БAs')).isAccepted());
    test.done();
  },
  'expect ascii letter to be accepted': function expect_ascii_letter_to_be_accepted(test) {
    test.ok(_index2.C.letterAs(_index2.C.ASCII_LETTER).parse(_index["default"].ofString('a'), 0).isAccepted());
    test.ok(!_index2.C.letterAs(_index2.C.ASCII_LETTER).parse(_index["default"].ofString('é')).isAccepted());
    test.ok(!_index2.C.letterAs(_index2.C.ASCII_LETTER).parse(_index["default"].ofString('Б')).isAccepted());
    test.done();
  },
  'expect ascii letters to be accepted': function expect_ascii_letters_to_be_accepted(test) {
    test.ok(_index2.C.lettersAs(_index2.C.ASCII_LETTER).then(_index2.F.eos()).parse(_index["default"].ofString('a')).isAccepted());
    /*
                                test.ok(
                                    !C.lettersAs(C.ASCII_LETTER)
                                        .then(F.eos())
                                        .parse(Streams.ofString('éA'))
                                        .isAccepted()
                                );
                                test.ok(
                                    !C.lettersAs(C.ASCII_LETTER)
                                        .then(F.eos())
                                        .parse(Streams.ofString('БAs'))
                                        .isAccepted()
                                );*/
    test.done();
  },
  'expect utf8 letter to be accepted': function expect_utf8_letter_to_be_accepted(test) {
    test.ok(_index2.C.letterAs(_index2.C.UTF8_LETTER).parse(_index["default"].ofString('a')).isAccepted());
    test.ok(_index2.C.letterAs(_index2.C.UTF8_LETTER).parse(_index["default"].ofString('é')).isAccepted());
    test.ok(_index2.C.letterAs(_index2.C.UTF8_LETTER).parse(_index["default"].ofString('Б')).isAccepted());
    test.ok(!_index2.C.letterAs(_index2.C.UTF8_LETTER).parse(_index["default"].ofString('÷')).isAccepted());
    test.done();
  },
  'expect utf8 letters to be accepted': function expect_utf8_letters_to_be_accepted(test) {
    test.ok(_index2.C.lettersAs(_index2.C.UTF8_LETTER).then(_index2.F.eos()).parse(_index["default"].ofString('a')).isAccepted());
    test.ok(_index2.C.lettersAs(_index2.C.UTF8_LETTER).then(_index2.F.eos()).parse(_index["default"].ofString('éA')).isAccepted());
    test.ok(_index2.C.lettersAs(_index2.C.UTF8_LETTER).then(_index2.F.eos()).parse(_index["default"].ofString('БAs')).isAccepted());
    test.ok(!_index2.C.letterAs(_index2.C.UTF8_LETTER).then(_index2.F.eos()).parse(_index["default"].ofString('Б÷As')).isAccepted());
    test.done();
  },
  'expect unknown letters to be rejected': function expect_unknown_letters_to_be_rejected(test) {
    var line = _index["default"].ofString('a');
    var errorFound = false;
    try {
      var combinator = _index2.C.lettersAs(Symbol('UNKNOWN')).then(_index2.F.eos());
      combinator.parse(line);
    } catch (_unused) {
      errorFound = true;
    }
    test.ok(errorFound);
    test.done();
  },
  'expect (letters) to be accepted': function expect_Letters_to_be_accepted(test) {
    test.expect(2);
    // tests here
    var parsing = _index2.C.letters().thenLeft(_index2.F.eos()).single().parse(_index["default"].ofString('someLetters'), 0);
    test.equal(parsing.isAccepted(), true, 'should be accepted.');
    test.deepEqual(parsing.value, 'someLetters', 'should be equal.');
    test.done();
  },
  'expect (letters) with space to be rejected': function expect_Letters_with_space_to_be_rejected(test) {
    test.expect(2);
    // tests here
    var parsing = _index2.C.letters().then(_index2.F.eos()).parse(_index["default"].ofString('some Letters'), 0);
    test.equal(parsing.isAccepted(), false, 'should be rejected.');
    test.equal(parsing.offset, 4);
    test.done();
  },
  'expect (letters) with number to be rejected': function expect_Letters_with_number_to_be_rejected(test) {
    test.expect(1);
    // tests here
    var parsing = _index2.C.letters().then(_index2.F.eos()).parse(_index["default"].ofString('some2Letters'), 0);
    test.equal(parsing.isAccepted(), false, 'should be accepted.');
    test.done();
  },
  'expect (letters) to return a string, not an array of letters': function expect_Letters_to_return_a_string_not_an_array_of_letters(test) {
    test.expect(1);
    // tests here
    var parsing = _index2.C.letters().thenLeft(_index2.F.eos()).single().parse(_index["default"].ofString('someLetters'), 0);
    test.equal(parsing.value, 'someLetters', 'not a string');
    test.done();
  },
  'expect (string) to be accepted': function expect_String_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.string('Hello').parse(_index["default"].ofString('Hello'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (string) to be rejected': function expect_String_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.string('hello').parse(_index["default"].ofString('hell'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'test stringIn': function test_stringIn(test) {
    var line = _index["default"].ofString('James Bond');
    var combinator = _index2.C.stringIn(['The', 'James', 'Bond', 'series']);
    var value = combinator.parse(line).value;
    test.ok(typeof value === 'string');
    test.ok(value === 'James');
    test.done();
  },
  'test stringIn Similar': function test_stringIn_Similar(test) {
    // Checks the search comes back after each search
    var line = _index["default"].ofString('Jack James Jane');
    var combinator = _index2.C.stringIn(['Jamie', 'Jacko', 'Jack']);
    var parsing = combinator.parse(line);
    var value = parsing.value;
    test.equal(_typeof(value), 'string');
    test.equal(value, 'Jack');
    test.equal(parsing.offset, 'Jack'.length);
    test.done();
  },
  'test stringIn one string sidecase': function test_stringIn_one_string_sidecase(test) {
    var line = _index["default"].ofString('James');
    var combinator = _index2.C.stringIn(['James']);
    var value = combinator.parse(line).value;
    test.ok(typeof value === 'string');
    test.ok(value === 'James');
    test.done();
  },
  'test stringIn empty sidecase': function test_stringIn_empty_sidecase(test) {
    var line = _index["default"].ofString('James');
    var combinator = _index2.C.stringIn([]).then(_index2.F.eos());
    var parsing = combinator.parse(line);
    test.ok(!parsing.isAccepted());
    test.done();
  },
  'test stringIn empty accept nothing sidecase': function test_stringIn_empty_accept_nothing_sidecase(test) {
    var line = _index["default"].ofString('');
    var combinator = _index2.C.stringIn([]).then(_index2.F.eos());
    var parsing = combinator.parse(line);
    test.ok(parsing.isAccepted());
    test.done();
  },
  'expect (notString) to be accepted': function expect_NotString_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.notString('**').parse(_index["default"].ofString('hello'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect (notString) to be h': function expect_NotString_to_be_h(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.notString('**').parse(_index["default"].ofString('hello'), 0).value, 'h', 'should be h.');
    test.done();
  },
  'expect (notString) to be rejected': function expect_NotString_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.notString('**').parse(_index["default"].ofString('**hello'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect accent to be accepted': function expect_accent_to_be_accepted(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.utf8Letter().parse(_index["default"].ofString('é'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect cyriliq to be accepted': function expect_cyriliq_to_be_accepted(test) {
    test.expect(2);
    // tests here
    //Белград
    //български
    test.equal(_index2.C.utf8Letter().parse(_index["default"].ofString('Б'), 0).isAccepted(), true, 'should be accepted.');
    test.equal(_index2.C.utf8Letter().parse(_index["default"].ofString('б'), 0).isAccepted(), true, 'should be accepted.');
    test.done();
  },
  'expect dash to be rejected': function expect_dash_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.utf8Letter().parse(_index["default"].ofString('-'), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect "nothing" to be rejected': function expect_Nothing_to_be_rejected(test) {
    test.expect(1);
    // tests here
    test.equal(_index2.C.utf8Letter().parse(_index["default"].ofString(''), 0).isAccepted(), false, 'should be rejected.');
    test.done();
  },
  'expect emoji to be accepted': function expect_emoji_to_be_accepted(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(!_index2.C.emoji().then(_index2.F.eos()).parse(_index["default"].ofString('б'), 0).isAccepted());
    test.ok(!_index2.C.emoji().then(_index2.F.eos()).parse(_index["default"].ofString('a'), 0).isAccepted());
    // multiple emojis are also accepted as one
    test.ok(_index2.C.emoji().then(_index2.F.eos()).parse(_index["default"].ofString('🐵🐵✈️'), 0).isAccepted());
    test.ok(_index2.C.emoji().then(_index2.F.eos()).parse(_index["default"].ofString('✈️'), 0).isAccepted());
    // Emoji 5.0 released in June 2017.
    test.ok(_index2.C.emoji().then(_index2.F.eos()).parse(_index["default"].ofString('🥪')).isAccepted());
    test.done();
  },
  'expect subString to works': function expect_subString_to_works(test) {
    var stream = _index["default"].ofString('James Bond');
    var parser = _index2.C.subString(6).then(_index2.C.string('Bond'));
    var response = parser.parse(stream);
    test.deepEqual(['James ', 'Bond'], response.value.array()); // Unlike F.subStream, C.subString joins result

    test.ok(response.isEos());
    test.done();
  }
};
//# sourceMappingURL=chars-bundle-test.js.map