Best JavaScript code snippet using root
tree.js
Source:tree.js
...17 const e = new Node.Empty();18 const n1 = leaf('1', ['input'], true);19 const n2 = leaf('2', ['input'], true);20 const n3 = leaf('3', ['input'], true);21 this.eq(n1.and(e).renderText(), '1');22 this.eq(n1.or(e).renderText(), '1');23 this.eq(n1.renderText(), '1');24 this.eq(n1.not().renderText(), 'not 1');25 this.eq(n1.not().not().renderText(), '1');26 this.eq(n1.and(n2).prefix('where').renderText(), 'where 1 and 2');27 this.eq(n1.and(n2.prefix('where')).renderText(), '1 and (where 2)');28 this.eq(n1.prefix('where').and(n2).renderText(), '(where 1) and 2');29 this.eq(n1.and(n2).and(n3).renderText(), '1, 2 and 3');30 this.eq(n1.and(n2.and(n3)).renderText(), '1, 2 and 3');31 this.eq(n1.or(n2).and(n3).renderText(), '(either 1 or 2) and 3');32 this.eq(n1.or(n2.and(n3)).renderText(), 'either 1 or (2 and 3)');33 this.eq(n1.and(n2).or(n3).renderText(), 'either (1 and 2) or 3');34 this.eq(n1.and(n2.or(n3)).renderText(), '1 and (either 2 or 3)');35 this.eq(n1.or(n2).or(n3).renderText(), 'either 1, 2 or 3');36 this.eq(n1.or(n2.or(n3)).renderText(), 'either 1, 2 or 3');37 });38 test('tree', async function () {39 const e = new Node.Empty();40 const n1 = leaf('1', ['input'], false);41 const n2 = leaf('2', ['input'], false);42 const n3 = leaf('3', ['input'], false);43 this.eq(n1.and(e).renderTree(), 'â 1');44 this.eq(n1.or(e).renderTree(), 'â 1');45 this.eq(n1.renderTree(), 'â 1');46 this.eq(n1.not().renderTree(), 'â not 1');47 this.eq(n1.not().not().renderTree(), 'â 1');48 this.eq(49 n1.and(n2).prefix('where').renderTree(),50 'â where\nââ â 1\nââ â 2'51 );52 this.eq(53 n1.and(n2.prefix('where')).renderTree(),54 'â 1\nââ â where\n ââ â 2'55 );56 this.eq(57 n1.prefix('where').and(n2).renderTree(),58 'â\nââ â where\nâ ââ â 1\nââ â 2'59 );60 this.eq(n1.and(n2).and(n3).renderTree(), 'â 1\nââ â 2\nââ â 3');61 this.eq(n1.and(n2.and(n3)).renderTree(), 'â 1\nââ â 2\nââ â 3');62 this.eq(63 n1.or(n2).and(n3).renderTree(),64 'â\nââ â either\nâ ââ â 1\nâ ââ â 2\nââ â 3'65 );66 this.eq(67 n1.or(n2.and(n3)).renderTree(),68 'â either\nââ â 1\nââ â 2\n ââ â 3'69 );70 this.eq(71 n1.and(n2).or(n3).renderTree(),72 'â either\nââ â 1\nâ ââ â 2\nââ â 3'73 );74 this.eq(75 n1.and(n2.or(n3)).renderTree(),76 'â 1\nââ â either\n ââ â 2\n ââ â 3'77 );78 this.eq(79 n1.or(n2).or(n3).renderTree(),80 'â either\nââ â 1\nââ â 2\nââ â 3'81 );82 this.eq(83 n1.or(n2.or(n3)).renderTree(),84 'â either\nââ â 1\nââ â 2\nââ â 3'85 );86 });87 test('long text', async function () {88 const l = 'aoeusnthaoeusnthaoeusnthaoeusnthaoeusnthaoeusnth';89 const n = leaf(l, ['input'], true);90 this.eq(n.renderText(), l);91 this.eq(n.and(n).renderText(), `${l}\n ${l}`);92 this.eq(n.and(n).and(n).renderText(), `${l}\n ${l}\n ${l}`);93 });94 });95 test('Leaf.not', async function () {96 test('text', async function () {97 const e = new Node.Empty();98 const n1 = leaf('1', ['input'], true).not();99 const n2 = leaf('2', ['input'], true).not();100 const n3 = leaf('3', ['input'], true).not();101 this.eq(n1.and(e).renderText(), 'not 1');102 this.eq(n1.or(e).renderText(), 'not 1');103 this.eq(n1.renderText(), 'not 1');104 this.eq(n1.not().renderText(), '1');105 this.eq(n1.not().not().renderText(), 'not 1');106 this.eq(n1.and(n2).and(n3).renderText(), 'not 1, not 2 and not 3');107 this.eq(n1.and(n2.and(n3)).renderText(), 'not 1, not 2 and not 3');108 this.eq(109 n1.or(n2).and(n3).renderText(),110 '(either not 1 or not 2) and not 3'111 );112 this.eq(113 n1.or(n2.and(n3)).renderText(),114 'either not 1 or (not 2 and not 3)'115 );116 this.eq(117 n1.and(n2).or(n3).renderText(),118 'either (not 1 and not 2) or not 3'119 );120 this.eq(121 n1.and(n2.or(n3)).renderText(),122 'not 1 and (either not 2 or not 3)'123 );124 this.eq(n1.or(n2).or(n3).renderText(), 'either not 1, not 2 or not 3');125 this.eq(n1.or(n2.or(n3)).renderText(), 'either not 1, not 2 or not 3');126 });127 test('tree', async function () {128 const e = new Node.Empty();129 const n1 = leaf('1', ['input'], false).not();130 const n2 = leaf('2', ['input'], false).not();131 const n3 = leaf('3', ['input'], false).not();132 this.eq(n1.and(e).renderTree(), 'â not 1');133 this.eq(n1.or(e).renderTree(), 'â not 1');134 this.eq(n1.renderTree(), 'â not 1');135 this.eq(n1.not().renderTree(), 'â 1');136 this.eq(n1.not().not().renderTree(), 'â not 1');137 this.eq(138 n1.and(n2).and(n3).renderTree(),139 'â not 1\nââ â not 2\nââ â not 3'140 );141 this.eq(142 n1.and(n2.and(n3)).renderTree(),143 'â not 1\nââ â not 2\nââ â not 3'144 );145 this.eq(146 n1.or(n2).and(n3).renderTree(),147 'â\nââ â either\nâ ââ â not 1\nâ ââ â not 2\nââ â not 3'148 );149 this.eq(150 n1.or(n2.and(n3)).renderTree(),151 'â either\nââ â not 1\nââ â not 2\n ââ â not 3'152 );153 this.eq(154 n1.and(n2).or(n3).renderTree(),155 'â either\nââ â not 1\nâ ââ â not 2\nââ â not 3'156 );157 this.eq(158 n1.and(n2.or(n3)).renderTree(),159 'â not 1\nââ â either\n ââ â not 2\n ââ â not 3'160 );161 this.eq(162 n1.or(n2).or(n3).renderTree(),163 'â either\nââ â not 1\nââ â not 2\nââ â not 3'164 );165 this.eq(166 n1.or(n2.or(n3)).renderTree(),167 'â either\nââ â not 1\nââ â not 2\nââ â not 3'168 );169 });170 });171 test('Branch', async function () {172 test('text', async function () {173 const e = new Node.Empty();174 const n1 = leaf('1', ['input'], true).prefix('where');175 const n2 = leaf('2', ['input'], true).prefix('where');176 const n3 = leaf('3', ['input'], true).prefix('where');177 this.eq(n1.and(e).renderText(), 'where 1');178 this.eq(n1.or(e).renderText(), 'where 1');179 this.eq(n1.renderText(), 'where 1');180 this.eq(n1.not().renderText(), 'not (where 1)');181 this.eq(n1.not().not().renderText(), 'where 1');182 this.eq(183 n1.and(n2).and(n3).renderText(),184 '(where 1), (where 2) and (where 3)'185 );186 this.eq(187 n1.and(n2.and(n3)).renderText(),188 '(where 1), (where 2) and (where 3)'189 );190 this.eq(191 n1.or(n2).and(n3).renderText(),192 '(either (where 1) or (where 2)) and (where 3)'193 );194 this.eq(195 n1.or(n2.and(n3)).renderText(),196 'either (where 1) or ((where 2) and (where 3))'197 );198 this.eq(199 n1.and(n2).or(n3).renderText(),200 'either ((where 1) and (where 2)) or (where 3)'201 );202 this.eq(203 n1.and(n2.or(n3)).renderText(),204 '(where 1) and (either (where 2) or (where 3))'205 );206 this.eq(207 n1.or(n2).or(n3).renderText(),208 'either (where 1), (where 2) or (where 3)'209 );210 this.eq(211 n1.or(n2.or(n3)).renderText(),212 'either (where 1), (where 2) or (where 3)'213 );214 });215 test('tree', async function () {216 const e = new Node.Empty();217 const n1 = leaf('1', ['input'], false).prefix('where');218 const n2 = leaf('2', ['input'], false).prefix('where');219 const n3 = leaf('3', ['input'], false).prefix('where');220 this.eq(n1.and(e).renderTree(), 'â where\nââ â 1');221 this.eq(n1.or(e).renderTree(), 'â where\nââ â 1');222 this.eq(n1.renderTree(), 'â where\nââ â 1');223 this.eq(n1.not().renderTree(), 'â not\nââ â where\n ââ â 1');224 this.eq(n1.not().not().renderTree(), 'â where\nââ â 1');225 this.eq(226 n1.and(n2).and(n3).renderTree(),227 'â\nââ â where\nâ ââ â 1\nââ â where\nâ ââ â 2\nââ â where\n' +228 ' ââ â 3'229 );230 this.eq(231 n1.and(n2.and(n3)).renderTree(),232 'â\nââ â where\nâ ââ â 1\nââ â where\nâ ââ â 2\nââ â where\n' +233 ' ââ â 3'234 );235 this.eq(236 n1.or(n2).and(n3).renderTree(),237 'â\nââ â either\nâ ââ â where\nâ â ââ â 1\nâ ââ â where\n' +238 'â ââ â 2\nââ â where\n ââ â 3'239 );240 this.eq(241 n1.or(n2.and(n3)).renderTree(),242 'â either\nââ â where\nâ ââ â 1\nââ â\n ââ â where\n' +243 ' â ââ â 2\n ââ â where\n ââ â 3'244 );245 this.eq(246 n1.and(n2).or(n3).renderTree(),247 'â either\nââ â\nâ ââ â where\nâ â ââ â 1\nâ ââ â where\n' +248 'â ââ â 2\nââ â where\n ââ â 3'249 );250 this.eq(251 n1.and(n2.or(n3)).renderTree(),252 'â\nââ â where\nâ ââ â 1\nââ â either\n ââ â where\n' +253 ' â ââ â 2\n ââ â where\n ââ â 3'254 );255 this.eq(256 n1.or(n2).or(n3).renderTree(),257 'â either\nââ â where\nâ ââ â 1\nââ â where\nâ ââ â 2\n' +258 'ââ â where\n ââ â 3'259 );260 this.eq(261 n1.or(n2.or(n3)).renderTree(),262 'â either\nââ â where\nâ ââ â 1\nââ â where\nâ ââ â 2\n' +263 'ââ â where\n ââ â 3'264 );265 });266 });267 test('And', async function () {268 test('text', async function () {269 const e = new Node.Empty();270 const n1 = leaf('1', ['input'], true).and(leaf('2', ['input'], true));271 const n2 = leaf('3', ['input'], true).and(leaf('4', ['input'], true));272 const n3 = leaf('5', ['input'], true).and(leaf('6', ['input'], true));273 this.eq(n1.and(e).renderText(), '1 and 2');274 this.eq(n1.or(e).renderText(), '1 and 2');275 this.eq(n1.renderText(), '1 and 2');276 this.eq(n1.not().renderText(), 'not (1 and 2)');277 this.eq(n1.not().not().renderText(), '1 and 2');278 this.eq(n1.and(n2).and(n3).renderText(), '1, 2, 3, 4, 5 and 6');279 this.eq(n1.and(n2.and(n3)).renderText(), '1, 2, 3, 4, 5 and 6');280 this.eq(281 n1.or(n2).and(n3).renderText(),282 '(either (1 and 2) or (3 and 4)), 5 and 6'283 );284 this.eq(285 n1.or(n2.and(n3)).renderText(),286 'either (1 and 2) or (3, 4, 5 and 6)'287 );288 this.eq(289 n1.and(n2).or(n3).renderText(),290 'either (1, 2, 3 and 4) or (5 and 6)'291 );292 this.eq(293 n1.and(n2.or(n3)).renderText(),294 '1, 2 and (either (3 and 4) or (5 and 6))'295 );296 this.eq(297 n1.or(n2).or(n3).renderText(),298 'either (1 and 2), (3 and 4) or (5 and 6)'299 );300 this.eq(301 n1.or(n2.or(n3)).renderText(),302 'either (1 and 2), (3 and 4) or (5 and 6)'303 );304 });305 test('tree', async function () {306 const e = new Node.Empty();307 const n1 = leaf('1', ['input'], false).and(leaf('2', ['input'], false));308 const n2 = leaf('3', ['input'], false).and(leaf('4', ['input'], false));309 const n3 = leaf('5', ['input'], false).and(leaf('6', ['input'], false));310 this.eq(n1.and(e).renderTree(), 'â 1\nââ â 2');311 this.eq(n1.or(e).renderTree(), 'â 1\nââ â 2');312 this.eq(n1.renderTree(), 'â 1\nââ â 2');313 this.eq(n1.not().renderTree(), 'â not\nââ â 1\nââ â 2');314 this.eq(n1.not().not().renderTree(), 'â 1\nââ â 2');315 this.eq(316 n1.and(n2).and(n3).renderTree(),317 'â 1\nââ â 2\nââ â 3\nââ â 4\nââ â 5\nââ â 6'318 );319 this.eq(320 n1.and(n2.and(n3)).renderTree(),321 'â 1\nââ â 2\nââ â 3\nââ â 4\nââ â 5\nââ â 6'322 );323 this.eq(324 n1.or(n2).and(n3).renderTree(),325 'â\nââ â either\nâ ââ â 1\nâ â ââ â 2\nâ ââ â 3\n' +326 'â ââ â 4\nââ â 5\nââ â 6'327 );328 this.eq(329 n1.or(n2.and(n3)).renderTree(),330 'â either\nââ â 1\nâ ââ â 2\nââ â 3\n ââ â 4\n ââ â 5\n' +331 ' ââ â 6'332 );333 this.eq(334 n1.and(n2).or(n3).renderTree(),335 'â either\nââ â 1\nâ ââ â 2\nâ ââ â 3\nâ ââ â 4\nââ â 5\n' +336 ' ââ â 6'337 );338 this.eq(339 n1.and(n2.or(n3)).renderTree(),340 'â 1\nââ â 2\nââ â either\n ââ â 3\n â ââ â 4\n ââ â 5\n' +341 ' ââ â 6'342 );343 this.eq(344 n1.or(n2).or(n3).renderTree(),345 'â either\nââ â 1\nâ ââ â 2\nââ â 3\nâ ââ â 4\nââ â 5\n ââ â 6'346 );347 this.eq(348 n1.or(n2.or(n3)).renderTree(),349 'â either\nââ â 1\nâ ââ â 2\nââ â 3\nâ ââ â 4\nââ â 5\n ââ â 6'350 );351 });352 });353 test('Or', async function () {354 test('text', async function () {355 const e = new Node.Empty();356 const n1 = leaf('1', ['input'], true).or(leaf('2', ['input'], true));357 const n2 = leaf('3', ['input'], true).or(leaf('4', ['input'], true));358 const n3 = leaf('5', ['input'], true).or(leaf('6', ['input'], true));359 this.eq(n1.and(e).renderText(), 'either 1 or 2');360 this.eq(n1.or(e).renderText(), 'either 1 or 2');361 this.eq(n1.renderText(), 'either 1 or 2');362 this.eq(n1.not().renderText(), 'neither 1 nor 2');363 this.eq(n1.not().not().renderText(), 'either 1 or 2');364 this.eq(365 n1.and(n2).and(n3).renderText(),366 '(either 1 or 2), (either 3 or 4) and (either 5 or 6)'367 );368 this.eq(369 n1.and(n2.and(n3)).renderText(),370 '(either 1 or 2), (either 3 or 4) and (either 5 or 6)'371 );372 this.eq(373 n1.or(n2).and(n3).renderText(),374 '(either 1, 2, 3 or 4) and (either 5 or 6)'375 );376 this.eq(377 n1.or(n2.and(n3)).renderText(),378 'either 1, 2 or ((either 3 or 4) and (either 5 or 6))'379 );380 this.eq(381 n1.and(n2).or(n3).renderText(),382 'either ((either 1 or 2) and (either 3 or 4)), 5 or 6'383 );384 this.eq(385 n1.and(n2.or(n3)).renderText(),386 '(either 1 or 2) and (either 3, 4, 5 or 6)'387 );388 this.eq(n1.or(n2).or(n3).renderText(), 'either 1, 2, 3, 4, 5 or 6');389 this.eq(n1.or(n2.or(n3)).renderText(), 'either 1, 2, 3, 4, 5 or 6');390 });391 test('tree', async function () {392 const e = new Node.Empty();393 const n1 = leaf('1', ['input'], false).or(leaf('2', ['input'], false));394 const n2 = leaf('3', ['input'], false).or(leaf('4', ['input'], false));395 const n3 = leaf('5', ['input'], false).or(leaf('6', ['input'], false));396 this.eq(n1.and(e).renderTree(), 'â either\nââ â 1\nââ â 2');397 this.eq(n1.or(e).renderTree(), 'â either\nââ â 1\nââ â 2');398 this.eq(n1.renderTree(), 'â either\nââ â 1\nââ â 2');399 this.eq(n1.not().renderTree(), 'â neither\nââ â 1\nââ â 2');400 this.eq(n1.not().not().renderTree(), 'â either\nââ â 1\nââ â 2');401 this.eq(402 n1.and(n2).and(n3).renderTree(),403 'â\nââ â either\nâ ââ â 1\nâ ââ â 2\nââ â either\nâ ââ â 3\n' +404 'â ââ â 4\nââ â either\n ââ â 5\n ââ â 6'405 );406 this.eq(407 n1.and(n2.and(n3)).renderTree(),408 'â\nââ â either\nâ ââ â 1\nâ ââ â 2\nââ â either\nâ ââ â 3\n' +409 'â ââ â 4\nââ â either\n ââ â 5\n ââ â 6'410 );411 this.eq(412 n1.or(n2).and(n3).renderTree(),413 'â\nââ â either\nâ ââ â 1\nâ ââ â 2\nâ ââ â 3\nâ ââ â 4\n' +414 'ââ â either\n ââ â 5\n ââ â 6'415 );416 this.eq(417 n1.or(n2.and(n3)).renderTree(),418 'â either\nââ â 1\nââ â 2\nââ â\n ââ â either\n â ââ â 3\n' +419 ' â ââ â 4\n ââ â either\n ââ â 5\n ââ â 6'420 );421 this.eq(422 n1.and(n2).or(n3).renderTree(),423 'â either\nââ â\nâ ââ â either\nâ â ââ â 1\nâ â ââ â 2\n' +424 'â ââ â either\nâ ââ â 3\nâ ââ â 4\nââ â 5\nââ â 6'425 );426 this.eq(427 n1.and(n2.or(n3)).renderTree(),428 'â\nââ â either\nâ ââ â 1\nâ ââ â 2\nââ â either\n ââ â 3\n' +429 ' ââ â 4\n ââ â 5\n ââ â 6'430 );431 this.eq(432 n1.or(n2).or(n3).renderTree(),433 'â either\nââ â 1\nââ â 2\nââ â 3\nââ â 4\nââ â 5\nââ â 6'434 );435 this.eq(436 n1.or(n2.or(n3)).renderTree(),437 'â either\nââ â 1\nââ â 2\nââ â 3\nââ â 4\nââ â 5\nââ â 6'438 );439 });440 });441 test('Nand', async function () {442 test('text', async function () {443 const e = new Node.Empty();444 const n1 = leaf('1', ['input'], true)445 .and(leaf('2', ['input'], true))446 .not();447 const n2 = leaf('3', ['input'], true)448 .and(leaf('4', ['input'], true))449 .not();450 const n3 = leaf('5', ['input'], true)451 .and(leaf('6', ['input'], true))452 .not();453 this.eq(n1.and(e).renderText(), 'not (1 and 2)');454 this.eq(n1.or(e).renderText(), 'not (1 and 2)');455 this.eq(n1.renderText(), 'not (1 and 2)');456 this.eq(n1.not().renderText(), '1 and 2');457 this.eq(n1.not().not().renderText(), 'not (1 and 2)');458 this.eq(459 n1.and(n2).and(n3).renderText(),460 '(not (1 and 2)), (not (3 and 4)) and (not (5 and 6))'461 );462 this.eq(463 n1.and(n2.and(n3)).renderText(),464 '(not (1 and 2)), (not (3 and 4)) and (not (5 and 6))'465 );466 this.eq(467 n1.or(n2).and(n3).renderText(),468 '\n either (not (1 and 2)) or (not (3 and 4))\n not (5 and 6)'469 );470 this.eq(471 n1.or(n2.and(n3)).renderText(),472 'either\n not (1 and 2)\n (not (3 and 4)) and (not (5 and 6))'473 );474 this.eq(475 n1.and(n2).or(n3).renderText(),476 'either\n (not (1 and 2)) and (not (3 and 4))\n not (5 and 6)'477 );478 this.eq(479 n1.and(n2.or(n3)).renderText(),480 '\n not (1 and 2)\n either (not (3 and 4)) or (not (5 and 6))'481 );482 this.eq(483 n1.or(n2).or(n3).renderText(),484 'either (not (1 and 2)), (not (3 and 4)) or (not (5 and 6))'485 );486 this.eq(487 n1.or(n2.or(n3)).renderText(),488 'either (not (1 and 2)), (not (3 and 4)) or (not (5 and 6))'489 );490 });491 test('tree', async function () {492 const e = new Node.Empty();493 const n1 = leaf('1', ['input'], false)494 .and(leaf('2', ['input'], false))495 .not();496 const n2 = leaf('3', ['input'], false)497 .and(leaf('4', ['input'], false))498 .not();499 const n3 = leaf('5', ['input'], false)500 .and(leaf('6', ['input'], false))501 .not();502 this.eq(n1.and(e).renderTree(), 'â not\nââ â 1\nââ â 2');503 this.eq(n1.or(e).renderTree(), 'â not\nââ â 1\nââ â 2');504 this.eq(n1.renderTree(), 'â not\nââ â 1\nââ â 2');505 this.eq(n1.not().renderTree(), 'â 1\nââ â 2');506 this.eq(n1.not().not().renderTree(), 'â not\nââ â 1\nââ â 2');507 this.eq(508 n1.and(n2).and(n3).renderTree(),509 'â\nââ â not\nâ ââ â 1\nâ ââ â 2\nââ â not\nâ ââ â 3\n' +510 'â ââ â 4\nââ â not\n ââ â 5\n ââ â 6'511 );512 this.eq(513 n1.and(n2.and(n3)).renderTree(),514 'â\nââ â not\nâ ââ â 1\nâ ââ â 2\nââ â not\nâ ââ â 3\n' +515 'â ââ â 4\nââ â not\n ââ â 5\n ââ â 6'516 );517 this.eq(518 n1.or(n2).and(n3).renderTree(),519 'â\nââ â either\nâ ââ â not\nâ â ââ â 1\nâ â ââ â 2\n' +520 'â ââ â not\nâ ââ â 3\nâ ââ â 4\nââ â not\n ââ â 5\n' +521 ' ââ â 6'522 );523 this.eq(524 n1.or(n2.and(n3)).renderTree(),525 'â either\nââ â not\nâ ââ â 1\nâ ââ â 2\nââ â\n ââ â not\n' +526 ' â ââ â 3\n â ââ â 4\n ââ â not\n ââ â 5\n' +527 ' ââ â 6'528 );529 this.eq(530 n1.and(n2).or(n3).renderTree(),531 'â either\nââ â\nâ ââ â not\nâ â ââ â 1\nâ â ââ â 2\n' +532 'â ââ â not\nâ ââ â 3\nâ ââ â 4\nââ â not\n ââ â 5\n' +533 ' ââ â 6'534 );535 this.eq(536 n1.and(n2.or(n3)).renderTree(),537 'â\nââ â not\nâ ââ â 1\nâ ââ â 2\nââ â either\n ââ â not\n' +538 ' â ââ â 3\n â ââ â 4\n ââ â not\n ââ â 5\n' +539 ' ââ â 6'540 );541 this.eq(542 n1.or(n2).or(n3).renderTree(),543 'â either\nââ â not\nâ ââ â 1\nâ ââ â 2\nââ â not\nâ ââ â 3\n' +544 'â ââ â 4\nââ â not\n ââ â 5\n ââ â 6'545 );546 this.eq(547 n1.or(n2.or(n3)).renderTree(),548 'â either\nââ â not\nâ ââ â 1\nâ ââ â 2\nââ â not\nâ ââ â 3\n' +549 'â ââ â 4\nââ â not\n ââ â 5\n ââ â 6'550 );551 });552 });553 test('Nor', async function () {554 test('text', async function () {555 const e = new Node.Empty();556 const n1 = leaf('1', ['input'], true)557 .or(leaf('2', ['input'], true))558 .not();559 const n2 = leaf('3', ['input'], true)560 .or(leaf('4', ['input'], true))561 .not();562 const n3 = leaf('5', ['input'], true)563 .or(leaf('6', ['input'], true))564 .not();565 this.eq(n1.and(e).renderText(), 'neither 1 nor 2');566 this.eq(n1.or(e).renderText(), 'neither 1 nor 2');567 this.eq(n1.renderText(), 'neither 1 nor 2');568 this.eq(n1.not().renderText(), 'either 1 or 2');569 this.eq(n1.not().not().renderText(), 'neither 1 nor 2');570 this.eq(571 n1.and(n2).and(n3).renderText(),572 '\n neither 1 nor 2\n neither 3 nor 4\n neither 5 nor 6'573 );574 this.eq(575 n1.and(n2.and(n3)).renderText(),576 '\n neither 1 nor 2\n neither 3 nor 4\n neither 5 nor 6'577 );578 this.eq(579 n1.or(n2).and(n3).renderText(),580 '\n either (neither 1 nor 2) or (neither 3 nor 4)\n' +581 ' neither 5 nor 6'582 );583 this.eq(584 n1.or(n2.and(n3)).renderText(),585 'either\n neither 1 nor 2\n' +586 ' (neither 3 nor 4) and (neither 5 nor 6)'587 );588 this.eq(589 n1.and(n2).or(n3).renderText(),590 'either\n (neither 1 nor 2) and (neither 3 nor 4)\n' +591 ' neither 5 nor 6'592 );593 this.eq(594 n1.and(n2.or(n3)).renderText(),595 '\n neither 1 nor 2\n' +596 ' either (neither 3 nor 4) or (neither 5 nor 6)'597 );598 this.eq(599 n1.or(n2).or(n3).renderText(),600 'either\n neither 1 nor 2\n neither 3 nor 4\n neither 5 nor 6'601 );602 this.eq(603 n1.or(n2.or(n3)).renderText(),604 'either\n neither 1 nor 2\n neither 3 nor 4\n neither 5 nor 6'605 );606 });607 test('tree', async function () {608 const e = new Node.Empty();609 const n1 = leaf('1', ['input'], false)610 .or(leaf('2', ['input'], false))611 .not();612 const n2 = leaf('3', ['input'], false)613 .or(leaf('4', ['input'], false))614 .not();615 const n3 = leaf('5', ['input'], false)616 .or(leaf('6', ['input'], false))617 .not();...
dmtalpha.ts
Source:dmtalpha.ts
...68 [69 createAuthorsHtml(entry),70 createTitleHtml(entry),71 [72 renderText(journal),73 volume ? `<b>${volume}</b>` : undefined,74 year ? `(${year})` : undefined,75 ]76 .filter(Boolean)77 .join(' '),78 renderNumberOrUndefined(number),79 renderText(pages),80 renderText(note),81 ]82 .filter(Boolean)83 .join(', ') + '.'84 )85}86const createBookHtmlElem = (entry: bibtypes.Book): HTMLString => {87 const {88 edition,89 series,90 volume,91 publisher,92 address,93 month,94 year,95 note,96 } = entry.entryTags97 return (98 [99 bibtypes.entryHasAuthor(entry)100 ? createAuthorsHtml(entry)101 : createEditorsHtml(entry as bibtypes.BibtexEntryWithEditor),102 createTitleHtml(entry),103 renderEditionOrUndefined(edition),104 renderText(series),105 renderVolumeOrUndefined(volume),106 renderText(publisher),107 renderText(address),108 renderDateOrUndefined(month, year),109 renderText(note),110 ]111 .filter(Boolean)112 .join(', ') + '.'113 )114}115const createBookletHtmlElem = (entry: bibtypes.Booklet): HTMLString => {116 const { howpublished, address, month, year, note } = entry.entryTags117 return (118 [119 bibtypes.entryHasAuthor(entry) ? createAuthorsHtml(entry) : undefined,120 createTitleHtml(entry),121 renderText(howpublished),122 renderText(address),123 renderDateOrUndefined(month, year),124 renderText(note),125 ]126 .filter(Boolean)127 .join(', ') + '.'128 )129}130const createInBookHtmlElem = (entry: bibtypes.InBook): HTMLString => {131 const {132 volume,133 number,134 series,135 chapter,136 edition,137 publisher,138 address,139 pages,140 month,141 year,142 note,143 } = entry.entryTags144 return (145 [146 bibtypes.entryHasAuthor(entry)147 ? createAuthorsHtml(entry)148 : createEditorsHtml(entry as bibtypes.BibtexEntryWithEditor),149 createTitleHtml(entry),150 renderEditionOrUndefined(edition),151 renderText(series),152 renderVolumeOrUndefined(volume),153 renderNumberOrUndefined(number),154 renderChapterOrUndefined(chapter),155 renderPagesOrUndefined(pages),156 renderText(publisher),157 renderText(address),158 renderDateOrUndefined(month, year),159 renderText(note),160 ]161 .filter(Boolean)162 .join(', ') + '.'163 )164}165const createInCollectionHtmlElem = (166 entry: bibtypes.InCollection167): HTMLString => {168 const {169 booktitle,170 series,171 volume,172 publisher,173 address,174 edition,175 month,176 year,177 note,178 pages,179 } = entry.entryTags180 return (181 [182 createAuthorsHtml(entry),183 createTitleHtml(entry),184 renderText(booktitle) +185 (bibtypes.entryHasEditor(entry) ? `(${createEditorsHtml(entry)})` : ''),186 renderText(series),187 renderVolumeOrUndefined(volume),188 renderText(publisher),189 renderText(address),190 renderEditionOrUndefined(edition),191 renderDateOrUndefined(month, year),192 renderText(note),193 renderPagesOrUndefined(pages),194 ]195 .filter(Boolean)196 .join(', ') + '.'197 )198}199const createInProceedingsHtmlElem = (200 entry: bibtypes.InProceedings201): HTMLString => {202 const {203 booktitle,204 series,205 volume,206 publisher,207 address,208 organization,209 month,210 year,211 note,212 pages,213 } = entry.entryTags214 let booktitleString = undefined215 if (booktitle) {216 booktitleString = [217 renderText(booktitle),218 address ? `(${renderText(address)})` : undefined,219 bibtypes.entryHasEditor(entry)220 ? `(${createEditorsHtml(entry)})`221 : undefined,222 ]223 .filter(Boolean)224 .join(' ')225 }226 return (227 [228 createAuthorsHtml(entry),229 createTitleHtml(entry),230 booktitleString,231 renderText(series),232 renderVolumeOrUndefined(volume),233 renderText(organization),234 renderText(publisher),235 renderDateOrUndefined(month, year),236 renderText(note),237 renderPagesOrUndefined(pages),238 ]239 .filter(Boolean)240 .join(', ') + '.'241 )242}243const createManualHtmlElem = (entry: bibtypes.Manual): HTMLString => {244 const { organization, address, edition, month, year, note } = entry.entryTags245 return (246 [247 bibtypes.entryHasAuthor(entry) ? createAuthorsHtml(entry) : undefined,248 createTitleHtml(entry),249 renderText(organization),250 renderText(address),251 renderEditionOrUndefined(edition),252 renderDateOrUndefined(month, year),253 renderText(note),254 ]255 .filter(Boolean)256 .join(', ') + '.'257 )258}259const createMastersThesisHtmlElem = (260 entry: bibtypes.MastersThesis261): HTMLString => {262 const { school, address, month, year, note } = entry.entryTags263 return (264 [265 createAuthorsHtml(entry),266 createTitleHtml(entry),267 `Master's thesis`,268 renderText(school),269 renderText(address),270 renderDateOrUndefined(month, year),271 renderText(note),272 ]273 .filter(Boolean)274 .join(', ') + '.'275 )276}277const createMiscHtmlElem = (entry: bibtypes.Misc): HTMLString => {278 const { howpublished, month, year, note } = entry.entryTags279 return (280 [281 bibtypes.entryHasAuthor(entry) ? createAuthorsHtml(entry) : undefined,282 entry.entryTags.title ? createTitleHtml(entry) : undefined,283 renderText(howpublished),284 renderDateOrUndefined(month, year),285 renderText(note),286 ]287 .filter(Boolean)288 .join(', ') + '.'289 )290}291const createPhdThesisHtmlElem = (entry: bibtypes.PhdThesis): HTMLString => {292 const { school, address, month, year, note } = entry.entryTags293 return (294 [295 createAuthorsHtml(entry),296 createTitleHtml(entry),297 `Ph.D. thesis`,298 renderText(school),299 renderText(address),300 renderDateOrUndefined(month, year),301 renderText(note),302 ]303 .filter(Boolean)304 .join(', ') + '.'305 )306}307const createProceedingsHtmlElem = (entry: bibtypes.Proceedings): HTMLString => {308 const {309 series,310 volume,311 address,312 organization,313 publisher,314 month,315 year,316 note,317 } = entry.entryTags318 return (319 [320 bibtypes.entryHasEditor(entry) ? createEditorsHtml(entry) : undefined,321 createTitleHtml(entry),322 renderText(series),323 renderVolumeOrUndefined(volume),324 renderText(address),325 renderText(organization),326 renderText(publisher),327 renderDateOrUndefined(month, year),328 renderText(note),329 ]330 .filter(Boolean)331 .join(', ') + '.'332 )333}334const createTechReportHtmlElem = (entry: bibtypes.TechReport): HTMLString => {335 const { number, institution, address, month, year, note } = entry.entryTags336 return (337 [338 createAuthorsHtml(entry),339 createTitleHtml(entry),340 number ? `Tech. Report ${number}` : undefined,341 renderText(institution),342 renderText(address),343 renderDateOrUndefined(month, year),344 renderText(note),345 ]346 .filter(Boolean)347 .join(', ') + '.'348 )349}350const createUnpublishedHtmlElem = (entry: bibtypes.Unpublished): HTMLString => {351 const { note, month, year } = entry.entryTags352 return (353 [354 createAuthorsHtml(entry),355 createTitleHtml(entry),356 renderText(note),357 renderDateOrUndefined(month, year),358 ]359 .filter(Boolean)360 .join(', ') + '.'361 )362}363const createPeopleString = (people: Person[]): string => {364 const names = people.map(author =>365 [author.firstName, author.lastName].filter(Boolean).join(' ')366 )367 if (names.length === 1) {368 return names[0]369 } else if (names.length === 2) {370 return `${names[0]} and ${names[1]}`371 } else {372 return names.slice(0, -1).join(', ') + `, and ${names.slice(-1)[0]}`373 }374}375const createEditorsHtml = (376 entry: bibtypes.BibtexEntryWithEditor377): HTMLString => {378 const editors = parsePeople(entry.entryTags.editor)379 const edSuffix = `(ed${editors.length > 1 ? 's' : ''})`380 return `${createPeopleString(editors)} ${edSuffix}`381}382const createAuthorsHtml = (383 entry: bibtypes.BibtexEntryWithAuthor384): HTMLString => {385 const authors = parsePeople(entry.entryTags.author)386 return createPeopleString(authors)387}388const createTitleHtml = (entry: bibtypes.BibtexEntry): HTMLString => {389 const { url, title } = entry.entryTags390 let result = `<span class="italic">${renderText(title)}</span>` as string391 if (url) {392 return `<a href="${url}">${result}</a>`393 }394 return result...
buttonNames.js
Source:buttonNames.js
1import DevCommand from '../Commands/DevCommand';2import MultCommand from '../Commands/MultCommand';3import MinusCommand from '../Commands/MinusCommand';4import PlusCommand from '../Commands/PlusCommand';5import PlusMinusCommand from '../Commands/PlusMinusCommand';6import PercentCommand from '../Commands/PercentCommand';7import XSquareCommand from '../Commands/XSquareCommand';8import XCubeCommand from '../Commands/XCubeCommand';9import XInYCommand from '../Commands/XInYCommand';10import EInxCommand from '../Commands/EInxCommand';11import TenInXCommand from '../Commands/TenInXCommand';12import OneDevXCommand from '../Commands/OneDevXCommand';13import SquareRootCommand from '../Commands/SquareRootCommand';14import CubeRootCommand from '../Commands/CubeRootCommand';15import YRootCommand from '../Commands/YRootCommand';16import XFactCommand from '../Commands/XFactCommand';17import MCCommand from '../Commands/MCCommand';18import MMinusCommand from '../Commands/MMinusCommand';19import MPlusCommand from '../Commands/MPlusCommand';20import MRCommand from '../Commands/MRCommand';21const buttonNames = {22 getButtonByOperator(operator) {23 return this[Object.keys(this).reduce((prev, curr) => {24 if (this[curr].renderText === operator) {25 return curr;26 }27 return prev;28 }, {})];29 },30 mc: {31 name: 'mc',32 buttonText: 'mc',33 Command: MCCommand,34 },35 mPlus: {36 name: 'mPlus',37 buttonText: 'm+',38 Command: MPlusCommand,39 },40 mMinus: {41 name: 'mMinus',42 buttonText: 'm-',43 Command: MMinusCommand,44 },45 mr: {46 name: 'mr',47 buttonText: 'mr',48 Command: MRCommand,49 },50 xSquare: {51 name: 'xSquare',52 buttonText: 'x²',53 renderText: '²',54 Command: XSquareCommand,55 },56 xCube: {57 name: 'xCube',58 buttonText: 'x³',59 renderText: '³',60 Command: XCubeCommand,61 },62 xy: {63 name: 'xy',64 buttonText: 'xʸ',65 renderText: '^',66 Command: XInYCommand,67 },68 ex: {69 name: 'ex',70 buttonText: 'eË£',71 renderText: '2.71828182846^',72 Command: EInxCommand,73 },74 tenInX: {75 name: 'tenInX',76 buttonText: '10Ë£',77 renderText: '10^',78 Command: TenInXCommand,79 },80 oneDevX: {81 name: 'oneDevX',82 buttonText: '1/x',83 renderText: '1/',84 Command: OneDevXCommand,85 },86 squareRoot: {87 name: 'squareRoot',88 buttonText: '²â',89 renderText: '²â',90 Command: SquareRootCommand,91 },92 cubeRoot: {93 name: 'cubeRoot',94 buttonText: '³â',95 renderText: '³â',96 Command: CubeRootCommand,97 },98 yRoot: {99 name: 'yRoot',100 buttonText: 'ʸâ',101 renderText: 'â',102 Command: YRootCommand,103 },104 xFact: {105 name: 'xFact',106 buttonText: 'x!',107 renderText: '!',108 Command: XFactCommand,109 },110 reset: {111 name: 'reset',112 buttonText: 'AC',113 Command: null,114 },115 plusMinus: {116 name: 'plusMinus',117 buttonText: '+/-',118 renderText: '-',119 Command: PlusMinusCommand,120 },121 percent: {122 name: 'percent',123 buttonText: '%',124 renderText: '%',125 Command: PercentCommand,126 },127 dev: {128 name: 'dev',129 buttonText: '/',130 renderText: '/',131 Command: DevCommand,132 },133 mult: {134 name: 'mult',135 buttonText: '*',136 renderText: '*',137 Command: MultCommand,138 },139 minus: {140 name: 'minus',141 buttonText: '-',142 renderText: '-',143 Command: MinusCommand,144 },145 plus: {146 name: 'plus',147 buttonText: '+',148 renderText: '+',149 Command: PlusCommand,150 },151 eq: {152 name: 'eq',153 buttonText: '=',154 renderText: '=',155 Command: null,156 },157 one: {158 name: 'one',159 buttonText: '1',160 renderText: '1',161 Command: null,162 },163 two: {164 name: 'two',165 buttonText: '2',166 renderText: '2',167 Command: null,168 },169 three: {170 name: 'three',171 buttonText: '3',172 renderText: '3',173 Command: null,174 },175 four: {176 name: 'four',177 buttonText: '4',178 renderText: '4',179 Command: null,180 },181 five: {182 name: 'five',183 buttonText: '5',184 renderText: '5',185 Command: null,186 },187 six: {188 name: 'six',189 buttonText: '6',190 renderText: '6',191 Command: null,192 },193 seven: {194 name: 'seven',195 buttonText: '7',196 renderText: '7',197 Command: null,198 },199 eight: {200 name: 'eight',201 buttonText: '8',202 renderText: '8',203 Command: null,204 },205 nine: {206 name: 'nine',207 buttonText: '9',208 renderText: '9',209 Command: null,210 },211 zero: {212 name: 'zero',213 buttonText: '0',214 renderText: '0',215 Command: null,216 },217 dot: {218 name: 'dot',219 buttonText: '.',220 renderText: '.',221 Command: null,222 },223 unDo: {224 name: 'unDo',225 buttonText: 'bck',226 Command: null,227 },228};229const buttonsHard = [230 buttonNames.mc,231 buttonNames.mPlus,232 buttonNames.mMinus,233 buttonNames.mr,234 buttonNames.xSquare,235 buttonNames.xCube,236 buttonNames.xy,237 buttonNames.ex,238 buttonNames.tenInX,239 buttonNames.oneDevX,240 buttonNames.squareRoot,241 buttonNames.cubeRoot,242 buttonNames.yRoot,243 buttonNames.xFact,244 buttonNames.unDo,245];246const buttonsSimpleUp = [247 buttonNames.reset,248 buttonNames.plusMinus,249 buttonNames.percent,250];251const buttonsSimpleRight = [252 buttonNames.dev,253 buttonNames.mult,254 buttonNames.minus,255 buttonNames.plus,256 buttonNames.eq,257];258const buttonsNumbers = [259 buttonNames.seven,260 buttonNames.eight,261 buttonNames.nine,262 buttonNames.four,263 buttonNames.five,264 buttonNames.six,265 buttonNames.one,266 buttonNames.two,267 buttonNames.three,268 buttonNames.zero,269 buttonNames.dot,270];271const resetableButtons = [272 buttonNames.eq,273 buttonNames.xSquare,274 buttonNames.xCube,275 buttonNames.ex,276 buttonNames.tenInX,277 buttonNames.oneDevX,278 buttonNames.percent,279 buttonNames.squareRoot,280 buttonNames.cubeRoot,281 buttonNames.xFact,282 buttonNames.mMinus,283 buttonNames.mPlus,284 buttonNames.unDo,285];286const memoryButtons = [287 buttonNames.mc,288 buttonNames.mPlus,289 buttonNames.mMinus,290 buttonNames.mr,291];292const answerWithOneOperand = [293 buttonNames.xSquare,294 buttonNames.xCube,295 buttonNames.ex,296 buttonNames.tenInX,297 buttonNames.squareRoot,298 buttonNames.cubeRoot,299 buttonNames.xFact,300];301const answerWithTwoOperands = [302 buttonNames.dev,303 buttonNames.mult,304 buttonNames.minus,305 buttonNames.plus,306 buttonNames.xy,307 buttonNames.yRoot,308];309const changeOneOperand = [310 buttonNames.oneDevX,311 buttonNames.plusMinus,312 buttonNames.percent,313];314export {315 buttonsHard,316 buttonsSimpleUp,317 buttonsSimpleRight,318 buttonsNumbers,319 resetableButtons,320 memoryButtons,321 answerWithOneOperand,322 answerWithTwoOperands,323 changeOneOperand,324 buttonNames,...
Using AI Code Generation
1var text = root.renderText("Hello World");2var text2 = root.renderText("Hello World2");3var text3 = root.renderText("Hello World3");4var text4 = root.renderText("Hello World4");5var text5 = root.renderText("Hello World5");6var text6 = root.renderText("Hello World6");7var text7 = text.renderText("Hello World7");8var text8 = text.renderText("Hello World8");9var text9 = text.renderText("Hello World9");10var text10 = text.renderText("Hello World10");11var text11 = text.renderText("Hello World11");12var text12 = text.renderText("Hello World12");13var text13 = text2.renderText("Hello World13");14var text14 = text2.renderText("Hello World14");15var text15 = text2.renderText("Hello World15");16var text16 = text2.renderText("Hello World16");17var text17 = text2.renderText("Hello World17");18var text18 = text2.renderText("Hello World18");19var text19 = text3.renderText("Hello World19");20var text20 = text3.renderText("Hello World20");21var text21 = text3.renderText("Hello World21");22var text22 = text3.renderText("Hello World22");23var text23 = text3.renderText("Hello World23");24var text24 = text3.renderText("Hello World24");25var text25 = text4.renderText("Hello World25");26var text26 = text4.renderText("Hello World26");27var text27 = text4.renderText("Hello World27");28var text28 = text4.renderText("Hello World28");29var text29 = text4.renderText("Hello World29");30var text30 = text4.renderText("Hello World30");31var text31 = text5.renderText("Hello World31");32var text32 = text5.renderText("Hello World32");33var text33 = text5.renderText("Hello World33");34var text34 = text5.renderText("Hello World34");35var text35 = text5.renderText("Hello
Using AI Code Generation
1var root = this.getRoot();2var text = "This is a test";3root.renderText(text);4var root = this.getRoot();5var text = "This is a test";6root.renderText(text);7var root = this.getRoot();8var text = "This is a test";9root.renderText(text);10var root = this.getRoot();11var text = "This is a test";12root.renderText(text);13var root = this.getRoot();14var text = "This is a test";15root.renderText(text);16var root = this.getRoot();17var text = "This is a test";18root.renderText(text);19var root = this.getRoot();20var text = "This is a test";21root.renderText(text);22var root = this.getRoot();23var text = "This is a test";24root.renderText(text);25var root = this.getRoot();26var text = "This is a test";27root.renderText(text);28var root = this.getRoot();29var text = "This is a test";30root.renderText(text);31var root = this.getRoot();32var text = "This is a test";33root.renderText(text);34var root = this.getRoot();35var text = "This is a test";36root.renderText(text);37var root = this.getRoot();38var text = "This is a test";39root.renderText(text);40var root = this.getRoot();41var text = "This is a test";
Using AI Code Generation
1var text = "Hello World";2var x = 100;3var y = 100;4var font = "Arial";5var size = 20;6var color = "#FFFFFF";7root.renderText(text, x, y, font, size, color);8var text = "Hello World";9var x = 100;10var y = 100;11var font = "Arial";12var size = 20;13var color = "#FFFFFF";14root.renderText(text, x, y, font, size, color);15var text = "Hello World";16var x = 100;17var y = 100;18var font = "Arial";19var size = 20;20var color = "#FFFFFF";21root.renderText(text, x, y, font, size, color);22var text = "Hello World";23var x = 100;24var y = 100;25var font = "Arial";26var size = 20;27var color = "#FFFFFF";28root.renderText(text, x, y, font, size, color);29var text = "Hello World";30var x = 100;31var y = 100;32var font = "Arial";33var size = 20;34var color = "#FFFFFF";35root.renderText(text, x, y, font, size, color);36var text = "Hello World";37var x = 100;38var y = 100;39var font = "Arial";40var size = 20;41var color = "#FFFFFF";42root.renderText(text, x, y, font, size, color);43var text = "Hello World";44var x = 100;45var y = 100;46var font = "Arial";47var size = 20;48var color = "#FFFFFF";49root.renderText(text, x, y, font,
Using AI Code Generation
1var rootComp = app.root;2rootComp.renderText("Hello World", 100, 100);3var rootComp = app.root;4rootComp.renderText("Hello World", 100, 100);5var rootComp = app.root;6rootComp.renderText("Hello World", 100, 100);7var rootComp = app.root;8rootComp.renderText("Hello World", 100, 100);9var rootComp = app.root;10rootComp.renderText("Hello World", 100, 100);11var rootComp = app.root;12rootComp.renderText("Hello World", 100, 100);13var rootComp = app.root;14rootComp.renderText("Hello World", 100, 100);15var rootComp = app.root;16rootComp.renderText("Hello World", 100, 100);17var rootComp = app.root;18rootComp.renderText("Hello World", 100, 100);
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!