How to use clearBuffer method in Best

Best JavaScript code snippet using best

tag_if.js

Source:tag_if.js Github

copy

Full Screen

...10 .add(function (done) {11 common.render(context, '{% if true %}YES{% else %}NO{% endif %}', function (err, buf) {12 assert.equal(err, null);13 assert.equal(buf, 'YES');14 context.clearBuffer();15 done();16 });17 })18 .add(function (done) {19 common.render(context, '{% if true %}YES{% endif %}-END', function (err, buf) {20 assert.equal(err, null);21 assert.equal(buf, 'YES-END');22 context.clearBuffer();23 done();24 });25 })26 .add(function (done) {27 common.render(context, '{% if false %}YES{% endif %}-END', function (err, buf) {28 assert.equal(err, null);29 assert.equal(buf, '-END');30 context.clearBuffer();31 done();32 });33 })34 .add(function (done) {35 common.render(context, '{% if false %}YES{% else %}NO{% endif %}', function (err, buf) {36 assert.equal(err, null);37 assert.equal(buf, 'NO');38 context.clearBuffer();39 done();40 });41 })42 .add(function (done) {43 common.render(context, '{% if not true %}YES{% else %}NO{% endif %}', function (err, buf) {44 assert.equal(err, null);45 assert.equal(buf, 'NO');46 context.clearBuffer();47 done();48 });49 })50 .add(function (done) {51 common.render(context, '{% if not false %}YES{% else %}NO{% endif %}', function (err, buf) {52 assert.equal(err, null);53 assert.equal(buf, 'YES');54 context.clearBuffer();55 done();56 });57 })58 .add(function (done) {59 common.render(context, '{% if true and true %}YES{% else %}NO{% endif %}', function (err, buf) {60 assert.equal(err, null);61 assert.equal(buf, 'YES');62 context.clearBuffer();63 done();64 });65 })66 .add(function (done) {67 common.render(context, '{% if true && true %}YES{% else %}NO{% endif %}', function (err, buf) {68 assert.equal(err, null);69 assert.equal(buf, 'YES');70 context.clearBuffer();71 done();72 });73 })74 .add(function (done) {75 common.render(context, '{% if true and false %}YES{% else %}NO{% endif %}', function (err, buf) {76 assert.equal(err, null);77 assert.equal(buf, 'NO');78 context.clearBuffer();79 done();80 });81 })82 .add(function (done) {83 common.render(context, '{% if false and false %}YES{% else %}NO{% endif %}', function (err, buf) {84 assert.equal(err, null);85 assert.equal(buf, 'NO');86 context.clearBuffer();87 done();88 });89 })90 .add(function (done) {91 common.render(context, '{% if true or true %}YES{% else %}NO{% endif %}', function (err, buf) {92 assert.equal(err, null);93 assert.equal(buf, 'YES');94 context.clearBuffer();95 done();96 });97 })98 .add(function (done) {99 common.render(context, '{% if true || true %}YES{% else %}NO{% endif %}', function (err, buf) {100 assert.equal(err, null);101 assert.equal(buf, 'YES');102 context.clearBuffer();103 done();104 });105 })106 .add(function (done) {107 common.render(context, '{% if true or false %}YES{% else %}NO{% endif %}', function (err, buf) {108 assert.equal(err, null);109 assert.equal(buf, 'YES');110 context.clearBuffer();111 done();112 });113 })114 .add(function (done) {115 common.render(context, '{% if false or false %}YES{% else %}NO{% endif %}', function (err, buf) {116 assert.equal(err, null);117 assert.equal(buf, 'NO');118 context.clearBuffer();119 done();120 });121 })122 .add(function (done) {123 common.render(context, '{% if 1 > 2 %}YES{% else %}NO{% endif %}', function (err, buf) {124 assert.equal(err, null);125 assert.equal(buf, 'NO');126 context.clearBuffer();127 done();128 });129 })130 .add(function (done) {131 common.render(context, '{% if 1 < 2 %}YES{% else %}NO{% endif %}', function (err, buf) {132 assert.equal(err, null);133 assert.equal(buf, 'YES');134 context.clearBuffer();135 done();136 });137 })138 .add(function (done) {139 common.render(context, '{% if 1 >= 2 %}YES{% else %}NO{% endif %}', function (err, buf) {140 assert.equal(err, null);141 assert.equal(buf, 'NO');142 context.clearBuffer();143 done();144 });145 })146 .add(function (done) {147 common.render(context, '{% if 3 >= 2 %}YES{% else %}NO{% endif %}', function (err, buf) {148 assert.equal(err, null);149 assert.equal(buf, 'YES');150 context.clearBuffer();151 done();152 });153 })154 .add(function (done) {155 common.render(context, '{% if 1 < 2 %}YES{% else %}NO{% endif %}', function (err, buf) {156 assert.equal(err, null);157 assert.equal(buf, 'YES');158 context.clearBuffer();159 done();160 });161 })162 .add(function (done) {163 common.render(context, '{% if 3 <= 2 %}YES{% else %}NO{% endif %}', function (err, buf) {164 assert.equal(err, null);165 assert.equal(buf, 'NO');166 context.clearBuffer();167 done();168 });169 })170 .add(function (done) {171 common.render(context, '{% if 1 <= 2 %}YES{% else %}NO{% endif %}', function (err, buf) {172 assert.equal(err, null);173 assert.equal(buf, 'YES');174 context.clearBuffer();175 done();176 });177 })178 .add(function (done) {179 common.render(context, '{% if 3 <= 2 %}YES{% else %}NO{% endif %}', function (err, buf) {180 assert.equal(err, null);181 assert.equal(buf, 'NO');182 context.clearBuffer();183 done();184 });185 })186 .add(function (done) {187 common.render(context, '{% if 1 = 2 %}YES{% else %}NO{% endif %}', function (err, buf) {188 assert.equal(err, null);189 assert.equal(buf, 'NO');190 context.clearBuffer();191 done();192 });193 })194 .add(function (done) {195 common.render(context, '{% if 3 == 2 %}YES{% else %}NO{% endif %}', function (err, buf) {196 assert.equal(err, null);197 assert.equal(buf, 'NO');198 context.clearBuffer();199 done();200 });201 })202 .add(function (done) {203 common.render(context, '{% if 1 == 1 %}YES{% else %}NO{% endif %}', function (err, buf) {204 assert.equal(err, null);205 assert.equal(buf, 'YES');206 context.clearBuffer();207 done();208 });209 })210 .add(function (done) {211 common.render(context, '{% if 1 == "1" %}YES{% else %}NO{% endif %}', function (err, buf) {212 assert.equal(err, null);213 assert.equal(buf, 'YES');214 context.clearBuffer();215 done();216 });217 })218 .add(function (done) {219 common.render(context, '{% if 1 === 1 %}YES{% else %}NO{% endif %}', function (err, buf) {220 assert.equal(err, null);221 assert.equal(buf, 'YES');222 context.clearBuffer();223 done();224 });225 })226 .add(function (done) {227 common.render(context, '{% if 1 === "1" %}YES{% else %}NO{% endif %}', function (err, buf) {228 assert.equal(err, null);229 assert.equal(buf, 'NO');230 context.clearBuffer();231 done();232 });233 })234 .add(function (done) {235 common.render(context, '{% if 1 != 2 %}YES{% else %}NO{% endif %}', function (err, buf) {236 assert.equal(err, null);237 assert.equal(buf, 'YES');238 context.clearBuffer();239 done();240 });241 })242 .add(function (done) {243 common.render(context, '{% if 1 != 1 %}YES{% else %}NO{% endif %}', function (err, buf) {244 assert.equal(err, null);245 assert.equal(buf, 'NO');246 context.clearBuffer();247 done();248 });249 })250 .add(function (done) {251 common.render(context, '{% if "abcd" contains "c" %}YES{% else %}NO{% endif %}', function (err, buf) {252 assert.equal(err, null);253 assert.equal(buf, 'YES');254 context.clearBuffer();255 done();256 });257 })258 .add(function (done) {259 common.render(context, '{% if "abcd" contains "e" %}YES{% else %}NO{% endif %}', function (err, buf) {260 assert.equal(err, null);261 assert.equal(buf, 'NO');262 context.clearBuffer();263 done();264 });265 })266 .add(function (done) {267 common.render(context, '{% if array hasValue 1 %}YES{% else %}NO{% endif %}', function (err, buf) {268 assert.equal(err, null);269 assert.equal(buf, 'YES');270 context.clearBuffer();271 done();272 });273 })274 .add(function (done) {275 common.render(context, '{% if array hasValue 6 %}YES{% else %}NO{% endif %}', function (err, buf) {276 assert.equal(err, null);277 assert.equal(buf, 'NO');278 context.clearBuffer();279 done();280 });281 })282 .add(function (done) {283 common.render(context, '{% if object hasValue 2 %}YES{% else %}NO{% endif %}', function (err, buf) {284 assert.equal(err, null);285 assert.equal(buf, 'YES');286 context.clearBuffer();287 done();288 });289 })290 .add(function (done) {291 common.render(context, '{% if object hasValue 6 %}YES{% else %}NO{% endif %}', function (err, buf) {292 assert.equal(err, null);293 assert.equal(buf, 'NO');294 context.clearBuffer();295 done();296 });297 })298 .add(function (done) {299 common.render(context, '{% if object hasKey "a" %}YES{% else %}NO{% endif %}', function (err, buf) {300 assert.equal(err, null);301 assert.equal(buf, 'YES');302 context.clearBuffer();303 done();304 });305 })306 .add(function (done) {307 common.render(context, '{% if object hasKey "x" %}YES{% else %}NO{% endif %}', function (err, buf) {308 assert.equal(err, null);309 assert.equal(buf, 'NO');310 context.clearBuffer();311 done();312 });313 })314 .end(done);315 });316 it('#else', function (done) {317 common.taskList()318 .add(function (done) {319 common.render(context, '{% if false %}YES{% elseif true %}YES2{% else %}NO{% endif %}', function (err, buf) {320 assert.equal(err, null);321 assert.equal(buf, 'YES2');322 context.clearBuffer();323 done();324 });325 })326 .add(function (done) {327 common.render(context, '{% if false %}YES{% elseif true %}YES2{% endif %}', function (err, buf) {328 assert.equal(err, null);329 assert.equal(buf, 'YES2');330 context.clearBuffer();331 done();332 });333 })334 .add(function (done) {335 common.render(context, '{% if false %}YES{% elseif false %}YES2{% elseif true %}YES3{% else %}NO{% endif %}', function (err, buf) {336 assert.equal(err, null);337 assert.equal(buf, 'YES3');338 context.clearBuffer();339 done();340 });341 })342 .add(function (done) {343 common.render(context, '{% if false %}YES{% elseif false %}YES2{% elseif true %}YES3{% endif %}', function (err, buf) {344 assert.equal(err, null);345 assert.equal(buf, 'YES3');346 context.clearBuffer();347 done();348 });349 })350 .add(function (done) {351 common.render(context, '{% if false %}YES{% elseif false %}YES2{% endif %}', function (err, buf) {352 assert.equal(err, null);353 assert.equal(buf, '');354 context.clearBuffer();355 done();356 });357 })358 .add(function (done) {359 common.render(context, '{% if false %}YES{% elseif false %}YES2{% elseif false %}YES3{% endif %}', function (err, buf) {360 assert.equal(err, null);361 assert.equal(buf, '');362 context.clearBuffer();363 done();364 });365 })366 // elsif367 .add(function (done) {368 common.render(context, '{% if false %}YES{% elsif true %}YES2{% else %}NO{% endif %}', function (err, buf) {369 assert.equal(err, null);370 assert.equal(buf, 'YES2');371 context.clearBuffer();372 done();373 });374 })375 .add(function (done) {376 common.render(context, '{% if false %}YES{% elsif true %}YES2{% endif %}', function (err, buf) {377 assert.equal(err, null);378 assert.equal(buf, 'YES2');379 context.clearBuffer();380 done();381 });382 })383 .add(function (done) {384 common.render(context, '{% if false %}YES{% elsif false %}YES2{% elsif true %}YES3{% else %}NO{% endif %}', function (err, buf) {385 assert.equal(err, null);386 assert.equal(buf, 'YES3');387 context.clearBuffer();388 done();389 });390 })391 .add(function (done) {392 common.render(context, '{% if false %}YES{% elsif false %}YES2{% elsif true %}YES3{% endif %}', function (err, buf) {393 assert.equal(err, null);394 assert.equal(buf, 'YES3');395 context.clearBuffer();396 done();397 });398 })399 .add(function (done) {400 common.render(context, '{% if false %}YES{% elsif false %}YES2{% endif %}', function (err, buf) {401 assert.equal(err, null);402 assert.equal(buf, '');403 context.clearBuffer();404 done();405 });406 })407 .add(function (done) {408 common.render(context, '{% if false %}YES{% elsif false %}YES2{% elsif false %}YES3{% endif %}', function (err, buf) {409 assert.equal(err, null);410 assert.equal(buf, '');411 context.clearBuffer();412 done();413 });414 })415 .end(done);416 });417 it('#empty', function (done) {418 common.taskList()419 .add(function (done) {420 common.render(context, '{% if false %}{% elseif true %}{% else %}{% endif %}', function (err, buf) {421 assert.equal(err, null);422 assert.equal(buf, '');423 context.clearBuffer();424 done();425 });426 })427 .add(function (done) {428 common.render(context, '{% if false %}{% elseif true %}YES{% else %}{% endif %}', function (err, buf) {429 assert.equal(err, null);430 assert.equal(buf, 'YES');431 context.clearBuffer();432 done();433 });434 })435 .add(function (done) {436 common.render(context, '{% if false %}{% elseif false %}{% else %}YES{% endif %}', function (err, buf) {437 assert.equal(err, null);438 assert.equal(buf, 'YES');439 context.clearBuffer();440 done();441 });442 })443 .add(function (done) {444 common.render(context, '{% if true %}YES{% elseif true %}{% else %}{% endif %}', function (err, buf) {445 assert.equal(err, null);446 assert.equal(buf, 'YES');447 context.clearBuffer();448 done();449 });450 })451 .end(done);452 });453 it('#multi condition', function (done) {454 common.taskList()455 .add(function (done) {456 common.render(context, '{% if false or false %}YES{% else %}NO{% endif %}', function (err, buf) {457 assert.equal(err, null);458 assert.equal(buf, 'NO');459 context.clearBuffer();460 done();461 });462 })463 .add(function (done) {464 common.render(context, '{% if false or false or true %}YES{% else %}NO{% endif %}', function (err, buf) {465 assert.equal(err, null);466 assert.equal(buf, 'YES');467 context.clearBuffer();468 done();469 });470 })471 .add(function (done) {472 common.render(context, '{% if false or false or false or true %}YES{% else %}NO{% endif %}', function (err, buf) {473 assert.equal(err, null);474 assert.equal(buf, 'YES');475 context.clearBuffer();476 done();477 });478 })479 .add(function (done) {480 common.render(context, '{% if true and true and false %}YES{% else %}NO{% endif %}', function (err, buf) {481 assert.equal(err, null);482 assert.equal(buf, 'NO');483 context.clearBuffer();484 done();485 });486 })487 .add(function (done) {488 common.render(context, '{% if true and true and true and false %}YES{% else %}NO{% endif %}', function (err, buf) {489 assert.equal(err, null);490 assert.equal(buf, 'NO');491 context.clearBuffer();492 done();493 });494 })495 .add(function (done) {496 common.render(context, '{% if aBC %}YES{% else %}NO{% endif %}', function (err, buf) {497 assert.equal(err, null);498 assert.equal(buf, 'NO');499 context.clearBuffer();500 done();501 });502 })503 .add(function (done) {504 common.render(context, '{% if aBc %}YES{% else %}NO{% endif %}', function (err, buf) {505 assert.equal(err, null);506 assert.equal(buf, 'YES');507 context.clearBuffer();508 done();509 });510 })511 .end(done);512 });513/*514 it('#Unexpected', function (done) {515 common.taskList()516 .add(function (done) {517 common.render(context, '{% if true %}YES{% endif %}{% endif %}', function (err, buf) {518 assert.equal(err, null);519 assert.equal(buf, 'YES{% endif %}');520 context.clearBuffer();521 done();522 });523 })524 .end(done);525 });526*/...

Full Screen

Full Screen

tokenizer.ts

Source:tokenizer.ts Github

copy

Full Screen

...448 case blockCommentMode:449 if (line[curChar] === "*" && line[curChar + 1] === "/") {450 pushBuffer("*/");451 ++curChar;452 clearBuffer();453 mode = codeMode;454 } else {455 pushBuffer(line[curChar]);456 }457 break;458 case stringMode:459 pushBuffer(line[curChar]);460 if (line[curChar] === begStr) {461 clearBuffer();462 mode = codeMode;463 }464 break;465 case codeMode:466 switch (line[curChar]) {467 case " ":468 case "\t":469 clearBuffer();470 break;471 case '"':472 case "'":473 case "`":474 clearBuffer();475 mode = stringMode;476 begStr = line[curChar];477 pushBuffer(line[curChar]);478 break;479 case "(":480 case ")":481 case "{":482 case "}":483 case "[":484 case "]":485 case ";":486 clearBuffer();487 pushBuffer(line[curChar]);488 clearBuffer();489 break;490 case "+":491 clearBuffer();492 if (line[curChar + 1] === "=") {493 pushBuffer("+=");494 ++curChar;495 } else {496 pushBuffer("+");497 }498 clearBuffer();499 break;500 case "-":501 clearBuffer();502 if (line[curChar + 1] === "=") {503 pushBuffer("-=");504 ++curChar;505 } else {506 pushBuffer("-");507 }508 break;509 case "*":510 clearBuffer();511 if (line[curChar + 1] === "=") {512 pushBuffer("*=");513 ++curChar;514 } else {515 pushBuffer("*");516 }517 break;518 case "/":519 clearBuffer();520 if (line[curChar + 1] === "=") {521 pushBuffer("/=");522 ++curChar;523 clearBuffer();524 } else if (line[curChar + 1] === "/") {525 mode = lineCommentMode;526 pushBuffer("//");527 ++curChar;528 } else if (line[curChar + 1] === "*") {529 mode = blockCommentMode;530 pushBuffer("/*");531 ++curChar;532 } else {533 pushBuffer("/");534 clearBuffer();535 }536 break;537 case "%":538 clearBuffer();539 if (line[curChar + 1] === "=") {540 pushBuffer("%=");541 ++curChar;542 } else {543 pushBuffer("%");544 }545 break;546 case "&":547 clearBuffer();548 if (line[curChar + 1] === "&") {549 if (line[curChar + 2] === "=") {550 pushBuffer("&&=");551 curChar += 2;552 } else {553 pushBuffer("&&");554 ++curChar;555 }556 } else if (line[curChar + 1] === "=") {557 pushBuffer("&=");558 ++curChar;559 } else {560 pushBuffer("&");561 }562 clearBuffer();563 break;564 case "|":565 clearBuffer();566 if (line[curChar + 1] === "|") {567 if (line[curChar + 2] === "=") {568 pushBuffer("||=");569 curChar += 2;570 } else {571 pushBuffer("||");572 ++curChar;573 }574 } else if (line[curChar + 1] === "=") {575 pushBuffer("|=");576 ++curChar;577 } else {578 pushBuffer("|");579 }580 clearBuffer();581 break;582 case "^":583 clearBuffer();584 if (line[curChar + 1] === "=") {585 pushBuffer("^=");586 ++curChar;587 } else {588 pushBuffer("^");589 }590 clearBuffer();591 break;592 case "~":593 clearBuffer();594 pushBuffer("~");595 clearBuffer();596 break;597 case "=":598 clearBuffer();599 if (line[curChar + 1] === "=") {600 if (line[curChar + 2] === "=") {601 pushBuffer("===");602 curChar += 2;603 } else {604 pushBuffer("==");605 ++curChar;606 }607 } else {608 pushBuffer("=");609 }610 clearBuffer();611 break;612 case "!":613 clearBuffer();614 if (line[curChar + 1] === "=") {615 if (line[curChar + 2] === "=") {616 pushBuffer("!==");617 curChar += 2;618 } else {619 pushBuffer("!=");620 ++curChar;621 }622 } else {623 pushBuffer("!");624 }625 clearBuffer();626 break;627 case "<":628 clearBuffer();629 if (line[curChar + 1] === "<") {630 if (line[curChar + 2] === "=") {631 pushBuffer("<<=");632 curChar += 2;633 } else {634 pushBuffer("<<");635 ++curChar;636 }637 } else if (line[curChar + 1] === "=") {638 pushBuffer("<=");639 ++curChar;640 } else {641 pushBuffer("<");642 }643 clearBuffer();644 break;645 case ">":646 clearBuffer();647 clearBuffer();648 if (line[curChar + 1] === ">") {649 if (line[curChar + 2] === ">") {650 if (line[curChar + 3] === "=") {651 pushBuffer(">>>=");652 curChar += 3;653 } else {654 pushBuffer(">>>");655 curChar += 2;656 }657 } else if (line[curChar + 2] === "=") {658 pushBuffer(">>=");659 curChar += 2;660 } else {661 pushBuffer(">>");662 ++curChar;663 }664 } else if (line[curChar + 1] === "=") {665 pushBuffer(">=");666 ++curChar;667 } else {668 pushBuffer(">");669 }670 clearBuffer();671 break;672 case "?":673 clearBuffer();674 if (line[curChar + 1] === "?") {675 if (line[curChar + 2] === "=") {676 pushBuffer("??=");677 curChar += 2;678 } else {679 pushBuffer("??");680 ++curChar;681 }682 } else if (line[curChar + 1] === ".") {683 pushBuffer("?.");684 ++curChar;685 } else {686 pushBuffer("?");687 }688 clearBuffer();689 break;690 case ":":691 clearBuffer();692 pushBuffer(":");693 clearBuffer();694 break;695 case ",":696 clearBuffer();697 pushBuffer(",");698 clearBuffer();699 break;700 case ".":701 clearBuffer();702 if (line[curChar + 1] === "." && line[curChar + 2] === ".") {703 pushBuffer("...");704 curChar += 2;705 } else if (706 line[curChar + 1] === "." &&707 line[curChar + 2] === "<"708 ) {709 pushBuffer("..<");710 curChar += 2;711 } else {712 pushBuffer(".");713 }714 clearBuffer();715 break;716 default:717 pushBuffer(line[curChar]);718 }719 break;720 }721 clearBuffer();722 if (mode === lineCommentMode) {723 mode = codeMode;724 }725 ++curLine;726 }727 clearBuffer();728 return tokens;729};730const createToken = (731 begLine: number,732 begChar: number,733 buffer: string,734): Token => {735 let role: Token["role"] = "other";736 let swiftRole: Token["swiftRole"] = "unknown";737 if (Object.keys(wellKnownRole).includes(buffer)) {738 role = wellKnownRole[buffer as keyof typeof wellKnownRole].role;739 swiftRole = wellKnownRole[buffer as keyof typeof wellKnownRole].swiftRole;740 } else if (/^[a-zA-Z_][a-zA-Z_0-9]*$/.test(buffer)) {741 role = "variable";...

Full Screen

Full Screen

tag_for.js

Source:tag_for.js Github

copy

Full Screen

...11 .add(function (done) {12 common.render(context, '{% for array %}{{ item }}{% endfor %}', function (err, buf) {13 assert.equal(err, null);14 assert.equal(buf, '123456');15 context.clearBuffer();16 done();17 });18 })19 .add(function (done) {20 common.render(context, '{% for item in array %}{{ item }}{% endfor %}', function (err, buf) {21 assert.equal(err, null);22 assert.equal(buf, '123456');23 context.clearBuffer();24 done();25 });26 })27 .add(function (done) {28 common.render(context, '{% for item in array limit:2 offset:2 %}{{ item }}{% endfor %}', function (err, buf) {29 assert.equal(err, null);30 assert.equal(buf, '34');31 context.clearBuffer();32 done();33 });34 })35 .add(function (done) {36 common.render(context, '{% for item in array limit:2 %}{{ item }}{% endfor %}', function (err, buf) {37 assert.equal(err, null);38 assert.equal(buf, '12');39 context.clearBuffer();40 done();41 });42 })43 .add(function (done) {44 common.render(context, '{% for item in array offset:3 %}{{ item }}{% endfor %}', function (err, buf) {45 assert.equal(err, null);46 assert.equal(buf, '456');47 context.clearBuffer();48 done();49 });50 })51 .add(function (done) {52 // 特殊格式写法53 common.render(context, '{% for item in array limit: 2 offset: 2 %}{{ item }}{% endfor %}', function (err, buf) {54 assert.equal(err, null);55 assert.equal(buf, '34');56 context.clearBuffer();57 done();58 });59 })60 .add(function (done) {61 // 特殊格式写法62 common.render(context, '{%for item in array limit: 2 offset: 2%}{{item}}{%endfor%}', function (err, buf) {63 assert.equal(err, null);64 assert.equal(buf, '34');65 context.clearBuffer();66 done();67 });68 })69 .add(function (done) {70 // 参数为变量71 common.render(context, '{% for item in object %}{{item}}{% endfor %}', function (err, buf) {72 assert.equal(err, null);73 assert.equal(buf, '123456abc');74 context.clearBuffer();75 done();76 });77 })78 .add(function (done) {79 common.render(context, '{% for item in (1..5) %}{{ item }}{% endfor %}', function (err, buf) {80 assert.equal(err, null);81 assert.equal(buf, '12345');82 context.clearBuffer();83 done();84 });85 })86 .add(function (done) {87 common.render(context, '{% for item in (1..range_end) %}{{ item }}{% endfor %}', function (err, buf) {88 assert.equal(err, null);89 assert.equal(buf, '12345');90 context.clearBuffer();91 done();92 });93 })94 .add(function (done) {95 common.render(context, '{% for item in (range_start..5) %}{{ item }}{% endfor %}', function (err, buf) {96 assert.equal(err, null);97 assert.equal(buf, '12345');98 context.clearBuffer();99 done();100 });101 })102 .add(function (done) {103 common.render(context, '{% for item in (range_start..range_end) %}{{ item }}{% endfor %}', function (err, buf) {104 assert.equal(err, null);105 assert.equal(buf, '12345');106 context.clearBuffer();107 done();108 });109 })110 .end(done);111 });112 it('#forloop', function (done) {113 common.taskList()114 .add(function (done) {115 common.render(context, '{% for item in array %}{{ item }}{{ forloop.first }}{% endfor %}', function (err, buf) {116 assert.equal(err, null);117 assert.equal(buf, '1true2false3false4false5false6false');118 context.clearBuffer();119 done();120 });121 })122 .add(function (done) {123 common.render(context, '{% for item in array %}{{ item }}{{ forloop.last }}{% endfor %}', function (err, buf) {124 assert.equal(err, null);125 assert.equal(buf, '1false2false3false4false5false6true');126 context.clearBuffer();127 done();128 });129 })130 .add(function (done) {131 common.render(context, '{% for item in array limit:2 %}{{ item }}{{ forloop.first }}{% endfor %}', function (err, buf) {132 assert.equal(err, null);133 assert.equal(buf, '1true2false');134 context.clearBuffer();135 done();136 });137 })138 .add(function (done) {139 common.render(context, '{% for item in array limit:2 %}{{ item }}{{ forloop.last }}{% endfor %}', function (err, buf) {140 assert.equal(err, null);141 assert.equal(buf, '1false2true');142 context.clearBuffer();143 done();144 });145 })146 .add(function (done) {147 common.render(context, '{% for item in array offset:2 %}{{ item }}{{ forloop.first }}{% endfor %}', function (err, buf) {148 assert.equal(err, null);149 assert.equal(buf, '3true4false5false6false');150 context.clearBuffer();151 done();152 });153 })154 .add(function (done) {155 common.render(context, '{% for item in array offset:2 %}{{ item }}{{ forloop.last }}{% endfor %}', function (err, buf) {156 assert.equal(err, null);157 assert.equal(buf, '3false4false5false6true');158 context.clearBuffer();159 done();160 });161 })162 .add(function (done) {163 common.render(context, '{% for item in array limit:2 offset:2 %}{{ item }}{{ forloop.first }}{% endfor %}', function (err, buf) {164 assert.equal(err, null);165 assert.equal(buf, '3true4false');166 context.clearBuffer();167 done();168 });169 })170 .add(function (done) {171 common.render(context, '{%for item in array%} {{forloop.index}} {%endfor%}', function (err, buf) {172 assert.equal(err, null);173 assert.equal(buf, ' 1 2 3 4 5 6 ');174 context.clearBuffer();175 done();176 });177 })178 .add(function (done) {179 common.render(context, '{%for item in array%} {{forloop.index0}} {%endfor%}', function (err, buf) {180 assert.equal(err, null);181 assert.equal(buf, ' 0 1 2 3 4 5 ');182 context.clearBuffer();183 done();184 });185 })186 .add(function (done) {187 common.render(context, '{%for item in array%}{{forloop.rindex0}}{%endfor%}', function (err, buf) {188 assert.equal(err, null);189 assert.equal(buf, '543210');190 context.clearBuffer();191 done();192 });193 })194 .add(function (done) {195 common.render(context, '{%for item in array%}{{forloop.rindex}}{%endfor%}', function (err, buf) {196 assert.equal(err, null);197 assert.equal(buf, '654321');198 context.clearBuffer();199 done();200 });201 })202 .add(function (done) {203 common.render(context, '{% for i in array %}{{forloop.name}}={{i}},{%endfor%}', function (err, buf) {204 assert.equal(err, null);205 assert.equal(buf, 'i=1,i=2,i=3,i=4,i=5,i=6,');206 context.clearBuffer();207 done();208 });209 })210 .add(function (done) {211 common.render(context, '{% for i in array %}{{forloop.length}}{%endfor%}', function (err, buf) {212 assert.equal(err, null);213 assert.equal(buf, '666666');214 context.clearBuffer();215 done();216 });217 })218 .end(done);219 });220 it('#else', function (done) {221 context.setLocals('array2', []);222 context.setLocals('array3', null);223 common.taskList()224 .add(function (done) {225 common.render(context, '{%for item in array%}+{%else%}-{%endfor%}', function (err, buf) {226 assert.equal(err, null);227 assert.equal(buf, '++++++');228 context.clearBuffer();229 done();230 });231 })232 .add(function (done) {233 common.render(context, '{%for item in array2%}+{%else%}-{%endfor%}', function (err, buf) {234 assert.equal(err, null);235 assert.equal(buf, '-');236 context.clearBuffer();237 done();238 });239 })240 .add(function (done) {241 common.render(context, '{%for item in array3%}+{%else%}-{%endfor%}', function (err, buf) {242 assert.equal(err, null);243 assert.equal(buf, '-');244 context.clearBuffer();245 done();246 });247 })248 .end(done);249 });250 it('#other', function (done) {251 context.setLocals('array4', {a:1, b:2, c:3, f:4, g:5});252 common.taskList()253 .add(function (done) {254 common.render(context, '{%for item in array4%}{{item}}{%endfor%}-{{array4.a}}{{array4.b}}', function (err, buf) {255 assert.equal(err, null);256 assert.equal(buf, '12345-12');257 context.clearBuffer();258 done();259 });260 })261 .add(function (done) {262 common.render(context, '{%for item in array limit:2%}{%for item in array offset:2%}{{item}}{%endfor%}{%endfor%}', function (err, buf) {263 assert.equal(err, null);264 assert.equal(buf, '34563456');265 context.clearBuffer();266 done();267 });268 })269 .end(done);270 });271 it('#item', function (done) {272 context.setLocals('array5', [{v:123}, {v:456}, {v:789}]);273 common.taskList()274 .add(function (done) {275 common.render(context, '{%for item in array5%}{{item.v}}{%endfor%}', function (err, buf) {276 assert.equal(err, null);277 assert.equal(buf, '123456789');278 context.clearBuffer();279 done();280 });281 })282 .end(done);283 });284 it('large #for', function (done) {285 var site = {286 posts: []287 };288 var result = '';289 for (var i = 0; i < 1000000; i++) {290 var title = 'Post ' + i;291 site.posts.push({ title: title });292 result.concat(title);293 }294 context.setLocals('posts', site);295 common.taskList()296 .add(function (done) {297 common.render(context, '{% for post in site.posts %}{{ post.title }}{% endfor %}', function (err, buf) {298 assert.equal(err, null);299 assert.equal(buf, result);300 context.clearBuffer();301 done();302 });303 })304 .end(done);305 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const BestFit = require('./BestFit');2const bestFit = new BestFit(10);3bestFit.allocate(0, 1);4bestFit.allocate(1, 2);5bestFit.allocate(2, 3);6bestFit.allocate(3, 4);7bestFit.allocate(4, 5);8bestFit.allocate(5, 6);9bestFit.allocate(6, 7);10bestFit.allocate(7, 8);11bestFit.allocate(8, 9);12bestFit.allocate(9, 10);13bestFit.clearBuffer();14console.log(bestFit);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestFit = require('./BestFit.js');2var bestFit = new BestFit(100);3bestFit.allocate(20);4bestFit.allocate(30);5bestFit.allocate(50);6bestFit.allocate(60);7bestFit.allocate(70);8bestFit.allocate(80);9bestFit.allocate(90);10bestFit.allocate(100);11bestFit.allocate(110);12bestFit.allocate(120);13bestFit.allocate(130);14bestFit.allocate(140);15bestFit.allocate(150);16bestFit.allocate(160);17bestFit.allocate(170);18bestFit.allocate(180);19bestFit.allocate(190);20bestFit.allocate(200);21bestFit.allocate(210);22bestFit.allocate(220);23bestFit.allocate(230);24bestFit.allocate(240);25bestFit.allocate(250);26bestFit.allocate(260);27bestFit.allocate(270);28bestFit.allocate(280);29bestFit.allocate(290);30bestFit.allocate(300);31bestFit.allocate(310);32bestFit.allocate(320);33bestFit.allocate(330);34bestFit.allocate(340);35bestFit.allocate(350);36bestFit.allocate(360);37bestFit.allocate(370);38bestFit.allocate(380);39bestFit.allocate(390);40bestFit.allocate(400);41bestFit.allocate(410);42bestFit.allocate(420);43bestFit.allocate(430);44bestFit.allocate(440);45bestFit.allocate(450);46bestFit.allocate(460);47bestFit.allocate(470);48bestFit.allocate(480);49bestFit.allocate(490);50bestFit.allocate(500);51bestFit.allocate(510);52bestFit.allocate(520);53bestFit.allocate(530);54bestFit.allocate(540);55bestFit.allocate(550);56bestFit.allocate(560);57bestFit.allocate(570);58bestFit.allocate(580);59bestFit.allocate(590);60bestFit.allocate(600);61bestFit.allocate(610);62bestFit.allocate(620);63bestFit.allocate(630);64bestFit.allocate(640);65bestFit.allocate(650);66bestFit.allocate(660);67bestFit.allocate(670);68bestFit.allocate(680);69bestFit.allocate(690);70bestFit.allocate(700);71bestFit.allocate(710);72bestFit.allocate(720);73bestFit.allocate(730);74bestFit.allocate(740);75bestFit.allocate(750);76bestFit.allocate(760);77bestFit.allocate(770);78bestFit.allocate(780);79bestFit.allocate(790);80bestFit.allocate(800);81bestFit.allocate(810);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBuy = require('bestbuy');2var bb = new BestBuy('your-api-key-here');3bb.clearBuffer(function(err, data) {4 if (err) {5 console.log(err);6 return;7 }8 console.log(data);9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestFit = require('./BestFit.js');2var bestFit = new BestFit(10);3var fs = require('fs');4var data = fs.readFileSync('input.txt', 'utf8');5var lines = data.split('\n');6for (var i = 0; i < lines.length; i++) {7 var line = lines[i].split(' ');8 if (line[0] == 'A') {9 bestFit.allocate(parseInt(line[1]));10 } else if (line[0] == 'D') {11 bestFit.deallocate(parseInt(line[1]));12 } else if (line[0] == 'C') {13 bestFit.clearBuffer();14 }15}

Full Screen

Using AI Code Generation

copy

Full Screen

1ws.OnOpen = function () {2 ws.Send('Hello World!');3 clearBuffer.Send('clearBuffer');4 ws.Send('Hello World!');5};6ws.OnMessage = function (msg) {7 Debug.Log(msg.Data);8};9clearBuffer.OnMessage = function (msg) {10 Debug.Log(msg.Data);11};12clearBuffer.OnOpen = function () {13 clearBuffer.Send('clearBuffer');14};15ws.OnOpen = function () {16 ws.Send('Hello World!');17 clearBuffer.Send('clearBuffer');18 ws.Send('Hello World!');19};20ws.OnMessage = function (msg) {21 Debug.Log(msg.Data);22};23clearBuffer.OnMessage = function (msg) {24 Debug.Log(msg.Data);25};26clearBuffer.OnOpen = function () {27 clearBuffer.Send('clearBuffer');28};29ws.OnOpen = function () {30 ws.Send('Hello World!');31 clearBuffer.Send('clearBuffer');32 ws.Send('Hello World!');33};34ws.OnMessage = function (msg) {35 Debug.Log(msg.Data);36};37clearBuffer.OnMessage = function (msg) {38 Debug.Log(msg.Data);39};40clearBuffer.OnOpen = function () {41 clearBuffer.Send('clearBuffer');42};

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestFit = require('./BestFit.js');2var bestFit = new BestFit(100);3for(var i = 0; i < 10; i++){4 bestFit.insertBlock(10);5}6console.log(bestFit.buffer);7console.log("Number of free blocks: " + bestFit.getFreeBlocks());8bestFit.clearBuffer();9console.log(bestFit.buffer);10console.log("Number of free blocks: " + bestFit.getFreeBlocks());11var BestFit = require('./BestFit.js');12var bestFit = new BestFit(100);13for(var i = 0; i < 10; i++){14 bestFit.insertBlock(10);15}16console.log(bestFit.buffer);17console.log("Number of free blocks: " + bestFit.getFreeBlocks());18bestFit.clearBuffer();19console.log(bestFit.buffer);20console.log("Number of free blocks: " + bestFit.getFreeBlocks());21var BestFit = require('./BestFit.js');22var bestFit = new BestFit(100);23for(var i = 0; i < 10; i++){24 bestFit.insertBlock(10);25}26console.log(bestFit.buffer);27console.log("Number of free blocks: " + bestFit.getFreeBlocks());28bestFit.clearBuffer();29console.log(bestFit.buffer);30console.log("Number of free

Full Screen

Using AI Code Generation

copy

Full Screen

1function clearBuffer(){2 var editor = new BestInPlaceEditor(this);3 var textfield = document.getElementById('test4');4 editor.setValue(textfield.value);5 editor.activateForm();6 editor.clearBuffer();7}8function clearBuffer(){9 var editor = new BestInPlaceEditor(this);10 var textfield = document.getElementById('test5');11 editor.setValue(textfield.value);12 editor.activateForm();13 editor.clearBuffer();14}15function clearBuffer(){16 var editor = new BestInPlaceEditor(this);17 var textfield = document.getElementById('test6');18 editor.setValue(textfield.value);19 editor.activateForm();20 editor.clearBuffer();21}22function clearBuffer(){23 var editor = new BestInPlaceEditor(this);24 var textfield = document.getElementById('test7');25 editor.setValue(textfield.value);26 editor.activateForm();27 editor.clearBuffer();28}29function clearBuffer(){30 var editor = new BestInPlaceEditor(this);31 var textfield = document.getElementById('test8');32 editor.setValue(textfield.value);33 editor.activateForm();34 editor.clearBuffer();35}36function clearBuffer(){

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best 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