How to use matchToken method in Cucumber-gherkin

Best JavaScript code snippet using cucumber-gherkin

pattern_test.js

Source:pattern_test.js Github

copy

Full Screen

...31function testStartTag() {32 var pattern = new goog.dom.pattern.StartTag('DIV');33 assertEquals(34 'StartTag(div) should match div', goog.dom.pattern.MatchType.MATCH,35 pattern.matchToken(36 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));37 assertEquals(38 'StartTag(div) should not match span',39 goog.dom.pattern.MatchType.NO_MATCH,40 pattern.matchToken(41 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));42 assertEquals(43 'StartTag(div) should not match /div',44 goog.dom.pattern.MatchType.NO_MATCH,45 pattern.matchToken(46 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));47}48function testStartTagCase() {49 var pattern = new goog.dom.pattern.StartTag('diV');50 assertEquals(51 'StartTag(diV) should match div', goog.dom.pattern.MatchType.MATCH,52 pattern.matchToken(53 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));54 assertEquals(55 'StartTag(diV) should not match span',56 goog.dom.pattern.MatchType.NO_MATCH,57 pattern.matchToken(58 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));59}60function testStartTagRegex() {61 var pattern = new goog.dom.pattern.StartTag(/D/);62 assertEquals(63 'StartTag(/D/) should match div', goog.dom.pattern.MatchType.MATCH,64 pattern.matchToken(65 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));66 assertEquals(67 'StartTag(/D/) should not match span',68 goog.dom.pattern.MatchType.NO_MATCH,69 pattern.matchToken(70 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));71 assertEquals(72 'StartTag(/D/) should not match /div',73 goog.dom.pattern.MatchType.NO_MATCH,74 pattern.matchToken(75 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));76}77function testStartTagAttributes() {78 var pattern = new goog.dom.pattern.StartTag('DIV', {id: 'div1'});79 assertEquals(80 'StartTag(div,id:div1) should match div1',81 goog.dom.pattern.MatchType.MATCH,82 pattern.matchToken(83 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));84 assertEquals(85 'StartTag(div,id:div2) should not match div1',86 goog.dom.pattern.MatchType.NO_MATCH,87 pattern.matchToken(88 goog.dom.getElement('div2'), goog.dom.TagWalkType.START_TAG));89}90function testStartTagStyle() {91 var pattern = new goog.dom.pattern.StartTag('SPAN', null, {color: 'red'});92 assertEquals(93 'StartTag(span,null,color:red) should match span1',94 goog.dom.pattern.MatchType.MATCH,95 pattern.matchToken(96 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));97 assertEquals(98 'StartTag(span,null,color:blue) should not match span1',99 goog.dom.pattern.MatchType.NO_MATCH,100 pattern.matchToken(101 goog.dom.getElement('span2'), goog.dom.TagWalkType.START_TAG));102}103function testStartTagAttributeRegex() {104 var pattern = new goog.dom.pattern.StartTag('SPAN', {id: /span\d/});105 assertEquals(106 'StartTag(span,id:/span\\d/) should match span1',107 goog.dom.pattern.MatchType.MATCH,108 pattern.matchToken(109 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));110 assertEquals(111 'StartTag(span,id:/span\\d/) should match span2',112 goog.dom.pattern.MatchType.MATCH,113 pattern.matchToken(114 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));115}116function testEndTag() {117 var pattern = new goog.dom.pattern.EndTag('DIV');118 assertEquals(119 'EndTag should match div', goog.dom.pattern.MatchType.MATCH,120 pattern.matchToken(121 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));122}123function testEndTagRegex() {124 var pattern = new goog.dom.pattern.EndTag(/D/);125 assertEquals(126 'EndTag(/D/) should match /div', goog.dom.pattern.MatchType.MATCH,127 pattern.matchToken(128 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));129 assertEquals(130 'EndTag(/D/) should not match /span', goog.dom.pattern.MatchType.NO_MATCH,131 pattern.matchToken(132 goog.dom.getElement('span1'), goog.dom.TagWalkType.END_TAG));133 assertEquals(134 'EndTag(/D/) should not match div', goog.dom.pattern.MatchType.NO_MATCH,135 pattern.matchToken(136 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));137}138function testChildMatches() {139 var pattern = new goog.dom.pattern.ChildMatches(140 new goog.dom.pattern.StartTag('DIV'), 2);141 assertEquals(142 'ChildMatches should match div', goog.dom.pattern.MatchType.MATCHING,143 pattern.matchToken(144 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));145 assertEquals(146 'ChildMatches should match /div', goog.dom.pattern.MatchType.MATCHING,147 pattern.matchToken(148 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));149 assertEquals(150 'ChildMatches should match div', goog.dom.pattern.MatchType.MATCHING,151 pattern.matchToken(152 goog.dom.getElement('div2'), goog.dom.TagWalkType.START_TAG));153 assertEquals(154 'ChildMatches should match /div', goog.dom.pattern.MatchType.MATCHING,155 pattern.matchToken(156 goog.dom.getElement('div2'), goog.dom.TagWalkType.END_TAG));157 assertEquals(158 'ChildMatches should finish match at /body',159 goog.dom.pattern.MatchType.BACKTRACK_MATCH,160 pattern.matchToken(document.body, goog.dom.TagWalkType.END_TAG));161 assertEquals(162 'ChildMatches should match div', goog.dom.pattern.MatchType.MATCHING,163 pattern.matchToken(164 goog.dom.getElement('div2'), goog.dom.TagWalkType.START_TAG));165 assertEquals(166 'ChildMatches should match /div', goog.dom.pattern.MatchType.MATCHING,167 pattern.matchToken(168 goog.dom.getElement('div2'), goog.dom.TagWalkType.END_TAG));169 assertEquals(170 'ChildMatches should fail to match at /body: not enough child matches',171 goog.dom.pattern.MatchType.NO_MATCH,172 pattern.matchToken(document.body, goog.dom.TagWalkType.END_TAG));173}174function testFullTag() {175 var pattern = new goog.dom.pattern.FullTag('DIV');176 assertEquals(177 'FullTag(div) should match div', goog.dom.pattern.MatchType.MATCHING,178 pattern.matchToken(179 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));180 assertEquals(181 'FullTag(div) should match /div', goog.dom.pattern.MatchType.MATCH,182 pattern.matchToken(183 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));184 assertEquals(185 'FullTag(div) should start match at div',186 goog.dom.pattern.MatchType.MATCHING,187 pattern.matchToken(188 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));189 assertEquals(190 'FullTag(div) should continue to match span',191 goog.dom.pattern.MatchType.MATCHING,192 pattern.matchToken(193 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));194 assertEquals(195 'FullTag(div) should continue to match /span',196 goog.dom.pattern.MatchType.MATCHING,197 pattern.matchToken(198 goog.dom.getElement('span1'), goog.dom.TagWalkType.END_TAG));199 assertEquals(200 'FullTag(div) should finish match at /div',201 goog.dom.pattern.MatchType.MATCH,202 pattern.matchToken(203 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));204}205function testAllChildren() {206 var pattern = new goog.dom.pattern.AllChildren();207 assertEquals(208 'AllChildren(div) should match div', goog.dom.pattern.MatchType.MATCHING,209 pattern.matchToken(210 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));211 assertEquals(212 'AllChildren(div) should match /div', goog.dom.pattern.MatchType.MATCHING,213 pattern.matchToken(214 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));215 assertEquals(216 'AllChildren(div) should match at /body',217 goog.dom.pattern.MatchType.BACKTRACK_MATCH,218 pattern.matchToken(document.body, goog.dom.TagWalkType.END_TAG));219 assertEquals(220 'AllChildren(div) should start match at div',221 goog.dom.pattern.MatchType.MATCHING,222 pattern.matchToken(223 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));224 assertEquals(225 'AllChildren(div) should continue to match span',226 goog.dom.pattern.MatchType.MATCHING,227 pattern.matchToken(228 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));229 assertEquals(230 'AllChildren(div) should continue to match /span',231 goog.dom.pattern.MatchType.MATCHING,232 pattern.matchToken(233 goog.dom.getElement('span1'), goog.dom.TagWalkType.END_TAG));234 assertEquals(235 'AllChildren(div) should continue to match at /div',236 goog.dom.pattern.MatchType.MATCHING,237 pattern.matchToken(238 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));239 assertEquals(240 'AllChildren(div) should finish match at /body',241 goog.dom.pattern.MatchType.BACKTRACK_MATCH,242 pattern.matchToken(document.body, goog.dom.TagWalkType.END_TAG));243}244function testText() {245 var pattern = new goog.dom.pattern.Text('Text');246 assertEquals(247 'Text should match div3/text()', goog.dom.pattern.MatchType.MATCH,248 pattern.matchToken(249 goog.dom.getElement('div3').firstChild, goog.dom.TagWalkType.OTHER));250 assertEquals(251 'Text should not match div4/text()', goog.dom.pattern.MatchType.NO_MATCH,252 pattern.matchToken(253 goog.dom.getElement('div4').firstChild, goog.dom.TagWalkType.OTHER));254 assertEquals(255 'Text should not match div3', goog.dom.pattern.MatchType.NO_MATCH,256 pattern.matchToken(257 goog.dom.getElement('div3'), goog.dom.TagWalkType.START_TAG));258}259function testTextRegex() {260 var pattern = new goog.dom.pattern.Text(/Text/);261 assertEquals(262 'Text(regex) should match div3/text()', goog.dom.pattern.MatchType.MATCH,263 pattern.matchToken(264 goog.dom.getElement('div3').firstChild, goog.dom.TagWalkType.OTHER));265 assertEquals(266 'Text(regex) should match div4/text()', goog.dom.pattern.MatchType.MATCH,267 pattern.matchToken(268 goog.dom.getElement('div4').firstChild, goog.dom.TagWalkType.OTHER));269}270function testNodeType() {271 var pattern = new goog.dom.pattern.NodeType(goog.dom.NodeType.COMMENT);272 assertEquals(273 'Comment matcher should match a comment',274 goog.dom.pattern.MatchType.MATCH,275 pattern.matchToken(276 goog.dom.getElement('nodeTypes').firstChild,277 goog.dom.TagWalkType.OTHER));278 assertEquals(279 'Comment matcher should not match a text node',280 goog.dom.pattern.MatchType.NO_MATCH,281 pattern.matchToken(282 goog.dom.getElement('nodeTypes').lastChild,283 goog.dom.TagWalkType.OTHER));284}285function testSequence() {286 var pattern = new goog.dom.pattern.Sequence([287 new goog.dom.pattern.StartTag('DIV'), new goog.dom.pattern.StartTag('SPAN'),288 new goog.dom.pattern.EndTag('SPAN'), new goog.dom.pattern.EndTag('DIV')289 ]);290 assertEquals(291 'Sequence[0] should match div1', goog.dom.pattern.MatchType.MATCHING,292 pattern.matchToken(293 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));294 assertEquals(295 'Sequence[1] should match span1', goog.dom.pattern.MatchType.MATCHING,296 pattern.matchToken(297 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));298 assertEquals(299 'Sequence[2] should match /span1', goog.dom.pattern.MatchType.MATCHING,300 pattern.matchToken(301 goog.dom.getElement('span1'), goog.dom.TagWalkType.END_TAG));302 assertEquals(303 'Sequence[3] should match /div1', goog.dom.pattern.MatchType.MATCH,304 pattern.matchToken(305 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));306 assertEquals(307 'Sequence[0] should match div1 again',308 goog.dom.pattern.MatchType.MATCHING,309 pattern.matchToken(310 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));311 assertEquals(312 'Sequence[1] should match span1 again',313 goog.dom.pattern.MatchType.MATCHING,314 pattern.matchToken(315 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));316 assertEquals(317 'Sequence[2] should match /span1 again',318 goog.dom.pattern.MatchType.MATCHING,319 pattern.matchToken(320 goog.dom.getElement('span1'), goog.dom.TagWalkType.END_TAG));321 assertEquals(322 'Sequence[3] should match /div1 again', goog.dom.pattern.MatchType.MATCH,323 pattern.matchToken(324 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));325 assertEquals(326 'Sequence[0] should match div1', goog.dom.pattern.MatchType.MATCHING,327 pattern.matchToken(328 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));329 assertEquals(330 'Sequence[1] should not match div1', goog.dom.pattern.MatchType.NO_MATCH,331 pattern.matchToken(332 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));333 assertEquals(334 'Sequence[0] should match div1 after failure',335 goog.dom.pattern.MatchType.MATCHING,336 pattern.matchToken(337 goog.dom.getElement('div1'), goog.dom.TagWalkType.START_TAG));338 assertEquals(339 'Sequence[1] should match span1 after failure',340 goog.dom.pattern.MatchType.MATCHING,341 pattern.matchToken(342 goog.dom.getElement('span1'), goog.dom.TagWalkType.START_TAG));343 assertEquals(344 'Sequence[2] should match /span1 after failure',345 goog.dom.pattern.MatchType.MATCHING,346 pattern.matchToken(347 goog.dom.getElement('span1'), goog.dom.TagWalkType.END_TAG));348 assertEquals(349 'Sequence[3] should match /div1 after failure',350 goog.dom.pattern.MatchType.MATCH,351 pattern.matchToken(352 goog.dom.getElement('div1'), goog.dom.TagWalkType.END_TAG));353}354function testRepeat() {355 var pattern = new goog.dom.pattern.Repeat(new goog.dom.pattern.StartTag('B'));356 // Note: this test does not mimic an actual matcher because it is only357 // passing the START_TAG events.358 assertEquals(359 'Repeat[B] should match b1', goog.dom.pattern.MatchType.MATCHING,360 pattern.matchToken(361 goog.dom.getElement('b1'), goog.dom.TagWalkType.START_TAG));362 assertEquals(363 'Repeat[B] should match b2', goog.dom.pattern.MatchType.MATCHING,364 pattern.matchToken(365 goog.dom.getElement('b2'), goog.dom.TagWalkType.START_TAG));366 assertEquals(367 'Repeat[B] should backtrack match i1',368 goog.dom.pattern.MatchType.BACKTRACK_MATCH,369 pattern.matchToken(370 goog.dom.getElement('i1'), goog.dom.TagWalkType.START_TAG));371 assertEquals('Repeat[B] should have match count of 2', 2, pattern.count);372 assertEquals(373 'Repeat[B] should backtrack match i1 even with no b matches',374 goog.dom.pattern.MatchType.BACKTRACK_MATCH,375 pattern.matchToken(376 goog.dom.getElement('i1'), goog.dom.TagWalkType.START_TAG));377 assertEquals('Repeat[B] should have match count of 0', 0, pattern.count);378}379function testRepeatWithMinimum() {380 var pattern =381 new goog.dom.pattern.Repeat(new goog.dom.pattern.StartTag('B'), 1);382 // Note: this test does not mimic an actual matcher because it is only383 // passing the START_TAG events.384 assertEquals(385 'Repeat[B,1] should match b1', goog.dom.pattern.MatchType.MATCHING,386 pattern.matchToken(387 goog.dom.getElement('b1'), goog.dom.TagWalkType.START_TAG));388 assertEquals(389 'Repeat[B,1] should match b2', goog.dom.pattern.MatchType.MATCHING,390 pattern.matchToken(391 goog.dom.getElement('b2'), goog.dom.TagWalkType.START_TAG));392 assertEquals(393 'Repeat[B,1] should backtrack match i1',394 goog.dom.pattern.MatchType.BACKTRACK_MATCH,395 pattern.matchToken(396 goog.dom.getElement('i1'), goog.dom.TagWalkType.START_TAG));397 assertEquals('Repeat[B,1] should have match count of 2', 2, pattern.count);398 assertEquals(399 'Repeat[B,1] should not match i1', goog.dom.pattern.MatchType.NO_MATCH,400 pattern.matchToken(401 goog.dom.getElement('i1'), goog.dom.TagWalkType.START_TAG));402}403function testRepeatWithMaximum() {404 var pattern =405 new goog.dom.pattern.Repeat(new goog.dom.pattern.StartTag('B'), 1, 1);406 // Note: this test does not mimic an actual matcher because it is only407 // passing the START_TAG events.408 assertEquals(409 'Repeat[B,1] should match b1', goog.dom.pattern.MatchType.MATCH,410 pattern.matchToken(411 goog.dom.getElement('b1'), goog.dom.TagWalkType.START_TAG));412}413function testSequenceBacktrack() {414 var pattern = new goog.dom.pattern.Sequence([415 new goog.dom.pattern.Repeat(new goog.dom.pattern.StartTag('SPAN')),416 new goog.dom.pattern.Text('X')417 ]);418 var root = goog.dom.getElement('span3');419 assertEquals(420 'Sequence[Repeat[SPAN],"X"] should match span3',421 goog.dom.pattern.MatchType.MATCHING,422 pattern.matchToken(root, goog.dom.TagWalkType.START_TAG));423 assertEquals(424 'Sequence[Repeat[SPAN],"X"] should match span3.firstChild',425 goog.dom.pattern.MatchType.MATCHING,426 pattern.matchToken(root.firstChild, goog.dom.TagWalkType.START_TAG));427 assertEquals(428 'Sequence[Repeat[SPAN],"X"] should match span3.firstChild.firstChild',429 goog.dom.pattern.MatchType.MATCHING,430 pattern.matchToken(431 root.firstChild.firstChild, goog.dom.TagWalkType.START_TAG));432 assertEquals(433 'Sequence[Repeat[SPAN],"X"] should finish match text node',434 goog.dom.pattern.MatchType.MATCH,435 pattern.matchToken(436 root.firstChild.firstChild.firstChild, goog.dom.TagWalkType.OTHER));...

Full Screen

Full Screen

jquery.inputmask.regex.extensions.js

Source:jquery.inputmask.regex.extensions.js Github

copy

Full Screen

1/*!2* jquery.inputmask.regex.extensions.js3* http://github.com/RobinHerbots/jquery.inputmask4* Copyright (c) 2010 - 2014 Robin Herbots5* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)6* Version: 3.1.347*/8!function(factory) {9 "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);10}(function($) {11 return $.extend($.inputmask.defaults.aliases, {12 Regex: {13 mask: "r",14 greedy: !1,15 repeat: "*",16 regex: null,17 regexTokens: null,18 tokenizer: /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,19 quantifierFilter: /[0-9]+[^,]/,20 isComplete: function(buffer, opts) {21 return new RegExp(opts.regex).test(buffer.join(""));22 },23 definitions: {24 r: {25 validator: function(chrs, maskset, pos, strict, opts) {26 function regexToken(isGroup, isQuantifier) {27 this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1, 28 this.quantifier = {29 min: 1,30 max: 131 }, this.repeaterPart = void 0;32 }33 function analyseRegex() {34 var match, m, currentToken = new regexToken(), opengroups = [];35 for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) switch (m = match[0], 36 m.charAt(0)) {37 case "(":38 opengroups.push(new regexToken(!0));39 break;40 case ")":41 var groupToken = opengroups.pop();42 opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);43 break;44 case "{":45 case "+":46 case "*":47 var quantifierToken = new regexToken(!1, !0);48 m = m.replace(/[{}]/g, "");49 var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 == mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);50 if (quantifierToken.quantifier = {51 min: mq0,52 max: mq153 }, opengroups.length > 0) {54 var matches = opengroups[opengroups.length - 1].matches;55 if (match = matches.pop(), !match.isGroup) {56 var groupToken = new regexToken(!0);57 groupToken.matches.push(match), match = groupToken;58 }59 matches.push(match), matches.push(quantifierToken);60 } else {61 if (match = currentToken.matches.pop(), !match.isGroup) {62 var groupToken = new regexToken(!0);63 groupToken.matches.push(match), match = groupToken;64 }65 currentToken.matches.push(match), currentToken.matches.push(quantifierToken);66 }67 break;68 default:69 opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(m) : currentToken.matches.push(m);70 }71 currentToken.matches.length > 0 && opts.regexTokens.push(currentToken);72 }73 function validateRegexToken(token, fromGroup) {74 var isvalid = !1;75 fromGroup && (regexPart += "(", openGroupCount++);76 for (var mndx = 0; mndx < token.matches.length; mndx++) {77 var matchToken = token.matches[mndx];78 if (1 == matchToken.isGroup) isvalid = validateRegexToken(matchToken, !0); else if (1 == matchToken.isQuantifier) {79 var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;80 if (isNaN(matchToken.quantifier.max)) {81 for (;matchToken.repeaterPart && matchToken.repeaterPart != regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;82 isvalid = isvalid || validateRegexToken(matchGroup, !0), isvalid && (matchToken.repeaterPart = regexPart), 83 regexPart = regexPartBak + matchToken.quantifier.max;84 } else {85 for (var i = 0, qm = matchToken.quantifier.max - 1; qm > i && !(isvalid = validateRegexToken(matchGroup, !0)); i++) ;86 regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";87 }88 } else if (void 0 != matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {89 var testExp;90 if ("[" == matchToken.charAt(0)) {91 testExp = regexPart, testExp += matchToken;92 for (var j = 0; openGroupCount > j; j++) testExp += ")";93 var exp = new RegExp("^(" + testExp + ")$");94 isvalid = exp.test(bufferStr);95 } else for (var l = 0, tl = matchToken.length; tl > l; l++) if ("\\" != matchToken.charAt(l)) {96 testExp = regexPart, testExp += matchToken.substr(0, l + 1), testExp = testExp.replace(/\|$/, "");97 for (var j = 0; openGroupCount > j; j++) testExp += ")";98 var exp = new RegExp("^(" + testExp + ")$");99 if (isvalid = exp.test(bufferStr)) break;100 }101 regexPart += matchToken;102 }103 if (isvalid) break;104 }105 return fromGroup && (regexPart += ")", openGroupCount--), isvalid;106 }107 null == opts.regexTokens && analyseRegex();108 var cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;109 cbuffer.splice(pos, 0, chrs);110 for (var bufferStr = cbuffer.join(""), i = 0; i < opts.regexTokens.length; i++) {111 var regexToken = opts.regexTokens[i];112 if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) break;113 }114 return isValid;115 },116 cardinality: 1117 }118 }119 }120 }), $.fn.inputmask;...

Full Screen

Full Screen

inputmask.regex.extensions.js

Source:inputmask.regex.extensions.js Github

copy

Full Screen

1/*!2* inputmask.regex.extensions.js3* https://github.com/RobinHerbots/Inputmask4* Copyright (c) 2010 - 2017 Robin Herbots5* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)6* Version: 3.3.117*/8!function(factory) {9 "function" == typeof define && define.amd ? define([ "./dependencyLibs/inputmask.dependencyLib", "./inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./dependencyLibs/inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);10}(function($, Inputmask) {11 return Inputmask.extendAliases({12 Regex: {13 mask: "r",14 greedy: !1,15 repeat: "*",16 regex: null,17 regexTokens: null,18 tokenizer: /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,19 quantifierFilter: /[0-9]+[^,]/,20 isComplete: function(buffer, opts) {21 return new RegExp(opts.regex, opts.casing ? "i" : "").test(buffer.join(""));22 },23 definitions: {24 r: {25 validator: function(chrs, maskset, pos, strict, opts) {26 function RegexToken(isGroup, isQuantifier) {27 this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1, 28 this.quantifier = {29 min: 1,30 max: 131 }, this.repeaterPart = void 0;32 }33 function validateRegexToken(token, fromGroup) {34 var isvalid = !1;35 fromGroup && (regexPart += "(", openGroupCount++);36 for (var mndx = 0; mndx < token.matches.length; mndx++) {37 var matchToken = token.matches[mndx];38 if (!0 === matchToken.isGroup) isvalid = validateRegexToken(matchToken, !0); else if (!0 === matchToken.isQuantifier) {39 var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;40 if (isNaN(matchToken.quantifier.max)) {41 for (;matchToken.repeaterPart && matchToken.repeaterPart !== regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;42 (isvalid = isvalid || validateRegexToken(matchGroup, !0)) && (matchToken.repeaterPart = regexPart), 43 regexPart = regexPartBak + matchToken.quantifier.max;44 } else {45 for (var i = 0, qm = matchToken.quantifier.max - 1; i < qm && !(isvalid = validateRegexToken(matchGroup, !0)); i++) ;46 regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";47 }48 } else if (void 0 !== matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {49 var testExp;50 if ("[" == matchToken.charAt(0)) {51 testExp = regexPart, testExp += matchToken;52 for (j = 0; j < openGroupCount; j++) testExp += ")";53 isvalid = (exp = new RegExp("^(" + testExp + ")$", opts.casing ? "i" : "")).test(bufferStr);54 } else for (var l = 0, tl = matchToken.length; l < tl; l++) if ("\\" !== matchToken.charAt(l)) {55 testExp = regexPart, testExp = (testExp += matchToken.substr(0, l + 1)).replace(/\|$/, "");56 for (var j = 0; j < openGroupCount; j++) testExp += ")";57 var exp = new RegExp("^(" + testExp + ")$", opts.casing ? "i" : "");58 if (isvalid = exp.test(bufferStr)) break;59 }60 regexPart += matchToken;61 }62 if (isvalid) break;63 }64 return fromGroup && (regexPart += ")", openGroupCount--), isvalid;65 }66 var bufferStr, groupToken, cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;67 null === opts.regexTokens && function() {68 var match, m, currentToken = new RegexToken(), opengroups = [];69 for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) switch ((m = match[0]).charAt(0)) {70 case "(":71 opengroups.push(new RegexToken(!0));72 break;73 case ")":74 groupToken = opengroups.pop(), opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);75 break;76 case "{":77 case "+":78 case "*":79 var quantifierToken = new RegexToken(!1, !0), mq = (m = m.replace(/[{}]/g, "")).split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 === mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);80 if (quantifierToken.quantifier = {81 min: mq0,82 max: mq183 }, opengroups.length > 0) {84 var matches = opengroups[opengroups.length - 1].matches;85 (match = matches.pop()).isGroup || ((groupToken = new RegexToken(!0)).matches.push(match), 86 match = groupToken), matches.push(match), matches.push(quantifierToken);87 } else (match = currentToken.matches.pop()).isGroup || ((groupToken = new RegexToken(!0)).matches.push(match), 88 match = groupToken), currentToken.matches.push(match), currentToken.matches.push(quantifierToken);89 break;90 default:91 opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(m) : currentToken.matches.push(m);92 }93 currentToken.matches.length > 0 && opts.regexTokens.push(currentToken);94 }(), cbuffer.splice(pos, 0, chrs), bufferStr = cbuffer.join("");95 for (var i = 0; i < opts.regexTokens.length; i++) {96 var regexToken = opts.regexTokens[i];97 if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) break;98 }99 return isValid;100 },101 cardinality: 1102 }103 }104 }105 }), Inputmask;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var lexer = new gherkin.Lexer();4var tokenMatcher = new gherkin.TokenMatcher();5var feature = parser.parse(lexer.lex('Feature: Hello6'));7var token = lexer.lex('Given a step')[0];8var match = tokenMatcher.matchToken(token, feature);9console.log(match);10var gherkin = require('gherkin');11var parser = new gherkin.Parser();12var lexer = new gherkin.Lexer();13var tokenMatcher = new gherkin.TokenMatcher();14var feature = parser.parse(lexer.lex('Feature: Hello15'));16var token = lexer.lex('Given a step')[0];17var match = tokenMatcher.matchToken(token, feature);18console.log(match.keyword);

Full Screen

Using AI Code Generation

copy

Full Screen

1var Cucumber = require('cucumber');2var gherkin = Cucumber.Gherkin;3var lexer = new gherkin.Lexer();4var tokenMatcher = new gherkin.TokenMatcher();5var lexer = new gherkin.Lexer();6var tokenMatcher = new gherkin.TokenMatcher();7var tokens = lexer.lex("Feature: Test");8var token = tokens[0];9var isFeature = tokenMatcher.matchToken(token, 'Feature');10var isBackground = tokenMatcher.matchToken(token, 'Background');11var isScenario = tokenMatcher.matchToken(token, 'Scenario');12var isFeature = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario');13var isBackground = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario');14var isScenario = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario');15var isFeature = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario', 'Step');16var isBackground = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario', 'Step');17var isScenario = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario', 'Step');18var isStep = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario', 'Step');19var isFeature = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario', 'Step', 'DocString', 'Row');20var isBackground = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario', 'Step', 'DocString', 'Row');21var isScenario = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario', 'Step', 'DocString', 'Row');22var isStep = tokenMatcher.matchToken(token, 'Feature', 'Background', 'Scenario', 'Step', 'DocString', 'Row');

Full Screen

Using AI Code Generation

copy

Full Screen

1var Cucumber = require('cucumber');2var gherkin = Cucumber.Gherkin;3var source = 'Given I have 42 cukes in my belly';4var lexer = new gherkin.Lexer('en');5var tokenMatcher = new gherkin.TokenMatcher();6var token = lexer.lex(source)[0];7var match = tokenMatcher.matchToken(token, 'Given');8console.log(match);9var Cucumber = require('cucumber');10var gherkin = Cucumber.Gherkin;11var source = 'Given I have 42 cukes in my belly';12var lexer = new gherkin.Lexer('en');13var tokenMatcher = new gherkin.TokenMatcher();14var token = lexer.lex(source)[0];15var match = tokenMatcher.matchToken(token, 'When');16console.log(match);17var Cucumber = require('cucumber');18var gherkin = Cucumber.Gherkin;19var source = 'Given I have 42 cukes in my belly';20var lexer = new gherkin.Lexer('en');21var tokenMatcher = new gherkin.TokenMatcher();22var token = lexer.lex(source)[0];23var match = tokenMatcher.matchToken(token, 'Given I have');24console.log(match);

Full Screen

Using AI Code Generation

copy

Full Screen

1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var lexer = new gherkin.Lexer();4var tokenMatcher = new gherkin.TokenMatcher();5";6var featureTokens = lexer.lex(feature);7var featureAst = parser.parse(featureTokens);8var step = "Given I have a step";9var stepTokens = lexer.lex(step);10var stepAst = parser.parse(stepTokens);11var match = tokenMatcher.matchToken(stepTokens[0], featureAst[0].steps[0]);12console.log(match);

Full Screen

Using AI Code Generation

copy

Full Screen

1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var feature = parser.parse('Feature: Test Feature4');5var token = feature.feature.children[0].steps[0];6console.log(token.matchToken('Given'));7var cucumber = require('cucumber');8var parser = new cucumber.Parser();9var feature = parser.parse('Feature: Test Feature10');11var token = feature.getFeatures()[0].getFeatureElements()[0].getSteps()[0];12console.log(token.matchToken('Given'));13var cucumber = require('cucumber');14var parser = new cucumber.Parser();15var feature = parser.parse('Feature: Test Feature16');17var token = feature.getFeatures()[0].getFeatureElements()[0].getSteps()[0];18console.log(token.matchToken('Given'));19var cucumber = require('cucumber');20var parser = new cucumber.Parser();21var feature = parser.parse('Feature: Test Feature22');23var token = feature.getFeatures()[0].getFeatureElements()[0].getSteps()[0];24console.log(token.matchToken('Given'));25var cucumber = require('cucumber');26var parser = new cucumber.Parser();27var feature = parser.parse('Feature: Test Feature28');29var token = feature.getFeatures()[0].getFeatureElements()[0].getSteps()[0];30console.log(token.matchToken('Given'));31var cucumber = require('cucumber');32var parser = new cucumber.Parser();33var feature = parser.parse('Feature: Test Feature34');35var token = feature.getFeatures()[0].get

Full Screen

Using AI Code Generation

copy

Full Screen

1var gherkin = require('cucumber-gherkin');2var fs = require('fs');3var featureFile = fs.readFileSync('featureFile.feature', 'utf8');4var token = gherkin.matchToken(featureFile, 'Feature');5console.log(token);6{ line: 1, column: 1, type: 'FeatureLine', value: 'Feature: feature file' }7var gherkin = require('cucumber-gherkin');8var fs = require('fs');9var featureFile = fs.readFileSync('featureFile.feature', 'utf8');10var tokens = gherkin.matchTokens(featureFile, 'Scenario');11console.log(tokens);12[ { line: 2, column: 3, type: 'ScenarioLine', value: 'Scenario: scenario' } ]

Full Screen

Using AI Code Generation

copy

Full Screen

1var gherkin = require('cucumber-gherkin');2var token = gherkin.matchToken('I have a cat', /^I have a cat$/);3console.log(token);4var gherkin = require('cucumber-gherkin');5var token = gherkin.matchToken('I have a cat', /^I have a dog$/);6console.log(token);7var gherkin = require('cucumber-gherkin');8var token = gherkin.matchToken('I have a cat', /^I have a cat$/, 3);9console.log(token);10var gherkin = require('cucumber-gherkin');11var token = gherkin.matchToken('I have a cat', /^I have a dog$/, 3);12console.log(token);13var gherkin = require('cucumber-gherkin');14var token = gherkin.matchToken('I have a cat', /^I have a dog$/, 2);15console.log(token);16var gherkin = require('cucumber-gherkin');17var token = gherkin.matchToken('

Full Screen

Cucumber Tutorial:

LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.

Cucumber Tutorial Chapters:

Here are the detailed Cucumber testing chapters to help you get started:

  • Importance of Cucumber - Learn why Cucumber is important in Selenium automation testing during the development phase to identify bugs and errors.
  • Setting Up Cucumber in Eclipse and IntelliJ - Learn how to set up Cucumber in Eclipse and IntelliJ.
  • Running First Cucumber.js Test Script - After successfully setting up your Cucumber in Eclipse or IntelliJ, this chapter will help you get started with Selenium Cucumber testing in no time.
  • Annotations in Cucumber - To handle multiple feature files and the multiple scenarios in each file, you need to use functionality to execute these scenarios. This chapter will help you learn about a handful of Cucumber annotations ranging from tags, Cucumber hooks, and more to ease the maintenance of the framework.
  • Automation Testing With Cucumber And Nightwatch JS - Learn how to build a robust BDD framework setup for performing Selenium automation testing by integrating Cucumber into the Nightwatch.js framework.
  • Automation Testing With Selenium, Cucumber & TestNG - Learn how to perform Selenium automation testing by integrating Cucumber with the TestNG framework.
  • Integrate Cucumber With Jenkins - By using Cucumber with Jenkins integration, you can schedule test case executions remotely and take advantage of the benefits of Jenkins. Learn how to integrate Cucumber with Jenkins with this detailed chapter.
  • Cucumber Best Practices For Selenium Automation - Take a deep dive into the advanced use cases, such as creating a feature file, separating feature files, and more for Cucumber testing.

Run Cucumber-gherkin automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful