How to use parseInt method in redwood

Best JavaScript code snippet using redwood

script2.js

Source:script2.js Github

copy

Full Screen

...265});266//Funciones de movimiento267//IZQUIERDA268function runLeft(){269 ring.style.left = parseInt(ring.style.left) + moveBy + 'px';270 ring2.style.left = parseInt(ring2.style.left) + moveBy + 'px';271 ring3.style.left = parseInt(ring3.style.left) + moveBy + 'px';272 ring4.style.left = parseInt(ring4.style.left) + moveBy + 'px';273 ring5.style.left = parseInt(ring5.style.left) + moveBy + 'px';274 ring6.style.left = parseInt(ring6.style.left) + moveBy + 'px';275 ring7.style.left = parseInt(ring7.style.left) + moveBy + 'px';276 ring8.style.left = parseInt(ring8.style.left) + moveBy + 'px';277 ring9.style.left = parseInt(ring9.style.left) + moveBy + 'px';278 ring10.style.left = parseInt(ring10.style.left) + moveBy + 'px';279 ring11.style.left = parseInt(ring11.style.left) + moveBy + 'px';280 ring12.style.left = parseInt(ring12.style.left) + moveBy + 'px';281 ring13.style.left = parseInt(ring13.style.left) + moveBy + 'px';282 ring14.style.left = parseInt(ring14.style.left) + moveBy + 'px';283 ring15.style.left = parseInt(ring15.style.left) + moveBy + 'px';284 ring16.style.left = parseInt(ring16.style.left) + moveBy + 'px';285 ring17.style.left = parseInt(ring17.style.left) + moveBy + 'px';286 ring18.style.left = parseInt(ring18.style.left) + moveBy + 'px';287 ring19.style.left = parseInt(ring19.style.left) + moveBy + 'px';288 ring20.style.left = parseInt(ring20.style.left) + moveBy + 'px';289 ring21.style.left = parseInt(ring21.style.left) + moveBy + 'px';290 ring22.style.left = parseInt(ring22.style.left) + moveBy + 'px';291 ring23.style.left = parseInt(ring23.style.left) + moveBy + 'px';292 ring24.style.left = parseInt(ring24.style.left) + moveBy + 'px';293 ring25.style.left = parseInt(ring25.style.left) + moveBy + 'px';294 ring26.style.left = parseInt(ring26.style.left) + moveBy + 'px';295 ring27.style.left = parseInt(ring27.style.left) + moveBy + 'px';296 ring28.style.left = parseInt(ring28.style.left) + moveBy + 'px';297 ring29.style.left = parseInt(ring29.style.left) + moveBy + 'px';298 ring30.style.left = parseInt(ring30.style.left) + moveBy + 'px';299 ring31.style.left = parseInt(ring31.style.left) + moveBy + 'px';300 ring32.style.left = parseInt(ring32.style.left) + moveBy + 'px';301 ring33.style.left = parseInt(ring33.style.left) + moveBy + 'px';302 ring34.style.left = parseInt(ring34.style.left) + moveBy + 'px';303 ring35.style.left = parseInt(ring35.style.left) + moveBy + 'px';304 ring36.style.left = parseInt(ring36.style.left) + moveBy + 'px';305 ring37.style.left = parseInt(ring37.style.left) + moveBy + 'px';306 ring38.style.left = parseInt(ring38.style.left) + moveBy + 'px';307 ring39.style.left = parseInt(ring39.style.left) + moveBy + 'px';308 ring40.style.left = parseInt(ring40.style.left) + moveBy + 'px';309 ring41.style.left = parseInt(ring41.style.left) + moveBy + 'px';310 ring42.style.left = parseInt(ring42.style.left) + moveBy + 'px';311 ring43.style.left = parseInt(ring43.style.left) + moveBy + 'px';312 ring44.style.left = parseInt(ring44.style.left) + moveBy + 'px';313 ring45.style.left = parseInt(ring45.style.left) + moveBy + 'px';314 ring46.style.left = parseInt(ring46.style.left) + moveBy + 'px';315 ring47.style.left = parseInt(ring47.style.left) + moveBy + 'px';316 ring48.style.left = parseInt(ring48.style.left) + moveBy + 'px';317 ring49.style.left = parseInt(ring49.style.left) + moveBy + 'px';318 ring50.style.left = parseInt(ring50.style.left) + moveBy + 'px';319 spikes.style.left = parseInt(spikes.style.left) + moveBy + 'px';320 spikes2.style.left = parseInt(spikes2.style.left) + moveBy + 'px';321 spikes3.style.left = parseInt(spikes3.style.left) + moveBy + 'px';322 spikes4.style.left = parseInt(spikes4.style.left) + moveBy + 'px';323 spikes5.style.left = parseInt(spikes5.style.left) + moveBy + 'px';324 eggman.style.left = parseInt(eggman.style.left) + moveBy + 'px';325 x--;326}327//DERECHA 328function runRight(){329 ring.style.left = parseInt(ring.style.left) - moveBy + 'px';330 ring2.style.left = parseInt(ring2.style.left) - moveBy + 'px';331 ring3.style.left = parseInt(ring3.style.left) - moveBy + 'px';332 ring4.style.left = parseInt(ring4.style.left) - moveBy + 'px';333 ring5.style.left = parseInt(ring5.style.left) - moveBy + 'px';334 ring6.style.left = parseInt(ring6.style.left) - moveBy + 'px';335 ring7.style.left = parseInt(ring7.style.left) - moveBy + 'px';336 ring8.style.left = parseInt(ring8.style.left) - moveBy + 'px';337 ring9.style.left = parseInt(ring9.style.left) - moveBy + 'px';338 ring10.style.left = parseInt(ring10.style.left) - moveBy + 'px';339 ring11.style.left = parseInt(ring11.style.left) - moveBy + 'px';340 ring12.style.left = parseInt(ring12.style.left) - moveBy + 'px';341 ring13.style.left = parseInt(ring13.style.left) - moveBy + 'px';342 ring14.style.left = parseInt(ring14.style.left) - moveBy + 'px';343 ring15.style.left = parseInt(ring15.style.left) - moveBy + 'px';344 ring16.style.left = parseInt(ring16.style.left) - moveBy + 'px';345 ring17.style.left = parseInt(ring17.style.left) - moveBy + 'px';346 ring18.style.left = parseInt(ring18.style.left) - moveBy + 'px';347 ring19.style.left = parseInt(ring19.style.left) - moveBy + 'px';348 ring20.style.left = parseInt(ring20.style.left) - moveBy + 'px';349 ring21.style.left = parseInt(ring21.style.left) - moveBy + 'px';350 ring22.style.left = parseInt(ring22.style.left) - moveBy + 'px';351 ring23.style.left = parseInt(ring23.style.left) - moveBy + 'px';352 ring24.style.left = parseInt(ring24.style.left) - moveBy + 'px';353 ring25.style.left = parseInt(ring25.style.left) - moveBy + 'px';354 ring26.style.left = parseInt(ring26.style.left) - moveBy + 'px';355 ring27.style.left = parseInt(ring27.style.left) - moveBy + 'px';356 ring28.style.left = parseInt(ring28.style.left) - moveBy + 'px';357 ring29.style.left = parseInt(ring29.style.left) - moveBy + 'px';358 ring30.style.left = parseInt(ring30.style.left) - moveBy + 'px';359 ring31.style.left = parseInt(ring31.style.left) - moveBy + 'px';360 ring32.style.left = parseInt(ring32.style.left) - moveBy + 'px';361 ring33.style.left = parseInt(ring33.style.left) - moveBy + 'px';362 ring34.style.left = parseInt(ring34.style.left) - moveBy + 'px';363 ring35.style.left = parseInt(ring35.style.left) - moveBy + 'px';364 ring36.style.left = parseInt(ring36.style.left) - moveBy + 'px';365 ring37.style.left = parseInt(ring37.style.left) - moveBy + 'px';366 ring38.style.left = parseInt(ring38.style.left) - moveBy + 'px';367 ring39.style.left = parseInt(ring39.style.left) - moveBy + 'px';368 ring40.style.left = parseInt(ring40.style.left) - moveBy + 'px';369 ring41.style.left = parseInt(ring41.style.left) - moveBy + 'px';370 ring42.style.left = parseInt(ring42.style.left) - moveBy + 'px';371 ring43.style.left = parseInt(ring43.style.left) - moveBy + 'px';372 ring44.style.left = parseInt(ring44.style.left) - moveBy + 'px';373 ring45.style.left = parseInt(ring45.style.left) - moveBy + 'px';374 ring46.style.left = parseInt(ring46.style.left) - moveBy + 'px';375 ring47.style.left = parseInt(ring47.style.left) - moveBy + 'px';376 ring48.style.left = parseInt(ring48.style.left) - moveBy + 'px';377 ring49.style.left = parseInt(ring49.style.left) - moveBy + 'px';378 ring50.style.left = parseInt(ring50.style.left) - moveBy + 'px';379 spikes.style.left = parseInt(spikes.style.left) - moveBy + 'px';380 spikes2.style.left = parseInt(spikes2.style.left) - moveBy + 'px';381 spikes3.style.left = parseInt(spikes3.style.left) - moveBy + 'px';382 spikes4.style.left = parseInt(spikes4.style.left) - moveBy + 'px';383 spikes5.style.left = parseInt(spikes5.style.left) - moveBy + 'px';384 eggman.style.left = parseInt(eggman.style.left) + moveBy + 'px';385 x++;386}387function XrunLeft(){388 ring.style.left = parseInt(ring.style.left) + 0 + 'px';389 ring2.style.left = parseInt(ring2.style.left) + 0 + 'px';390 ring3.style.left = parseInt(ring3.style.left) + 0 + 'px';391 ring4.style.left = parseInt(ring4.style.left) + 0 + 'px';392 ring5.style.left = parseInt(ring5.style.left) + 0 + 'px';393 ring6.style.left = parseInt(ring6.style.left) + 0 + 'px';394 ring7.style.left = parseInt(ring7.style.left) + 0 + 'px';395 ring8.style.left = parseInt(ring8.style.left) + 0 + 'px';396 ring9.style.left = parseInt(ring9.style.left) + 0 + 'px';397 ring10.style.left = parseInt(ring10.style.left) + 0 + 'px';398 ring11.style.left = parseInt(ring11.style.left) + 0 + 'px';399 ring12.style.left = parseInt(ring12.style.left) + 0 + 'px';400 ring13.style.left = parseInt(ring13.style.left) + 0 + 'px';401 ring14.style.left = parseInt(ring14.style.left) + 0 + 'px';402 ring15.style.left = parseInt(ring15.style.left) + 0 + 'px';403 ring16.style.left = parseInt(ring16.style.left) + 0 + 'px';404 ring17.style.left = parseInt(ring17.style.left) + 0 + 'px';405 ring18.style.left = parseInt(ring18.style.left) + 0 + 'px';406 ring19.style.left = parseInt(ring19.style.left) + 0 + 'px';407 ring20.style.left = parseInt(ring20.style.left) + 0 + 'px';408 ring21.style.left = parseInt(ring21.style.left) + 0 + 'px';409 ring22.style.left = parseInt(ring22.style.left) + 0 + 'px';410 ring23.style.left = parseInt(ring23.style.left) + 0 + 'px';411 ring24.style.left = parseInt(ring24.style.left) + 0 + 'px';412 ring25.style.left = parseInt(ring25.style.left) + 0 + 'px';413 ring26.style.left = parseInt(ring26.style.left) + 0 + 'px';414 ring27.style.left = parseInt(ring27.style.left) + 0 + 'px';415 ring28.style.left = parseInt(ring28.style.left) + 0 + 'px';416 ring29.style.left = parseInt(ring29.style.left) + 0 + 'px';417 ring30.style.left = parseInt(ring30.style.left) + 0 + 'px';418 ring31.style.left = parseInt(ring31.style.left) + 0 + 'px';419 ring32.style.left = parseInt(ring32.style.left) + 0 + 'px';420 ring33.style.left = parseInt(ring33.style.left) + 0 + 'px';421 ring34.style.left = parseInt(ring34.style.left) + 0 + 'px';422 ring35.style.left = parseInt(ring35.style.left) + 0 + 'px';423 ring36.style.left = parseInt(ring36.style.left) + 0 + 'px';424 ring37.style.left = parseInt(ring37.style.left) + 0 + 'px';425 ring38.style.left = parseInt(ring38.style.left) + 0 + 'px';426 ring39.style.left = parseInt(ring39.style.left) + 0 + 'px';427 ring40.style.left = parseInt(ring40.style.left) + 0 + 'px';428 ring41.style.left = parseInt(ring41.style.left) + 0 + 'px';429 ring42.style.left = parseInt(ring42.style.left) + 0 + 'px';430 ring43.style.left = parseInt(ring43.style.left) + 0 + 'px';431 ring44.style.left = parseInt(ring44.style.left) + 0 + 'px';432 ring45.style.left = parseInt(ring45.style.left) + 0 + 'px';433 ring46.style.left = parseInt(ring46.style.left) + 0 + 'px';434 ring47.style.left = parseInt(ring47.style.left) + 0 + 'px';435 ring48.style.left = parseInt(ring48.style.left) + 0 + 'px';436 ring49.style.left = parseInt(ring49.style.left) + 0 + 'px';437 ring50.style.left = parseInt(ring50.style.left) + 0 + 'px';438 spikes.style.left = parseInt(spikes.style.left) + 0 + 'px';439 spikes2.style.left = parseInt(spikes2.style.left) + 0 + 'px';440 spikes3.style.left = parseInt(spikes3.style.left) + 0 + 'px';441 spikes4.style.left = parseInt(spikes4.style.left) + 0 + 'px';442 spikes5.style.left = parseInt(spikes5.style.left) + 0 + 'px';443 eggman.style.left = parseInt(eggman.style.left) + 0 + 'px';444 x--;445}446//DERECHA 447function XrunRight(){448 ring.style.left = parseInt(ring.style.left) - 0 + 'px';449 ring2.style.left = parseInt(ring2.style.left) - 0 + 'px';450 ring3.style.left = parseInt(ring3.style.left) - 0 + 'px';451 ring4.style.left = parseInt(ring4.style.left) - 0 + 'px';452 ring5.style.left = parseInt(ring5.style.left) - 0 + 'px';453 ring6.style.left = parseInt(ring6.style.left) - 0 + 'px';454 ring7.style.left = parseInt(ring7.style.left) - 0 + 'px';455 ring8.style.left = parseInt(ring8.style.left) - 0 + 'px';456 ring9.style.left = parseInt(ring9.style.left) - 0 + 'px';457 ring10.style.left = parseInt(ring10.style.left) - 0 + 'px';458 ring11.style.left = parseInt(ring11.style.left) - 0 + 'px';459 ring12.style.left = parseInt(ring12.style.left) - 0 + 'px';460 ring13.style.left = parseInt(ring13.style.left) - 0 + 'px';461 ring14.style.left = parseInt(ring14.style.left) - 0 + 'px';462 ring15.style.left = parseInt(ring15.style.left) - 0 + 'px';463 ring16.style.left = parseInt(ring16.style.left) - 0 + 'px';464 ring17.style.left = parseInt(ring17.style.left) - 0 + 'px';465 ring18.style.left = parseInt(ring18.style.left) - 0 + 'px';466 ring19.style.left = parseInt(ring19.style.left) - 0 + 'px';467 ring20.style.left = parseInt(ring20.style.left) - 0 + 'px';468 ring21.style.left = parseInt(ring21.style.left) - 0 + 'px';469 ring22.style.left = parseInt(ring22.style.left) - 0 + 'px';470 ring23.style.left = parseInt(ring23.style.left) - 0 + 'px';471 ring24.style.left = parseInt(ring24.style.left) - 0 + 'px';472 ring25.style.left = parseInt(ring25.style.left) - 0 + 'px';473 ring26.style.left = parseInt(ring26.style.left) - 0 + 'px';474 ring27.style.left = parseInt(ring27.style.left) - 0 + 'px';475 ring28.style.left = parseInt(ring28.style.left) - 0 + 'px';476 ring29.style.left = parseInt(ring29.style.left) - 0 + 'px';477 ring30.style.left = parseInt(ring30.style.left) - 0 + 'px';478 ring31.style.left = parseInt(ring31.style.left) - 0 + 'px';479 ring32.style.left = parseInt(ring32.style.left) - 0 + 'px';480 ring33.style.left = parseInt(ring33.style.left) - 0 + 'px';481 ring34.style.left = parseInt(ring34.style.left) - 0 + 'px';482 ring35.style.left = parseInt(ring35.style.left) - 0 + 'px';483 ring36.style.left = parseInt(ring36.style.left) - 0 + 'px';484 ring37.style.left = parseInt(ring37.style.left) - 0 + 'px';485 ring38.style.left = parseInt(ring38.style.left) - 0 + 'px';486 ring39.style.left = parseInt(ring39.style.left) - 0 + 'px';487 ring40.style.left = parseInt(ring40.style.left) - 0 + 'px';488 ring41.style.left = parseInt(ring41.style.left) - 0 + 'px';489 ring42.style.left = parseInt(ring42.style.left) - 0 + 'px';490 ring43.style.left = parseInt(ring43.style.left) - 0 + 'px';491 ring44.style.left = parseInt(ring44.style.left) - 0 + 'px';492 ring45.style.left = parseInt(ring45.style.left) - 0 + 'px';493 ring46.style.left = parseInt(ring46.style.left) - 0 + 'px';494 ring47.style.left = parseInt(ring47.style.left) - 0 + 'px';495 ring48.style.left = parseInt(ring48.style.left) - 0 + 'px';496 ring49.style.left = parseInt(ring49.style.left) - 0 + 'px';497 ring50.style.left = parseInt(ring50.style.left) - 0 + 'px';498 spikes.style.left = parseInt(spikes.style.left) - 0 + 'px';499 spikes2.style.left = parseInt(spikes2.style.left) - 0 + 'px';500 spikes3.style.left = parseInt(spikes3.style.left) - 0 + 'px';501 spikes4.style.left = parseInt(spikes4.style.left) - 0 + 'px';502 spikes5.style.left = parseInt(spikes5.style.left) - 0 + 'px';503 eggman.style.left = parseInt(eggman.style.left) + 0 + 'px';504 x++;505}506function moveDie(){507 sonic.classList.add("died");508}509//anillos horizontales510function rings(value, clase){511 if(x==value){512 clase.classList.add("blink");513 var ringSound = new Audio('./audio/ringSound.mp3');514 ringSound.play();515 }516}517//anillos verticales518function ringsY(v1, v2, clase){519 if(y == 1){520 if(x>=v1 && x<=v2){521 clase.classList.add("blink");522 var ringSound = new Audio('./audio/ringSound.mp3');523 ringSound.play();}524 }525}526//contador de puntaje527function scoreR(value){528 if(x==value){529 score++;530 //console.log(score);531 document.getElementById("puntaje").innerHTML = score;532 }533}534function scoreL(value){535 if(x==value){536 score--;537 //console.log(score);538 }539}540function scoreY(v1,v2){541 if(y == 1){542 if(x>=v1 && x<=v2){543 score++;544 //console.log(score);545 document.getElementById("puntaje").innerHTML = score;546 }547 }548}549var die = 0;550function lose(p1,p2){551 if(y == 1){552 if(x>=p1 && x<=p2){553 score++;554 //console.log("you lose");555 sonic.classList.add("died");556 die++;557 }558 }559}560function ganar(v, clase){561 if(x==v){562 clase.classList.add("eggLoses");563 win.classList.add("mostrar");564 }565}566function repetir(v){567 if(x==v){568 alert("PRESS F5 TO PLAY AGAIN");569 }570}571//Eggman572function eggMan(){573 if(score >= 50){574 keepRuning.classList.add("keep2");575 }576 return;577}578//KEYDOWN579window.addEventListener('keydown', (e)=>{580 var jump = new Audio('./audio/jump.mp3');581 if(e.key == "ArrowRight"){582 runRight();583 song.play();584 sonic.classList.add("moving");585 sonic.classList.remove("sonic2");586 sonic.classList.add("sonic");587 background.classList.add("background2");588 eggman.classList.add("eggRun");589 eggman.classList.remove("eggman");590 y=0;591 if(die>0){592 morir.classList.add("mostrar");593 alert("PRESS F5 TO PLAY AGAIN");594 }595 596 597 console.log(x);598 // eggMan();599 scoreR(31);600 scoreR(35);601 scoreR(38);602 scoreR(41);603 scoreR(66);604 scoreR(69);605 scoreR(71);606 scoreR(74);607 scoreR(77);608 scoreR(80);609 scoreR(132);610 scoreR(135);611 scoreR(138);612 scoreR(141);613 scoreR(144);614 scoreR(165);615 scoreR(168);616 scoreR(171);617 scoreR(174);618 scoreR(177);619 scoreR(205);620 scoreR(208);621 scoreR(211);622 scoreR(214);623 scoreR(217);624 scoreR(220);625 scoreR(223);626 scoreR(226);627 scoreR(229);628 scoreR(232);629 scoreR(272);630 scoreR(275);631 scoreR(278);632 scoreR(281);633 scoreR(284);634 scoreR(287);635 scoreR(288);636 rings(31, ring);637 rings(35, ring2);638 rings(38, ring3);639 rings(41, ring4);640 rings(66, ring5);641 rings(69, ring6);642 rings(71, ring7);643 rings(74, ring8);644 rings(77, ring9);645 rings(80, ring10);646 rings(132, ring15);647 rings(135, ring16);648 rings(138, ring17);649 rings(141, ring18);650 rings(144, ring19);651 rings(165, ring24);652 rings(168, ring25);653 rings(171, ring26);654 rings(174, ring27);655 rings(177, ring28);656 rings(205, ring29);657 rings(208, ring30);658 rings(211, ring31);659 rings(214, ring32);660 rings(217, ring33);661 rings(220, ring34);662 rings(223, ring35);663 rings(226, ring36);664 rings(229, ring37);665 rings(232, ring38);666 rings(272, ring42);667 rings(275, ring43);668 rings(278, ring44);669 rings(281, ring45);670 rings(284, ring46);671 rings(287, ring47);672 rings(288, ring48);673 ganar(528, eggman2);674 repetir(531);675 if(score >= 50){676 eggman2.style.left = parseInt(eggman2.style.left) - moveBy + 'px';677 }678 }679 if(e.key == "ArrowLeft"){680 runLeft();681 y=0;682 //console.log(x);683 sonic.classList.add("moving2");684 background.classList.add("background2");685 eggman.classList.add("eggRun");686 eggman.classList.remove("eggman");687 if(die>0){688 morir.classList.add("mostrar");689 alert("PRESS F5 TO PLAY AGAIN");690 }691 //eggMan();692 scoreL(31);693 scoreL(35);694 scoreL(38);695 scoreL(41);696 scoreL(66);697 scoreL(69);698 scoreL(71);699 scoreL(74);700 scoreL(77);701 scoreL(80);702 scoreL(132);703 scoreL(135);704 scoreL(138);705 scoreL(141);706 scoreL(144);707 scoreL(165);708 scoreL(168);709 scoreL(171);710 scoreL(174);711 scoreL(177);712 scoreL(205);713 scoreL(208);714 scoreL(211);715 scoreL(214);716 scoreL(217);717 scoreL(220);718 scoreL(223);719 scoreL(226);720 scoreL(229);721 scoreL(232);722 scoreL(272);723 scoreL(275);724 scoreL(278);725 scoreL(281);726 scoreL(284);727 scoreL(287);728 scoreL(288);729 if(score >= 50){730 eggman2.style.left = parseInt(eggman2.style.left) + moveBy + 'px';731 732 }733 }734 if(e.key == "ArrowUp"){ 735 sonic.classList.add("jumping");736 y=1;737 738 jump.play();739 //console.log(y);740 if(die>0){741 morir.classList.add("mostrar");742 alert("PRESS F5 TO PLAY AGAIN");743 }744 ringsY(36, 39, ring11);...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

...266});267//Funciones de movimiento268//IZQUIERDA269function runLeft(){270 ring.style.left = parseInt(ring.style.left) + moveBy + 'px';271 ring2.style.left = parseInt(ring2.style.left) + moveBy + 'px';272 ring3.style.left = parseInt(ring3.style.left) + moveBy + 'px';273 ring4.style.left = parseInt(ring4.style.left) + moveBy + 'px';274 ring5.style.left = parseInt(ring5.style.left) + moveBy + 'px';275 ring6.style.left = parseInt(ring6.style.left) + moveBy + 'px';276 ring7.style.left = parseInt(ring7.style.left) + moveBy + 'px';277 ring8.style.left = parseInt(ring8.style.left) + moveBy + 'px';278 ring9.style.left = parseInt(ring9.style.left) + moveBy + 'px';279 ring10.style.left = parseInt(ring10.style.left) + moveBy + 'px';280 ring11.style.left = parseInt(ring11.style.left) + moveBy + 'px';281 ring12.style.left = parseInt(ring12.style.left) + moveBy + 'px';282 ring13.style.left = parseInt(ring13.style.left) + moveBy + 'px';283 ring14.style.left = parseInt(ring14.style.left) + moveBy + 'px';284 ring15.style.left = parseInt(ring15.style.left) + moveBy + 'px';285 ring16.style.left = parseInt(ring16.style.left) + moveBy + 'px';286 ring17.style.left = parseInt(ring17.style.left) + moveBy + 'px';287 ring18.style.left = parseInt(ring18.style.left) + moveBy + 'px';288 ring19.style.left = parseInt(ring19.style.left) + moveBy + 'px';289 ring20.style.left = parseInt(ring20.style.left) + moveBy + 'px';290 ring21.style.left = parseInt(ring21.style.left) + moveBy + 'px';291 ring22.style.left = parseInt(ring22.style.left) + moveBy + 'px';292 ring23.style.left = parseInt(ring23.style.left) + moveBy + 'px';293 ring24.style.left = parseInt(ring24.style.left) + moveBy + 'px';294 ring25.style.left = parseInt(ring25.style.left) + moveBy + 'px';295 ring26.style.left = parseInt(ring26.style.left) + moveBy + 'px';296 ring27.style.left = parseInt(ring27.style.left) + moveBy + 'px';297 ring28.style.left = parseInt(ring28.style.left) + moveBy + 'px';298 ring29.style.left = parseInt(ring29.style.left) + moveBy + 'px';299 ring30.style.left = parseInt(ring30.style.left) + moveBy + 'px';300 ring31.style.left = parseInt(ring31.style.left) + moveBy + 'px';301 ring32.style.left = parseInt(ring32.style.left) + moveBy + 'px';302 ring33.style.left = parseInt(ring33.style.left) + moveBy + 'px';303 ring34.style.left = parseInt(ring34.style.left) + moveBy + 'px';304 ring35.style.left = parseInt(ring35.style.left) + moveBy + 'px';305 ring36.style.left = parseInt(ring36.style.left) + moveBy + 'px';306 ring37.style.left = parseInt(ring37.style.left) + moveBy + 'px';307 ring38.style.left = parseInt(ring38.style.left) + moveBy + 'px';308 ring39.style.left = parseInt(ring39.style.left) + moveBy + 'px';309 ring40.style.left = parseInt(ring40.style.left) + moveBy + 'px';310 ring41.style.left = parseInt(ring41.style.left) + moveBy + 'px';311 ring42.style.left = parseInt(ring42.style.left) + moveBy + 'px';312 ring43.style.left = parseInt(ring43.style.left) + moveBy + 'px';313 ring44.style.left = parseInt(ring44.style.left) + moveBy + 'px';314 ring45.style.left = parseInt(ring45.style.left) + moveBy + 'px';315 ring46.style.left = parseInt(ring46.style.left) + moveBy + 'px';316 ring47.style.left = parseInt(ring47.style.left) + moveBy + 'px';317 ring48.style.left = parseInt(ring48.style.left) + moveBy + 'px';318 ring49.style.left = parseInt(ring49.style.left) + moveBy + 'px';319 ring50.style.left = parseInt(ring50.style.left) + moveBy + 'px';320 spikes.style.left = parseInt(spikes.style.left) + moveBy + 'px';321 spikes2.style.left = parseInt(spikes2.style.left) + moveBy + 'px';322 spikes3.style.left = parseInt(spikes3.style.left) + moveBy + 'px';323 spikes4.style.left = parseInt(spikes4.style.left) + moveBy + 'px';324 spikes5.style.left = parseInt(spikes5.style.left) + moveBy + 'px';325 eggman.style.left = parseInt(eggman.style.left) + moveBy + 'px';326 x--;327}328//DERECHA 329function runRight(){330 ring.style.left = parseInt(ring.style.left) - moveBy + 'px';331 ring2.style.left = parseInt(ring2.style.left) - moveBy + 'px';332 ring3.style.left = parseInt(ring3.style.left) - moveBy + 'px';333 ring4.style.left = parseInt(ring4.style.left) - moveBy + 'px';334 ring5.style.left = parseInt(ring5.style.left) - moveBy + 'px';335 ring6.style.left = parseInt(ring6.style.left) - moveBy + 'px';336 ring7.style.left = parseInt(ring7.style.left) - moveBy + 'px';337 ring8.style.left = parseInt(ring8.style.left) - moveBy + 'px';338 ring9.style.left = parseInt(ring9.style.left) - moveBy + 'px';339 ring10.style.left = parseInt(ring10.style.left) - moveBy + 'px';340 ring11.style.left = parseInt(ring11.style.left) - moveBy + 'px';341 ring12.style.left = parseInt(ring12.style.left) - moveBy + 'px';342 ring13.style.left = parseInt(ring13.style.left) - moveBy + 'px';343 ring14.style.left = parseInt(ring14.style.left) - moveBy + 'px';344 ring15.style.left = parseInt(ring15.style.left) - moveBy + 'px';345 ring16.style.left = parseInt(ring16.style.left) - moveBy + 'px';346 ring17.style.left = parseInt(ring17.style.left) - moveBy + 'px';347 ring18.style.left = parseInt(ring18.style.left) - moveBy + 'px';348 ring19.style.left = parseInt(ring19.style.left) - moveBy + 'px';349 ring20.style.left = parseInt(ring20.style.left) - moveBy + 'px';350 ring21.style.left = parseInt(ring21.style.left) - moveBy + 'px';351 ring22.style.left = parseInt(ring22.style.left) - moveBy + 'px';352 ring23.style.left = parseInt(ring23.style.left) - moveBy + 'px';353 ring24.style.left = parseInt(ring24.style.left) - moveBy + 'px';354 ring25.style.left = parseInt(ring25.style.left) - moveBy + 'px';355 ring26.style.left = parseInt(ring26.style.left) - moveBy + 'px';356 ring27.style.left = parseInt(ring27.style.left) - moveBy + 'px';357 ring28.style.left = parseInt(ring28.style.left) - moveBy + 'px';358 ring29.style.left = parseInt(ring29.style.left) - moveBy + 'px';359 ring30.style.left = parseInt(ring30.style.left) - moveBy + 'px';360 ring31.style.left = parseInt(ring31.style.left) - moveBy + 'px';361 ring32.style.left = parseInt(ring32.style.left) - moveBy + 'px';362 ring33.style.left = parseInt(ring33.style.left) - moveBy + 'px';363 ring34.style.left = parseInt(ring34.style.left) - moveBy + 'px';364 ring35.style.left = parseInt(ring35.style.left) - moveBy + 'px';365 ring36.style.left = parseInt(ring36.style.left) - moveBy + 'px';366 ring37.style.left = parseInt(ring37.style.left) - moveBy + 'px';367 ring38.style.left = parseInt(ring38.style.left) - moveBy + 'px';368 ring39.style.left = parseInt(ring39.style.left) - moveBy + 'px';369 ring40.style.left = parseInt(ring40.style.left) - moveBy + 'px';370 ring41.style.left = parseInt(ring41.style.left) - moveBy + 'px';371 ring42.style.left = parseInt(ring42.style.left) - moveBy + 'px';372 ring43.style.left = parseInt(ring43.style.left) - moveBy + 'px';373 ring44.style.left = parseInt(ring44.style.left) - moveBy + 'px';374 ring45.style.left = parseInt(ring45.style.left) - moveBy + 'px';375 ring46.style.left = parseInt(ring46.style.left) - moveBy + 'px';376 ring47.style.left = parseInt(ring47.style.left) - moveBy + 'px';377 ring48.style.left = parseInt(ring48.style.left) - moveBy + 'px';378 ring49.style.left = parseInt(ring49.style.left) - moveBy + 'px';379 ring50.style.left = parseInt(ring50.style.left) - moveBy + 'px';380 spikes.style.left = parseInt(spikes.style.left) - moveBy + 'px';381 spikes2.style.left = parseInt(spikes2.style.left) - moveBy + 'px';382 spikes3.style.left = parseInt(spikes3.style.left) - moveBy + 'px';383 spikes4.style.left = parseInt(spikes4.style.left) - moveBy + 'px';384 spikes5.style.left = parseInt(spikes5.style.left) - moveBy + 'px';385 eggman.style.left = parseInt(eggman.style.left) + moveBy + 'px';386 x++;387}388function XrunLeft(){389 ring.style.left = parseInt(ring.style.left) + 0 + 'px';390 ring2.style.left = parseInt(ring2.style.left) + 0 + 'px';391 ring3.style.left = parseInt(ring3.style.left) + 0 + 'px';392 ring4.style.left = parseInt(ring4.style.left) + 0 + 'px';393 ring5.style.left = parseInt(ring5.style.left) + 0 + 'px';394 ring6.style.left = parseInt(ring6.style.left) + 0 + 'px';395 ring7.style.left = parseInt(ring7.style.left) + 0 + 'px';396 ring8.style.left = parseInt(ring8.style.left) + 0 + 'px';397 ring9.style.left = parseInt(ring9.style.left) + 0 + 'px';398 ring10.style.left = parseInt(ring10.style.left) + 0 + 'px';399 ring11.style.left = parseInt(ring11.style.left) + 0 + 'px';400 ring12.style.left = parseInt(ring12.style.left) + 0 + 'px';401 ring13.style.left = parseInt(ring13.style.left) + 0 + 'px';402 ring14.style.left = parseInt(ring14.style.left) + 0 + 'px';403 ring15.style.left = parseInt(ring15.style.left) + 0 + 'px';404 ring16.style.left = parseInt(ring16.style.left) + 0 + 'px';405 ring17.style.left = parseInt(ring17.style.left) + 0 + 'px';406 ring18.style.left = parseInt(ring18.style.left) + 0 + 'px';407 ring19.style.left = parseInt(ring19.style.left) + 0 + 'px';408 ring20.style.left = parseInt(ring20.style.left) + 0 + 'px';409 ring21.style.left = parseInt(ring21.style.left) + 0 + 'px';410 ring22.style.left = parseInt(ring22.style.left) + 0 + 'px';411 ring23.style.left = parseInt(ring23.style.left) + 0 + 'px';412 ring24.style.left = parseInt(ring24.style.left) + 0 + 'px';413 ring25.style.left = parseInt(ring25.style.left) + 0 + 'px';414 ring26.style.left = parseInt(ring26.style.left) + 0 + 'px';415 ring27.style.left = parseInt(ring27.style.left) + 0 + 'px';416 ring28.style.left = parseInt(ring28.style.left) + 0 + 'px';417 ring29.style.left = parseInt(ring29.style.left) + 0 + 'px';418 ring30.style.left = parseInt(ring30.style.left) + 0 + 'px';419 ring31.style.left = parseInt(ring31.style.left) + 0 + 'px';420 ring32.style.left = parseInt(ring32.style.left) + 0 + 'px';421 ring33.style.left = parseInt(ring33.style.left) + 0 + 'px';422 ring34.style.left = parseInt(ring34.style.left) + 0 + 'px';423 ring35.style.left = parseInt(ring35.style.left) + 0 + 'px';424 ring36.style.left = parseInt(ring36.style.left) + 0 + 'px';425 ring37.style.left = parseInt(ring37.style.left) + 0 + 'px';426 ring38.style.left = parseInt(ring38.style.left) + 0 + 'px';427 ring39.style.left = parseInt(ring39.style.left) + 0 + 'px';428 ring40.style.left = parseInt(ring40.style.left) + 0 + 'px';429 ring41.style.left = parseInt(ring41.style.left) + 0 + 'px';430 ring42.style.left = parseInt(ring42.style.left) + 0 + 'px';431 ring43.style.left = parseInt(ring43.style.left) + 0 + 'px';432 ring44.style.left = parseInt(ring44.style.left) + 0 + 'px';433 ring45.style.left = parseInt(ring45.style.left) + 0 + 'px';434 ring46.style.left = parseInt(ring46.style.left) + 0 + 'px';435 ring47.style.left = parseInt(ring47.style.left) + 0 + 'px';436 ring48.style.left = parseInt(ring48.style.left) + 0 + 'px';437 ring49.style.left = parseInt(ring49.style.left) + 0 + 'px';438 ring50.style.left = parseInt(ring50.style.left) + 0 + 'px';439 spikes.style.left = parseInt(spikes.style.left) + 0 + 'px';440 spikes2.style.left = parseInt(spikes2.style.left) + 0 + 'px';441 spikes3.style.left = parseInt(spikes3.style.left) + 0 + 'px';442 spikes4.style.left = parseInt(spikes4.style.left) + 0 + 'px';443 spikes5.style.left = parseInt(spikes5.style.left) + 0 + 'px';444 eggman.style.left = parseInt(eggman.style.left) + 0 + 'px';445 x--;446}447//DERECHA 448function XrunRight(){449 ring.style.left = parseInt(ring.style.left) - 0 + 'px';450 ring2.style.left = parseInt(ring2.style.left) - 0 + 'px';451 ring3.style.left = parseInt(ring3.style.left) - 0 + 'px';452 ring4.style.left = parseInt(ring4.style.left) - 0 + 'px';453 ring5.style.left = parseInt(ring5.style.left) - 0 + 'px';454 ring6.style.left = parseInt(ring6.style.left) - 0 + 'px';455 ring7.style.left = parseInt(ring7.style.left) - 0 + 'px';456 ring8.style.left = parseInt(ring8.style.left) - 0 + 'px';457 ring9.style.left = parseInt(ring9.style.left) - 0 + 'px';458 ring10.style.left = parseInt(ring10.style.left) - 0 + 'px';459 ring11.style.left = parseInt(ring11.style.left) - 0 + 'px';460 ring12.style.left = parseInt(ring12.style.left) - 0 + 'px';461 ring13.style.left = parseInt(ring13.style.left) - 0 + 'px';462 ring14.style.left = parseInt(ring14.style.left) - 0 + 'px';463 ring15.style.left = parseInt(ring15.style.left) - 0 + 'px';464 ring16.style.left = parseInt(ring16.style.left) - 0 + 'px';465 ring17.style.left = parseInt(ring17.style.left) - 0 + 'px';466 ring18.style.left = parseInt(ring18.style.left) - 0 + 'px';467 ring19.style.left = parseInt(ring19.style.left) - 0 + 'px';468 ring20.style.left = parseInt(ring20.style.left) - 0 + 'px';469 ring21.style.left = parseInt(ring21.style.left) - 0 + 'px';470 ring22.style.left = parseInt(ring22.style.left) - 0 + 'px';471 ring23.style.left = parseInt(ring23.style.left) - 0 + 'px';472 ring24.style.left = parseInt(ring24.style.left) - 0 + 'px';473 ring25.style.left = parseInt(ring25.style.left) - 0 + 'px';474 ring26.style.left = parseInt(ring26.style.left) - 0 + 'px';475 ring27.style.left = parseInt(ring27.style.left) - 0 + 'px';476 ring28.style.left = parseInt(ring28.style.left) - 0 + 'px';477 ring29.style.left = parseInt(ring29.style.left) - 0 + 'px';478 ring30.style.left = parseInt(ring30.style.left) - 0 + 'px';479 ring31.style.left = parseInt(ring31.style.left) - 0 + 'px';480 ring32.style.left = parseInt(ring32.style.left) - 0 + 'px';481 ring33.style.left = parseInt(ring33.style.left) - 0 + 'px';482 ring34.style.left = parseInt(ring34.style.left) - 0 + 'px';483 ring35.style.left = parseInt(ring35.style.left) - 0 + 'px';484 ring36.style.left = parseInt(ring36.style.left) - 0 + 'px';485 ring37.style.left = parseInt(ring37.style.left) - 0 + 'px';486 ring38.style.left = parseInt(ring38.style.left) - 0 + 'px';487 ring39.style.left = parseInt(ring39.style.left) - 0 + 'px';488 ring40.style.left = parseInt(ring40.style.left) - 0 + 'px';489 ring41.style.left = parseInt(ring41.style.left) - 0 + 'px';490 ring42.style.left = parseInt(ring42.style.left) - 0 + 'px';491 ring43.style.left = parseInt(ring43.style.left) - 0 + 'px';492 ring44.style.left = parseInt(ring44.style.left) - 0 + 'px';493 ring45.style.left = parseInt(ring45.style.left) - 0 + 'px';494 ring46.style.left = parseInt(ring46.style.left) - 0 + 'px';495 ring47.style.left = parseInt(ring47.style.left) - 0 + 'px';496 ring48.style.left = parseInt(ring48.style.left) - 0 + 'px';497 ring49.style.left = parseInt(ring49.style.left) - 0 + 'px';498 ring50.style.left = parseInt(ring50.style.left) - 0 + 'px';499 spikes.style.left = parseInt(spikes.style.left) - 0 + 'px';500 spikes2.style.left = parseInt(spikes2.style.left) - 0 + 'px';501 spikes3.style.left = parseInt(spikes3.style.left) - 0 + 'px';502 spikes4.style.left = parseInt(spikes4.style.left) - 0 + 'px';503 spikes5.style.left = parseInt(spikes5.style.left) - 0 + 'px';504 eggman.style.left = parseInt(eggman.style.left) + 0 + 'px';505 x++;506}507function moveDie(){508 sonic.classList.add("died");509}510//anillos horizontales511function rings(value, clase){512 if(x==value){513 clase.classList.add("blink");514 var ringSound = new Audio('./audio/ringSound.mp3');515 ringSound.play();516 }517}518//anillos verticales519function ringsY(v1, v2, clase){520 if(y == 1){521 if(x>=v1 && x<=v2){522 clase.classList.add("blink");523 var ringSound = new Audio('./audio/ringSound.mp3');524 ringSound.play();}525 }526}527//contador de puntaje528function scoreR(value){529 if(x==value){530 score++;531 //console.log(score);532 document.getElementById("puntaje").innerHTML = score;533 }534}535function scoreL(value){536 if(x==value){537 score--;538 //console.log(score);539 }540}541function scoreY(v1,v2){542 if(y == 1){543 if(x>=v1 && x<=v2){544 score++;545 //console.log(score);546 document.getElementById("puntaje").innerHTML = score;547 }548 }549}550var die = 0;551function lose(p1,p2){552 if(y == 1){553 if(x>=p1 && x<=p2){554 score++;555 //console.log("you lose");556 sonic.classList.add("died");557 die++;558 }559 }560}561function ganar(v, clase){562 if(x==v){563 clase.classList.add("eggLoses");564 win.classList.add("mostrar");565 }566}567function repetir(v){568 if(x==v){569 alert("PRESS F5 TO PLAY AGAIN");570 }571}572//Eggman573function eggMan(){574 if(score >= 50){575 keepRuning.classList.add("keep2");576 }577 return;578}579//KEYDOWN580window.addEventListener('keydown', (e)=>{581 var jump = new Audio('./audio/jump.mp3');582 if(e.key == "ArrowRight"){583 runRight();584 sonic.classList.add("moving");585 sonic.classList.remove("sonic2");586 sonic.classList.add("sonic");587 background.classList.add("background2");588 eggman.classList.add("eggRun");589 eggman.classList.remove("eggman");590 y=0;591 if(die>0){592 morir.classList.add("mostrar");593 alert("PRESS F5 TO PLAY AGAIN");594 }595 596 597 console.log(x);598 // eggMan();599 scoreR(31);600 scoreR(35);601 scoreR(38);602 scoreR(41);603 scoreR(66);604 scoreR(69);605 scoreR(71);606 scoreR(74);607 scoreR(77);608 scoreR(80);609 scoreR(132);610 scoreR(135);611 scoreR(138);612 scoreR(141);613 scoreR(144);614 scoreR(165);615 scoreR(168);616 scoreR(171);617 scoreR(174);618 scoreR(177);619 scoreR(205);620 scoreR(208);621 scoreR(211);622 scoreR(214);623 scoreR(217);624 scoreR(220);625 scoreR(223);626 scoreR(226);627 scoreR(229);628 scoreR(232);629 scoreR(272);630 scoreR(275);631 scoreR(278);632 scoreR(281);633 scoreR(284);634 scoreR(287);635 scoreR(288);636 rings(31, ring);637 rings(35, ring2);638 rings(38, ring3);639 rings(41, ring4);640 rings(66, ring5);641 rings(69, ring6);642 rings(71, ring7);643 rings(74, ring8);644 rings(77, ring9);645 rings(80, ring10);646 rings(132, ring15);647 rings(135, ring16);648 rings(138, ring17);649 rings(141, ring18);650 rings(144, ring19);651 rings(165, ring24);652 rings(168, ring25);653 rings(171, ring26);654 rings(174, ring27);655 rings(177, ring28);656 rings(205, ring29);657 rings(208, ring30);658 rings(211, ring31);659 rings(214, ring32);660 rings(217, ring33);661 rings(220, ring34);662 rings(223, ring35);663 rings(226, ring36);664 rings(229, ring37);665 rings(232, ring38);666 rings(272, ring42);667 rings(275, ring43);668 rings(278, ring44);669 rings(281, ring45);670 rings(284, ring46);671 rings(287, ring47);672 rings(288, ring48);673 ganar(528, eggman2);674 repetir(531);675 if(score >= 50){676 eggman2.style.left = parseInt(eggman2.style.left) - moveBy + 'px';677 }678 }679 if(e.key == "ArrowLeft"){680 runLeft();681 y=0;682 //console.log(x);683 sonic.classList.add("moving2");684 background.classList.add("background2");685 eggman.classList.add("eggRun");686 eggman.classList.remove("eggman");687 if(die>0){688 morir.classList.add("mostrar");689 alert("PRESS F5 TO PLAY AGAIN");690 }691 //eggMan();692 scoreL(31);693 scoreL(35);694 scoreL(38);695 scoreL(41);696 scoreL(66);697 scoreL(69);698 scoreL(71);699 scoreL(74);700 scoreL(77);701 scoreL(80);702 scoreL(132);703 scoreL(135);704 scoreL(138);705 scoreL(141);706 scoreL(144);707 scoreL(165);708 scoreL(168);709 scoreL(171);710 scoreL(174);711 scoreL(177);712 scoreL(205);713 scoreL(208);714 scoreL(211);715 scoreL(214);716 scoreL(217);717 scoreL(220);718 scoreL(223);719 scoreL(226);720 scoreL(229);721 scoreL(232);722 scoreL(272);723 scoreL(275);724 scoreL(278);725 scoreL(281);726 scoreL(284);727 scoreL(287);728 scoreL(288);729 if(score >= 50){730 eggman2.style.left = parseInt(eggman2.style.left) + moveBy + 'px';731 732 }733 }734 if(e.key == "ArrowUp"){ 735 sonic.classList.add("jumping");736 y=1;737 738 jump.play();739 //console.log(y);740 if(die>0){741 morir.classList.add("mostrar");742 alert("PRESS F5 TO PLAY AGAIN");743 }744 ringsY(36, 39, ring11);...

Full Screen

Full Screen

9.3.1-3.js

Source:9.3.1-3.js Github

copy

Full Screen

...222223//***** This answer is preferred but Infinity is also acceptable here *****224225testcases[tc++] = new TestCase( SECTION,226"parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity",227true,228parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity );229230//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here *****231testcases[tc++] = new TestCase( SECTION,232"parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308",233true ,234parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308 );235236//***** This answer is preferred but Infinity is also acceptable here *****237238testcases[tc++] = new TestCase( SECTION,239"parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity",240true,241parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity);242243//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here *****244testcases[tc++] = new TestCase( SECTION,245"parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308",246true,247parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308 );248249testcases[tc++] = new TestCase( SECTION,250 "0x12345678",251 305419896,252 0x12345678 );253254testcases[tc++] = new TestCase( SECTION,255 "0x80000000",256 2147483648,257 0x80000000 );258259testcases[tc++] = new TestCase( SECTION,260 "0xffffffff",261 4294967295,262 0xffffffff );263264testcases[tc++] = new TestCase( SECTION,265 "0x100000000",266 4294967296,267 0x100000000 );268269testcases[tc++] = new TestCase( SECTION,270 "077777777777777777",271 2251799813685247,272 077777777777777777 );273274testcases[tc++] = new TestCase( SECTION,275 "077777777777777776",276 2251799813685246,277 077777777777777776 );278279testcases[tc++] = new TestCase( SECTION,280 "0x1fffffffffffff",281 9007199254740991,282 0x1fffffffffffff );283284testcases[tc++] = new TestCase( SECTION,285 "0x20000000000000",286 9007199254740992,287 0x20000000000000 );288289testcases[tc++] = new TestCase( SECTION,290 "0x20123456789abc",291 9027215253084860,292 0x20123456789abc );293294testcases[tc++] = new TestCase( SECTION,295 "0x20123456789abd",296 9027215253084860,297 0x20123456789abd );298299testcases[tc++] = new TestCase( SECTION,300 "0x20123456789abe",301 9027215253084862,302 0x20123456789abe );303304testcases[tc++] = new TestCase( SECTION,305 "0x20123456789abf",306 9027215253084864,307 0x20123456789abf );308309/***** These test the round-to-nearest-or-even-if-equally-close rule *****/310311testcases[tc++] = new TestCase( SECTION,312 "0x1000000000000080",313 1152921504606847000,314 0x1000000000000080 );315316testcases[tc++] = new TestCase( SECTION,317 "0x1000000000000081",318 1152921504606847200,319 0x1000000000000081 );320321testcases[tc++] = new TestCase( SECTION,322 "0x1000000000000100",323 1152921504606847200,324 0x1000000000000100 );325testcases[tc++] = new TestCase( SECTION,326 "0x100000000000017f",327 1152921504606847200,328 0x100000000000017f );329330testcases[tc++] = new TestCase( SECTION,331 "0x1000000000000180",332 1152921504606847500,333 0x1000000000000180 );334335testcases[tc++] = new TestCase( SECTION,336 "0x1000000000000181",337 1152921504606847500,338 0x1000000000000181 );339340testcases[tc++] = new TestCase( SECTION,341 "0x10000000000001f0",342 1152921504606847500,343 0x10000000000001f0 );344345testcases[tc++] = new TestCase( SECTION,346 "0x1000000000000200",347 1152921504606847500,348 0x1000000000000200 );349350testcases[tc++] = new TestCase( SECTION,351 "0x100000000000027f",352 1152921504606847500,353 0x100000000000027f );354355testcases[tc++] = new TestCase( SECTION,356 "0x1000000000000280",357 1152921504606847500,358 0x1000000000000280 );359360testcases[tc++] = new TestCase( SECTION,361 "0x1000000000000281",362 1152921504606847700,363 0x1000000000000281 );364365testcases[tc++] = new TestCase( SECTION,366 "0x10000000000002ff",367 1152921504606847700,368 0x10000000000002ff );369370testcases[tc++] = new TestCase( SECTION,371 "0x1000000000000300",372 1152921504606847700,373 0x1000000000000300 );374375testcases[tc++] = new TestCase( SECTION,376 "0x10000000000000000",377 18446744073709552000,378 0x10000000000000000 );379380testcases[tc++] = new TestCase( SECTION,381"parseInt(\"000000100000000100100011010001010110011110001001101010111100\",2)",3829027215253084860,383parseInt("000000100000000100100011010001010110011110001001101010111100",2) );384385testcases[tc++] = new TestCase( SECTION,386"parseInt(\"000000100000000100100011010001010110011110001001101010111101\",2)",3879027215253084860,388parseInt("000000100000000100100011010001010110011110001001101010111101",2) );389390testcases[tc++] = new TestCase( SECTION,391"parseInt(\"000000100000000100100011010001010110011110001001101010111111\",2)",3929027215253084864,393parseInt("000000100000000100100011010001010110011110001001101010111111",2) );394395testcases[tc++] = new TestCase( SECTION,396"parseInt(\"0000001000000001001000110100010101100111100010011010101111010\",2)",39718054430506169720,398parseInt("0000001000000001001000110100010101100111100010011010101111010",2));399400testcases[tc++] = new TestCase( SECTION,401"parseInt(\"0000001000000001001000110100010101100111100010011010101111011\",2)",40218054430506169724,403parseInt("0000001000000001001000110100010101100111100010011010101111011",2) );404405testcases[tc++] = new TestCase( SECTION,406"parseInt(\"0000001000000001001000110100010101100111100010011010101111100\",2)",40718054430506169724,408parseInt("0000001000000001001000110100010101100111100010011010101111100",2));409410testcases[tc++] = new TestCase( SECTION,411"parseInt(\"0000001000000001001000110100010101100111100010011010101111110\",2)",41218054430506169728,413parseInt("0000001000000001001000110100010101100111100010011010101111110",2));414415testcases[tc++] = new TestCase( SECTION,416 "parseInt(\"yz\",35)",417 34,418 parseInt("yz",35) );419420testcases[tc++] = new TestCase( SECTION,421 "parseInt(\"yz\",36)",422 1259,423 parseInt("yz",36) );424425testcases[tc++] = new TestCase( SECTION,426 "parseInt(\"yz\",37)",427 NaN,428 parseInt("yz",37) );429430testcases[tc++] = new TestCase( SECTION,431 "parseInt(\"+77\")",432 77,433 parseInt("+77") );434435testcases[tc++] = new TestCase( SECTION,436 "parseInt(\"-77\",9)",437 -70,438 parseInt("-77",9) );439440testcases[tc++] = new TestCase( SECTION,441 "parseInt(\"\\u20001234\\u2000\")",442 1234,443 parseInt("\u20001234\u2000") );444445testcases[tc++] = new TestCase( SECTION,446 "parseInt(\"123456789012345678\")",447 123456789012345680,448 parseInt("123456789012345678") );449450testcases[tc++] = new TestCase( SECTION,451 "parseInt(\"9\",8)",452 NaN,453 parseInt("9",8) );454455testcases[tc++] = new TestCase( SECTION,456 "parseInt(\"1e2\")",457 1,458 parseInt("1e2") );459460testcases[tc++] = new TestCase( SECTION,461 "parseInt(\"1.9999999999999999999\")",462 1,463 parseInt("1.9999999999999999999") );464465testcases[tc++] = new TestCase( SECTION,466 "parseInt(\"0x10\")",467 16,468 parseInt("0x10") );469470testcases[tc++] = new TestCase( SECTION,471 "parseInt(\"0x10\",10)",472 0,473 parseInt("0x10",10) );474475testcases[tc++] = new TestCase( SECTION,476 "parseInt(\"0022\")",477 18,478 parseInt("0022") );479480testcases[tc++] = new TestCase( SECTION,481 "parseInt(\"0022\",10)",482 22,483 parseInt("0022",10) );484485testcases[tc++] = new TestCase( SECTION,486 "parseInt(\"0x1000000000000080\")",487 1152921504606847000,488 parseInt("0x1000000000000080") );489490testcases[tc++] = new TestCase( SECTION,491 "parseInt(\"0x1000000000000081\")",492 1152921504606847200,493 parseInt("0x1000000000000081") );494495s =496"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";497498testcases[tc++] = new TestCase( SECTION, "s = "+499"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+500"s",501"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",502s );503504505testcases[tc++] = new TestCase( SECTION, "s +="+506"\"0000000000000000000000000000000000000\"; s",507"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",508s += "0000000000000000000000000000000000000" );509510testcases[tc++] = new TestCase( SECTION, "-s",511-1.7976931348623157e+308,512-s );513514s =515"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";516517testcases[tc++] = new TestCase( SECTION, "s ="+518"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+519"s",520"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",521s );522523testcases[tc++] = new TestCase( SECTION,524"s += \"0000000000000000000000000000000000001\"",525"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",526s += "0000000000000000000000000000000000001" );527528testcases[tc++] = new TestCase( SECTION,529"-s",530-1.7976931348623157e+308,531-s );532533s =534"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";535536testcases[tc++] = new TestCase( SECTION,537"s ="+538"\"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+539"s",540"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",541s );542543544testcases[tc++] = new TestCase( SECTION,545"s += \"0000000000000000000000000000000000000\"",546"0xFFFFFFFFFFFFFC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",547s += "0000000000000000000000000000000000000");548549550testcases[tc++] = new TestCase( SECTION,551"-s",552-Infinity,553-s );554555s =556"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";557558testcases[tc++] = new TestCase( SECTION,559"s = "+560"\"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";s",561"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",562s);563564testcases[tc++] = new TestCase( SECTION,565"s += \"0000000000000000000000000000000000001\"",566"0xFFFFFFFFFFFFFB00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",567s += "0000000000000000000000000000000000001" );568569testcases[tc++] = new TestCase( SECTION,570"-s",571-1.7976931348623157e+308,572-s );573574testcases[tc++] = new TestCase( SECTION,575"s += \"0\"",576"0xFFFFFFFFFFFFFB000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010",577s += "0" );578579testcases[tc++] = new TestCase( SECTION,580"-s",581-Infinity,582-s );583584testcases[tc++] = new TestCase( SECTION,585"parseInt(s)",586Infinity,587parseInt(s) );588589testcases[tc++] = new TestCase( SECTION,590"parseInt(s,32)",5910,592parseInt(s,32) );593594testcases[tc++] = new TestCase( SECTION,595"parseInt(s,36)",596Infinity,597parseInt(s,36) );598599testcases[tc++] = new TestCase( SECTION,600 "-\"\"",601 0,602 -"" );603604testcases[tc++] = new TestCase( SECTION,605 "-\" \"",606 0,607 -" " );608609testcases[tc++] = new TestCase( SECTION,610 "-\"999\"",611 -999, ...

Full Screen

Full Screen

15.1.2.2-1.js

Source:15.1.2.2-1.js Github

copy

Full Screen

...21 */22/**23 File Name: 15.1.2.2-1.js24 ECMA Section: 15.1.2.2 Function properties of the global object25 parseInt( string, radix )2627 Description:2829 The parseInt function produces an integer value dictated by intepretation30 of the contents of the string argument according to the specified radix.3132 When the parseInt function is called, the following steps are taken:3334 1. Call ToString(string).35 2. Compute a substring of Result(1) consisting of the leftmost character36 that is not a StrWhiteSpaceChar and all characters to the right of37 that character. (In other words, remove leading whitespace.)38 3. Let sign be 1.39 4. If Result(2) is not empty and the first character of Result(2) is a40 minus sign -, let sign be -1.41 5. If Result(2) is not empty and the first character of Result(2) is a42 plus sign + or a minus sign -, then Result(5) is the substring of43 Result(2) produced by removing the first character; otherwise, Result(5)44 is Result(2).45 6. If the radix argument is not supplied, go to step 12.46 7. Call ToInt32(radix).47 8. If Result(7) is zero, go to step 12; otherwise, if Result(7) < 2 or48 Result(7) > 36, return NaN.49 9. Let R be Result(7).50 10. If R = 16 and the length of Result(5) is at least 2 and the first two51 characters of Result(5) are either "0x" or "0X", let S be the substring52 of Result(5) consisting of all but the first two characters; otherwise,53 let S be Result(5).54 11. Go to step 22.55 12. If Result(5) is empty or the first character of Result(5) is not 0,56 go to step 20.57 13. If the length of Result(5) is at least 2 and the second character of58 Result(5) is x or X, go to step 17.59 14. Let R be 8.60 15. Let S be Result(5).61 16. Go to step 22.62 17. Let R be 16.63 18. Let S be the substring of Result(5) consisting of all but the first64 two characters.65 19. Go to step 22.66 20. Let R be 10.67 21. Let S be Result(5).68 22. If S contains any character that is not a radix-R digit, then let Z be69 the substring of S consisting of all characters to the left of the70 leftmost such character; otherwise, let Z be S.71 23. If Z is empty, return NaN.72 24. Compute the mathematical integer value that is represented by Z in73 radix-R notation. (But if R is 10 and Z contains more than 2074 significant digits, every digit after the 20th may be replaced by a 075 digit, at the option of the implementation; and if R is not 2, 4, 8,76 10, 16, or 32, then Result(24) may be an implementation-dependent77 approximation to the mathematical integer value that is represented78 by Z in radix-R notation.)79 25. Compute the number value for Result(24).80 26. Return sign Result(25).8182 Note that parseInt may interpret only a leading portion of the string as83 an integer value; it ignores any characters that cannot be interpreted as84 part of the notation of an integer, and no indication is given that any85 such characters were ignored.8687 Author: christine@netscape.com88 Date: 28 october 19978990*/91 var SECTION = "15.1.2.2-1";92 var VERSION = "ECMA_1";93 startTest();94 var TITLE = "parseInt(string, radix)";95 var BUGNUMBER="111199";9697 writeHeaderToLog( SECTION + " "+ TITLE);9899 var testcases = getTestCases();100101 test();102103function getTestCases() {104 var array = new Array();105 var item = 0;106107 var HEX_STRING = "0x0";108 var HEX_VALUE = 0;109110 array[item++] = new TestCase( SECTION, "parseInt.length", 2, parseInt.length );111 array[item++] = new TestCase( SECTION, "parseInt.length = 0; parseInt.length", 2, eval("parseInt.length = 0; parseInt.length") );112 array[item++] = new TestCase( SECTION, "var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS", "", eval("var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS") );113 array[item++] = new TestCase( SECTION, "delete parseInt.length", false, delete parseInt.length );114 array[item++] = new TestCase( SECTION, "delete parseInt.length; parseInt.length", 2, eval("delete parseInt.length; parseInt.length") );115 array[item++] = new TestCase( SECTION, "parseInt.length = null; parseInt.length", 2, eval("parseInt.length = null; parseInt.length") );116117 array[item++] = new TestCase( SECTION, "parseInt()", NaN, parseInt() );118 array[item++] = new TestCase( SECTION, "parseInt('')", NaN, parseInt("") );119 array[item++] = new TestCase( SECTION, "parseInt('','')", NaN, parseInt("","") );120 array[item++] = new TestCase( SECTION,121 "parseInt(\" 0xabcdef ",122 11259375,123 parseInt( " 0xabcdef " ));124125 array[item++] = new TestCase( SECTION,126 "parseInt(\" 0XABCDEF ",127 11259375,128 parseInt( " 0XABCDEF " ) );129130 array[item++] = new TestCase( SECTION,131 "parseInt( 0xabcdef )",132 11259375,133 parseInt( "0xabcdef") );134135 array[item++] = new TestCase( SECTION,136 "parseInt( 0XABCDEF )",137 11259375,138 parseInt( "0XABCDEF") );139140 for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {141 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) );142 HEX_VALUE += Math.pow(16,POWER)*15;143 }144 for ( HEX_STRING = "0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {145 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) );146 HEX_VALUE += Math.pow(16,POWER)*15;147 }148 for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {149 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) );150 HEX_VALUE += Math.pow(16,POWER)*15;151 }152 for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {153 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) );154 HEX_VALUE += Math.pow(16,POWER)*15;155 }156 for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {157 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",null)", HEX_VALUE, parseInt(HEX_STRING,null) );158 HEX_VALUE += Math.pow(16,POWER)*15;159 }160 for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {161 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+", void 0)", HEX_VALUE, parseInt(HEX_STRING, void 0) );162 HEX_VALUE += Math.pow(16,POWER)*15;163 }164165 // a few tests with spaces166167 for ( var space = " ", HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0;168 POWER < 15;169 POWER++, HEX_STRING = HEX_STRING +"f", space += " ")170 {171 array[item++] = new TestCase( SECTION, "parseInt("+space+HEX_STRING+space+", void 0)", HEX_VALUE, parseInt(space+HEX_STRING+space, void 0) );172 HEX_VALUE += Math.pow(16,POWER)*15;173 }174175 // a few tests with negative numbers176 for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {177 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) );178 HEX_VALUE -= Math.pow(16,POWER)*15;179 }180181 // we should stop parsing when we get to a value that is not a numeric literal for the type we expect182183 for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {184 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"g",16) );185 HEX_VALUE += Math.pow(16,POWER)*15;186 }187 for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {188 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"G",16) );189 HEX_VALUE += Math.pow(16,POWER)*15;190 }191192 for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {193 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) );194 HEX_VALUE -= Math.pow(16,POWER)*15;195 }196 for ( HEX_STRING = "-0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {197 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) );198 HEX_VALUE -= Math.pow(16,POWER)*15;199 }200 for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {201 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) );202 HEX_VALUE -= Math.pow(16,POWER)*15;203 }204 for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) {205 array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) );206 HEX_VALUE -= Math.pow(16,POWER)*15;207 }208209 // let us do some octal tests. numbers that start with 0 and do not provid a radix should210 // default to using "0" as a radix.211212 var OCT_STRING = "0";213 var OCT_VALUE = 0;214215 for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) {216 array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) );217 OCT_VALUE += Math.pow(8,POWER)*7;218 }219220 for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) {221 array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) );222 OCT_VALUE -= Math.pow(8,POWER)*7;223 }224225 // should get the same results as above if we provid the radix of 8 (or 010)226227 for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) {228 array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+",8)", OCT_VALUE, parseInt(OCT_STRING,8) );229 OCT_VALUE += Math.pow(8,POWER)*7;230 }231 for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) {232 array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+",010)", OCT_VALUE, parseInt(OCT_STRING,010) );233 OCT_VALUE -= Math.pow(8,POWER)*7;234 }235236 // we shall stop parsing digits when we get one that isn't a numeric literal of the type we think237 // it should be.238 for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) {239 array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+"8,8)", OCT_VALUE, parseInt(OCT_STRING+"8",8) );240 OCT_VALUE += Math.pow(8,POWER)*7;241 }242 for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) {243 array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+"8,010)", OCT_VALUE, parseInt(OCT_STRING+"8",010) );244 OCT_VALUE -= Math.pow(8,POWER)*7;245 }246247 array[item++] = new TestCase( SECTION, "parseInt( '0x' )", NaN, parseInt("0x") );248 array[item++] = new TestCase( SECTION, "parseInt( '0X' )", NaN, parseInt("0X") );249250 array[item++] = new TestCase( SECTION, "parseInt( '11111111112222222222' )", 11111111112222222222, parseInt("11111111112222222222") );251 array[item++] = new TestCase( SECTION, "parseInt( '111111111122222222223' )", 111111111122222222220, parseInt("111111111122222222223") );252 array[item++] = new TestCase( SECTION, "parseInt( '11111111112222222222',10 )", 11111111112222222222, parseInt("11111111112222222222",10) );253 array[item++] = new TestCase( SECTION, "parseInt( '111111111122222222223',10 )", 111111111122222222220, parseInt("111111111122222222223",10) );254255 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', -1 )", Number.NaN, parseInt("01234567890",-1) );256 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 0 )", Number.NaN, parseInt("01234567890",1) );257 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 1 )", Number.NaN, parseInt("01234567890",1) );258 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 2 )", 1, parseInt("01234567890",2) );259 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 3 )", 5, parseInt("01234567890",3) );260 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 4 )", 27, parseInt("01234567890",4) );261 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 5 )", 194, parseInt("01234567890",5) );262 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 6 )", 1865, parseInt("01234567890",6) );263 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 7 )", 22875, parseInt("01234567890",7) );264 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 8 )", 342391, parseInt("01234567890",8) );265 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 9 )", 6053444, parseInt("01234567890",9) );266 array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 10 )", 1234567890, parseInt("01234567890",10) );267268 // need more test cases with hex radix269270 array[item++] = new TestCase( SECTION, "parseInt( '1234567890', '0xa')", 1234567890, parseInt("1234567890","0xa") );271272 array[item++] = new TestCase( SECTION, "parseInt( '012345', 11 )", 17715, parseInt("012345",11) );273274 array[item++] = new TestCase( SECTION, "parseInt( '012345', 35 )", 1590195, parseInt("012345",35) );275 array[item++] = new TestCase( SECTION, "parseInt( '012345', 36 )", 1776965, parseInt("012345",36) );276 array[item++] = new TestCase( SECTION, "parseInt( '012345', 37 )", Number.NaN, parseInt("012345",37) );277278 return ( array );279}280function test( array ) {281 for ( tc=0 ; tc < testcases.length; tc++ ) {282 testcases[tc].passed = writeTestCaseResult(283 testcases[tc].expect,284 testcases[tc].actual,285 testcases[tc].description +" = "+ testcases[tc].actual );286287 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";288 }289 stopTest();290 return ( testcases ); ...

Full Screen

Full Screen

assignment3.js

Source:assignment3.js Github

copy

Full Screen

...4647 switch (true) {4849 case (num > 21 && num < 100):50 tens = parseInt(num / 10) * 10;51 ans = num_set[tens];5253 ones = parseInt(num % 10);54 if (ones > 0) {55 ans += " " + num_set[ones];56 }5758 console.log(num + ":" + ans);596061 break;6263646566 case (len == 3):67 //console.log(len);6869 ans = num_set[parseInt(str[0])] + " " + "hundread" + " ";7071 if (parseInt(str[1]) != 0) {7273 if (parseInt(str[1]) >= 1 && parseInt(str[1]) < 2)74 ans += num_set[parseInt(((str[1]) * 10)) + parseInt(str[2])] + " ";757677 else {78 ans += num_set[parseInt(str[1] * 10)] + " ";79 ans += num_set[parseInt(str[2])] + " ";8081 }8283 }8485 console.log(num + ":" + ans);868788 break;8990 91929394 case (len == 4):95 //console.log(len);969798 if (parseInt(str[0]) != 0) {99100 ans = num_set[parseInt(str[0])] + " ";101 ans += "Thousand" + " ";102103104 }105106 ans += num_set[parseInt(str[1])] + " " + "hundread" + " ";107108 if (parseInt(str[2]) != 0) {109110 if (parseInt(str[2]) >= 1 && parseInt(str[2]) < 2)111 ans += num_set[parseInt(((str[2]) * 10)) + parseInt(str[3])] + " ";112113114 else {115 ans += num_set[parseInt(str[2] * 10)] + " ";116 ans += num_set[parseInt(str[3])] + " ";117118 }119120 }121122 console.log(num + ":" + ans);123124125 break;126127128 129130131132 case (len == 5):133 //console.log(len);134135136 if (parseInt(str[0]) != 0) {137138 if (parseInt(str[0]) >= 1 && parseInt(str[0]) < 2)139 ans = num_set[parseInt(((str[0]) * 10)) + parseInt(str[1])] + " " + " Thousand" + " ";140141142 else {143 ans = num_set[parseInt(str[0] * 10)] + " ";144 ans += num_set[parseInt(str[1])] + " ";145 ans += "Thousand" + " ";146 }147148 }149150 ans += num_set[parseInt(str[2])] + " " + "hundread" + " ";151152 if (parseInt(str[3]) != 0) {153154 if (parseInt(str[3]) >= 1 && parseInt(str[3]) < 2)155 ans += num_set[parseInt(((str[3]) * 10)) + parseInt(str[4])] + " ";156157158 else {159 ans += num_set[parseInt(str[3] * 10)] + " ";160 ans += num_set[parseInt(str[4])] + " ";161162 }163164 }165166 console.log(num + ":" + ans);167168169 break;170171172173174175176 case (len == 6):177 //console.log(len);178179 ans = num_set[parseInt(str[0])] + " " + "hundread" + " ";180181 if (parseInt(str[1]) != 0) {182183 if (parseInt(str[1]) >= 1 && parseInt(str[1]) < 2)184 ans += num_set[parseInt(((str[1]) * 10)) + parseInt(str[2])] + " " + " Thousand" + " ";185186187 else {188 ans += num_set[parseInt(str[1] * 10)] + " ";189 ans += num_set[parseInt(str[2])] + " ";190 ans += "Thousand" + " ";191 }192193 }194195 ans += num_set[parseInt(str[3])] + " " + "hundread" + " ";196197 if (parseInt(str[4]) != 0) {198199 if (parseInt(str[4]) >= 1 && parseInt(str[4]) < 2)200 ans += num_set[parseInt(((str[4]) * 10)) + parseInt(str[5])] + " ";201202203 else {204 ans += num_set[parseInt(str[1] * 10)] + " ";205 ans += num_set[parseInt(str[2])] + " ";206207 }208209 }210211 console.log(num + ":" + ans);212213214 break;215216217218219 case (len == 7):220 //console.log(len);221 ans = num_set[parseInt(str[0])] + " " + "Million" + " ";222 ans += num_set[parseInt(str[1])] + " " + "hundread" + " ";223224 if (parseInt(str[2]) != 0) {225226 if (parseInt(str[2]) >= 1 && parseInt(str[2]) < 2)227 ans += num_set[parseInt(((str[2]) * 10)) + parseInt(str[3])] + " " + " Thousand" + " ";228229230 else {231 ans += num_set[parseInt(str[2] * 10)] + " ";232 ans += num_set[parseInt(str[3])] + " ";233 ans += "Thousand" + " ";234 }235236 }237238239240241 ans += num_set[parseInt(str[4])] + " " + "hundread" + " ";242243 if (parseInt(str[5]) != 0) {244245 if (parseInt(str[5]) >= 1 && parseInt(str[5]) < 2)246 ans += num_set[parseInt(((str[5]) * 10)) + parseInt(str[6])] + " ";247248249 else {250 ans += num_set[parseInt(str[5] * 10)] + " ";251 ans += num_set[parseInt(str[6])] + " ";252 }253254255 }256257258 console.log(num + ":" + ans);259260261 break;262263264265266 case (len == 8):267268 if (parseInt(str[0]) != 0) {269270 if (parseInt(str[0]) >= 1 && parseInt(str[0]) < 2) {271 ans = num_set[parseInt(((str[0]) * 10)) + parseInt(str[1])] + " " + " Million" + " ";272 }273 else {274 ans = num_set[parseInt(str[0] * 10)] + " ";275 ans += num_set[parseInt(str[1])] + " ";276 ans += "Million" + " ";277 }278279 }280281 ans += num_set[parseInt(str[2])] + " " + "hundread" + " ";282283 if (parseInt(str[3]) != 0) {284 if (parseInt(str[3]) >= 1 && parseInt(str[3]) < 2) {285 ans += num_set[parseInt(((str[3]) * 10)) + parseInt(str[4])] + " " + " Thousand" + " ";286 }287 else {288 ans += num_set[parseInt(str[3] * 10)] + " ";289 ans += num_set[parseInt(str[4])] + " ";290 ans += "Thousand" + " ";291 }292293 }294 ans += "thousand" + " ";295296297 ans += num_set[parseInt(str[5])] + " " + "hundread" + " ";298299 if (parseInt(str[6]) != 0) {300301 if (parseInt(str[6]) >= 1 && parseInt(str[6]) < 2) {302 ans += num_set[parseInt(((str[6]) * 10)) + parseInt(str[7])] + " ";303 }304 else {305 ans += num_set[parseInt(str[6] * 10)] + " ";306 ans += num_set[parseInt(str[7])] + " ";307308 }309310 }311312 console.log(num + ":" + ans);313314315 break;316317318319320321 case (len == 9):322 //console.log(len);323324325326 ans = num_set[parseInt(str[0])] + " " + "hundread" + " ";327328 if (parseInt(str[1]) != 0) {329330 if (parseInt(str[1]) >= 1 && parseInt(str[1]) < 2)331 ans += num_set[parseInt(((str[1]) * 10)) + parseInt(str[2])] + " " + " Million" + " ";332333334 else {335 ans += num_set[parseInt(str[1] * 10)] + " ";336 ans += num_set[parseInt(str[2])] + " ";337 ans += "Million" + " ";338 }339340 }341342 if (parseInt(str[3]) != 0)343 ans += num_set[parseInt(str[3])] + " " + "hundread" + " ";344345 if (parseInt(str[4]) != 0) {346347 if (parseInt(str[4]) >= 1 && parseInt(str[4]) < 2)348 ans += num_set[parseInt(((str[4]) * 10)) + parseInt(str[5])] + " " + " Thousand" + " ";349350351 else {352 ans += num_set[parseInt(str[4] * 10)] + " ";353 ans += num_set[parseInt(str[5])] + " ";354 ans += "Thousand" + " ";355 }356357 }358359360361 if (parseInt(str[6]) != 0)362 ans += num_set[parseInt(str[6])] + " " + "hundread" + " ";363364365 if (parseInt(str[7]) != 0) {366367 if (parseInt(str[7]) >= 1 && parseInt(str[7]) < 2)368 ans += num_set[parseInt(((str[7]) * 10)) + parseInt(str[8])] + " ";369370371 else {372 ans += num_set[parseInt(str[7] * 10)] + " ";373 ans += num_set[parseInt(str[8])] + " ";374 }375376377 }378 console.log(num + ":" + ans);379380 break;381382383384385386 case (len == 10):387 //console.log(len);388 ans = num_set[parseInt(str[0])] + " " + "Billion" + " ";389390 if (parseInt(str[1]) != 0)391 ans += num_set[parseInt(str[1])] + " " + "hundread" + " ";392393 if (parseInt(str[2]) != 0) {394395 if (parseInt(str[2]) >= 1 && parseInt(str[2]) < 2)396 ans += num_set[parseInt(((str[2]) * 10)) + parseInt(str[3])] + " " + " Million" + " ";397398399 else {400 ans += num_set[parseInt(str[2] * 10)] + " ";401 ans += num_set[parseInt(str[3])] + " ";402 ans += "Million" + " ";403 }404405 }406407 if (parseInt(str[4]) != 0)408 ans += num_set[parseInt(str[4])] + " " + "hundread" + " ";409410 if (parseInt(str[5]) != 0) {411412 if (parseInt(str[5]) >= 1 && parseInt(str[5]) < 2)413 ans += num_set[parseInt(((str[5]) * 10)) + parseInt(str[6])] + " " + " Thousand" + " ";414415416 else {417 ans += num_set[parseInt(str[5] * 10)] + " ";418 ans += num_set[parseInt(str[6])] + " ";419 ans += "Thousand" + " ";420 }421422 }423424425 if (parseInt(str[7]) != 0)426 ans += num_set[parseInt(str[7])] + " " + "hundread" + " ";427428 if (parseInt(str[8]) != 0) {429430 if (parseInt(str[8]) >= 1 && parseInt(str[8]) < 2)431 ans += num_set[parseInt(((str[8]) * 10)) + parseInt(str[9])] + " ";432433434 else {435 ans += num_set[parseInt(str[8] * 10)] + " ";436 ans += num_set[parseInt(str[9])] + " ";437438 }439440 }441442 console.log(num + ":" + ans);443444445 break;446447448449450451 case (len == 11):452 //console.log(len);453454 if (parseInt(str[0]) >= 1 && parseInt(str[0]) < 2) {455 ans = num_set[parseInt(((str[0]) * 10)) + parseInt(str[1])] + " " + " Billion" + " ";456 }457 else {458 ans = num_set[parseInt(str[0] * 10)] + " ";459 ans += num_set[parseInt(str[1])] + " ";460 ans += "Billion" + " ";461 }462463464 if (parseInt(str[2]) != 0)465 ans += num_set[parseInt(str[2])] + " " + "hundread" + " ";466467 if (parseInt(str[3]) >= 1 && parseInt(str[3]) < 2) {468 ans += num_set[parseInt(((str[3]) * 10)) + parseInt(str[4])] + " " + " Million" + " ";469 }470 else {471 ans += num_set[parseInt(str[3] * 10)] + " ";472 ans += num_set[parseInt(str[4])] + " ";473 ans += "Million" + " ";474 }475476 if (parseInt(str[5]) != 0)477 ans += num_set[parseInt(str[5])] + " " + "hundread" + " ";478479480 if (parseInt(str[6]) >= 1 && parseInt(str[6]) < 2) {481 ans += num_set[parseInt(((str[6]) * 10)) + parseInt(str[7])] + " " + " Thousand" + " ";482 }483 else {484 ans += num_set[parseInt(str[6] * 10)] + " ";485 ans += num_set[parseInt(str[7])] + " ";486 ans += "Thousand" + " ";487 }488489 if (parseInt(str[8]) != 0)490 ans += num_set[parseInt(str[8])] + " " + "hundread" + " ";491492 if (parseInt(str[9]) >= 1 && parseInt(str[9]) < 2) {493 ans += num_set[parseInt(((str[9]) * 10)) + parseInt(str[10])] + " ";494 }495 else {496 ans += num_set[parseInt(str[9] * 10)] + " ";497 ans += num_set[parseInt(str[10])] + " ";498 }499500501 console.log(num + ":" + ans);502503 break;504505506507508 case (len == 12):509 //console.log(len);510 ans = num_set[parseInt(str[0])] + " Hundread ";511512 if (parseInt(str[1]) != 0) {513514 if (parseInt(str[1]) >= 1 && parseInt(str[1]) < 2)515 ans += num_set[parseInt(((str[1]) * 10)) + parseInt(str[2])] + " " + " Billion" + " ";516517518 else {519 ans += num_set[parseInt(str[1] * 10)] + " ";520 ans += num_set[parseInt(str[2])] + " ";521 ans += "Billion" + " ";522 }523524 }525526 if (parseInt(str[3]) != 0)527 ans += num_set[parseInt(str[3])] + " " + "hundread" + " ";528529530 if (parseInt(str[4]) != 0) {531532 if (parseInt(str[4]) >= 1 && parseInt(str[4]) < 2)533 ans += num_set[parseInt(((str[4]) * 10)) + parseInt(str[5])] + " " + " Million" + " ";534535536 else {537 ans += num_set[parseInt(str[4] * 10)] + " ";538 ans += num_set[parseInt(str[5])] + " ";539 ans += "Million" + " ";540 }541542 }543544 if (parseInt(str[6]) != 0)545 ans += num_set[parseInt(str[6])] + " " + "hundread" + " ";546547 if (parseInt(str[7]) != 0) {548549 if (parseInt(str[7]) >= 1 && parseInt(str[7]) < 2)550 ans += num_set[parseInt(((str[7]) * 10)) + parseInt(str[8])] + " " + " Thousand" + " ";551552553 else {554 ans += num_set[parseInt(str[7] * 10)] + " ";555 ans += num_set[parseInt(str[8])] + " ";556 ans += "Thousand" + " ";557 }558559 }560561562 if (parseInt(str[9]) != 0)563 ans += num_set[parseInt(str[9])] + " " + "hundread" + " ";564565 if (parseInt(str[10]) != 0) {566567 if (parseInt(str[10]) >= 1 && parseInt(str[10]) < 2)568 ans += num_set[parseInt(((str[10]) * 10)) + parseInt(str[11])] + " ";569570571 else {572 ans += num_set[parseInt(str[1] * 10)] + " ";573 ans += num_set[parseInt(str[2])] + " ";574 }575576 }577578 console.log(num + ":" + ans);579580 break;581 }582583584585586587}588589val = prompt("enter the number");590num = parseInt(val);591var len = val.length;592//console.log(len);593 ...

Full Screen

Full Screen

15.1.2.2-2.js

Source:15.1.2.2-2.js Github

copy

Full Screen

...21 */22/**23 File Name: 15.1.2.2-1.js24 ECMA Section: 15.1.2.2 Function properties of the global object25 parseInt( string, radix )2627 Description: parseInt test cases written by waldemar, and documented in28 http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874.2930 Author: christine@netscape.com31 Date: 28 october 19973233*/34var SECTION = "15.1.2.2-2";35var VERSION = "ECMA_1";36 startTest();37var TITLE = "parseInt(string, radix)";38var BUGNUMBER="123874";3940writeHeaderToLog( SECTION + " "+ TITLE);4142var testcases = new Array();4344testcases[tc++] = new TestCase( SECTION,45 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)',46 9027215253084860,47 parseInt("000000100000000100100011010001010110011110001001101010111100",2) );4849testcases[tc++] = new TestCase( SECTION,50 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)',51 9027215253084860,52 parseInt("000000100000000100100011010001010110011110001001101010111101",2));5354testcases[tc++] = new TestCase( SECTION,55 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)',56 9027215253084864,57 parseInt("000000100000000100100011010001010110011110001001101010111111",2) );5859testcases[tc++] = new TestCase( SECTION,60 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)',61 18054430506169720,62 parseInt("0000001000000001001000110100010101100111100010011010101111010",2) );6364testcases[tc++] = new TestCase( SECTION,65 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)',66 18054430506169724,67 parseInt("0000001000000001001000110100010101100111100010011010101111011",2));6869testcases[tc++] = new TestCase( SECTION,70 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)',71 18054430506169724,72 parseInt("0000001000000001001000110100010101100111100010011010101111100",2) );7374testcases[tc++] = new TestCase( SECTION,75 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)',76 18054430506169728,77 parseInt("0000001000000001001000110100010101100111100010011010101111110",2) );7879testcases[tc++] = new TestCase( SECTION,80 'parseInt("yz",35)',81 34,82 parseInt("yz",35) );8384testcases[tc++] = new TestCase( SECTION,85 'parseInt("yz",36)',86 1259,87 parseInt("yz",36) );8889testcases[tc++] = new TestCase( SECTION,90 'parseInt("yz",37)',91 NaN,92 parseInt("yz",37) );9394testcases[tc++] = new TestCase( SECTION,95 'parseInt("+77")',96 77,97 parseInt("+77") );9899testcases[tc++] = new TestCase( SECTION,100 'parseInt("-77",9)',101 -70,102 parseInt("-77",9) );103104testcases[tc++] = new TestCase( SECTION,105 'parseInt("\u20001234\u2000")',106 1234,107 parseInt("\u20001234\u2000") );108109testcases[tc++] = new TestCase( SECTION,110 'parseInt("123456789012345678")',111 123456789012345680,112 parseInt("123456789012345678") );113114testcases[tc++] = new TestCase( SECTION,115 'parseInt("9",8)',116 NaN,117 parseInt("9",8) );118119testcases[tc++] = new TestCase( SECTION,120 'parseInt("1e2")',121 1,122 parseInt("1e2") );123124testcases[tc++] = new TestCase( SECTION,125 'parseInt("1.9999999999999999999")',126 1,127 parseInt("1.9999999999999999999") );128129testcases[tc++] = new TestCase( SECTION,130 'parseInt("0x10")',131 16,132 parseInt("0x10") );133134testcases[tc++] = new TestCase( SECTION,135 'parseInt("0x10",10)',136 0,137 parseInt("0x10",10));138139testcases[tc++] = new TestCase( SECTION,140 'parseInt("0022")',141 18,142 parseInt("0022"));143144testcases[tc++] = new TestCase( SECTION,145 'parseInt("0022",10)',146 22,147 parseInt("0022",10) );148149testcases[tc++] = new TestCase( SECTION,150 'parseInt("0x1000000000000080")',151 1152921504606847000,152 parseInt("0x1000000000000080") );153154testcases[tc++] = new TestCase( SECTION,155 'parseInt("0x1000000000000081")',156 1152921504606847200,157 parseInt("0x1000000000000081") );158159s =160"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"161162s += "0000000000000000000000000000000000000";163164testcases[tc++] = new TestCase( SECTION,165 "s = " + s +"; -s",166 -1.7976931348623157e+308,167 -s );168169s =170"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";171s += "0000000000000000000000000000000000001";172173testcases[tc++] = new TestCase( SECTION,174 "s = " + s +"; -s",175 -1.7976931348623157e+308,176 -s );177178179s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";180181s += "0000000000000000000000000000000000000"182183184testcases[tc++] = new TestCase( SECTION,185 "s = " + s + "; -s",186 -Infinity,187 -s );188189s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";190s += "0000000000000000000000000000000000001";191192testcases[tc++] = new TestCase( SECTION,193 "s = " + s + "; -s",194 -1.7976931348623157e+308,195 -s );196197s += "0"198199testcases[tc++] = new TestCase( SECTION,200 "s = " + s + "; -s",201 -Infinity,202 -s );203204testcases[tc++] = new TestCase( SECTION,205 'parseInt(s)',206 Infinity,207 parseInt(s) );208209testcases[tc++] = new TestCase( SECTION,210 'parseInt(s,32)',211 0,212 parseInt(s,32) );213214testcases[tc++] = new TestCase( SECTION,215 'parseInt(s,36)',216 Infinity,217 parseInt(s,36));218219test();220221function test( array ) {222 for ( tc=0 ; tc < testcases.length; tc++ ) {223 testcases[tc].passed = writeTestCaseResult(224 testcases[tc].expect,225 testcases[tc].actual,226 testcases[tc].description +" = "+ testcases[tc].actual );227228 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";229 }230 stopTest();231 return ( testcases ); ...

Full Screen

Full Screen

OBJLoader.js

Source:OBJLoader.js Github

copy

Full Screen

...77 // ["f 1 2 3", "1", "2", "3", undefined]78 if ( result[ 4 ] === undefined ) {79 80 geometry.faces.push( face3(81 parseInt( result[ 1 ] ) - 1,82 parseInt( result[ 2 ] ) - 1,83 parseInt( result[ 3 ] ) - 184 ) );85 } else {86 geometry.faces.push( face4(87 parseInt( result[ 1 ] ) - 1,88 parseInt( result[ 2 ] ) - 1,89 parseInt( result[ 3 ] ) - 1,90 parseInt( result[ 4 ] ) - 191 ) );92 }93 }94 // f vertex/uv vertex/uv vertex/uv ...95 pattern = /f( ([\d]+)\/([\d]+))( ([\d]+)\/([\d]+))( ([\d]+)\/([\d]+))( ([\d]+)\/([\d]+))?/g;96 while ( ( result = pattern.exec( object ) ) != null ) {97 // ["f 1/1 2/2 3/3", " 1/1", "1", "1", " 2/2", "2", "2", " 3/3", "3", "3", undefined, undefined, undefined]98 if ( result[ 10 ] === undefined ) {99 100 geometry.faces.push( face3(101 parseInt( result[ 2 ] ) - 1,102 parseInt( result[ 5 ] ) - 1,103 parseInt( result[ 8 ] ) - 1104 ) );105 geometry.faceVertexUvs[ 0 ].push( [106 uvs[ parseInt( result[ 3 ] ) - 1 ],107 uvs[ parseInt( result[ 6 ] ) - 1 ],108 uvs[ parseInt( result[ 9 ] ) - 1 ]109 ] );110 } else {111 geometry.faces.push( face4(112 parseInt( result[ 2 ] ) - 1,113 parseInt( result[ 5 ] ) - 1,114 parseInt( result[ 8 ] ) - 1,115 parseInt( result[ 11 ] ) - 1116 ) );117 geometry.faceVertexUvs[ 0 ].push( [118 uvs[ parseInt( result[ 3 ] ) - 1 ],119 uvs[ parseInt( result[ 6 ] ) - 1 ],120 uvs[ parseInt( result[ 9 ] ) - 1 ],121 uvs[ parseInt( result[ 12 ] ) - 1 ]122 ] );123 }124 }125 // f vertex/uv/normal vertex/uv/normal vertex/uv/normal ...126 pattern = /f( ([\d]+)\/([\d]+)\/([\d]+))( ([\d]+)\/([\d]+)\/([\d]+))( ([\d]+)\/([\d]+)\/([\d]+))( ([\d]+)\/([\d]+)\/([\d]+))?/g;127 while ( ( result = pattern.exec( object ) ) != null ) {128 // ["f 1/1/1 2/2/2 3/3/3", " 1/1/1", "1", "1", "1", " 2/2/2", "2", "2", "2", " 3/3/3", "3", "3", "3", undefined, undefined, undefined, undefined]129 if ( result[ 13 ] === undefined ) {130 131 geometry.faces.push( face3(132 parseInt( result[ 2 ] ) - 1,133 parseInt( result[ 6 ] ) - 1,134 parseInt( result[ 10 ] ) - 1,135 [136 normals[ parseInt( result[ 4 ] ) - 1 ],137 normals[ parseInt( result[ 8 ] ) - 1 ],138 normals[ parseInt( result[ 12 ] ) - 1 ]139 ]140 ) );141 geometry.faceVertexUvs[ 0 ].push( [142 uvs[ parseInt( result[ 3 ] ) - 1 ],143 uvs[ parseInt( result[ 7 ] ) - 1 ],144 uvs[ parseInt( result[ 11 ] ) - 1 ]145 ] );146 } else {147 geometry.faces.push( face4(148 parseInt( result[ 2 ] ) - 1,149 parseInt( result[ 6 ] ) - 1,150 parseInt( result[ 10 ] ) - 1,151 parseInt( result[ 14 ] ) - 1,152 [153 normals[ parseInt( result[ 4 ] ) - 1 ],154 normals[ parseInt( result[ 8 ] ) - 1 ],155 normals[ parseInt( result[ 12 ] ) - 1 ],156 normals[ parseInt( result[ 16 ] ) - 1 ]157 ]158 ) );159 geometry.faceVertexUvs[ 0 ].push( [160 uvs[ parseInt( result[ 3 ] ) - 1 ],161 uvs[ parseInt( result[ 7 ] ) - 1 ],162 uvs[ parseInt( result[ 11 ] ) - 1 ],163 uvs[ parseInt( result[ 15 ] ) - 1 ]164 ] );165 }166 }167 // f vertex//normal vertex//normal vertex//normal ...168 pattern = /f( ([\d]+)\/\/([\d]+))( ([\d]+)\/\/([\d]+))( ([\d]+)\/\/([\d]+))( ([\d]+)\/\/([\d]+))?/g;169 while ( ( result = pattern.exec( object ) ) != null ) {170 // ["f 1//1 2//2 3//3", " 1//1", "1", "1", " 2//2", "2", "2", " 3//3", "3", "3", undefined, undefined, undefined]171 if ( result[ 10 ] === undefined ) {172 173 geometry.faces.push( face3(174 parseInt( result[ 2 ] ) - 1,175 parseInt( result[ 5 ] ) - 1,176 parseInt( result[ 8 ] ) - 1,177 [178 normals[ parseInt( result[ 3 ] ) - 1 ],179 normals[ parseInt( result[ 6 ] ) - 1 ],180 normals[ parseInt( result[ 9 ] ) - 1 ]181 ]182 ) );183 } else {184 geometry.faces.push( face4(185 parseInt( result[ 2 ] ) - 1,186 parseInt( result[ 5 ] ) - 1,187 parseInt( result[ 8 ] ) - 1,188 parseInt( result[ 11 ] ) - 1,189 [190 normals[ parseInt( result[ 3 ] ) - 1 ],191 normals[ parseInt( result[ 6 ] ) - 1 ],192 normals[ parseInt( result[ 9 ] ) - 1 ],193 normals[ parseInt( result[ 12 ] ) - 1 ]194 ]195 ) );196 }197 }198 geometry.computeCentroids();199 group.add( new THREE.Mesh( geometry, new THREE.MeshLambertMaterial() ) );200 }201 return group;...

Full Screen

Full Screen

S15.1.2.2_A5.2_T2.js

Source:S15.1.2.2_A5.2_T2.js Github

copy

Full Screen

...6 * @path ch15/15.1/15.1.2/15.1.2.2/S15.1.2.2_A5.2_T2.js7 * @description : 0X8 */9//CHECK#010if (parseInt("0X0", 0) !== parseInt("0", 16)) {11 $ERROR('#0: parseInt("0X0", 0) === parseInt("0", 16). Actual: ' + (parseInt("0X0", 0)));12}13//CHECK#114if (parseInt("0X1") !== parseInt("1", 16)) {15 $ERROR('#1: parseInt("0X1") === parseInt("1", 16). Actual: ' + (parseInt("0X1")));16}17//CHECK#218if (parseInt("0X2") !== parseInt("2", 16)) {19 $ERROR('#2: parseInt("0X2") === parseInt("2", 16). Actual: ' + (parseInt("0X2")));20}21//CHECK#322if (parseInt("0X3") !== parseInt("3", 16)) {23 $ERROR('#3: parseInt("0X3") === parseInt("3", 16). Actual: ' + (parseInt("0X3")));24}25//CHECK#426if (parseInt("0X4") !== parseInt("4", 16)) {27 $ERROR('#4: parseInt("0X4") === parseInt("4", 16). Actual: ' + (parseInt("0X4")));28}29//CHECK#530if (parseInt("0X5") !== parseInt("5", 16)) {31 $ERROR('#5: parseInt("0X5") === parseInt("5", 16). Actual: ' + (parseInt("0X5")));32}33//CHECK#634if (parseInt("0X6") !== parseInt("6", 16)) {35 $ERROR('#6: parseInt("0X6") === parseInt("6", 16). Actual: ' + (parseInt("0X6")));36}37//CHECK#738if (parseInt("0X7") !== parseInt("7", 16)) {39 $ERROR('#7: parseInt("0X7") === parseInt("7", 16). Actual: ' + (parseInt("0X7")));40}41//CHECK#842if (parseInt("0X8") !== parseInt("8", 16)) {43 $ERROR('#8: parseInt("0X8") === parseInt("8", 16). Actual: ' + (parseInt("0X8")));44}45//CHECK#946if (parseInt("0X9") !== parseInt("9", 16)) {47 $ERROR('#9: parseInt("0X9") === parseInt("9", 16). Actual: ' + (parseInt("0X9")));48}49//CHECK#A50if (parseInt("0XA") !== parseInt("A", 16)) {51 $ERROR('#A: parseInt("0XA") === parseInt("A", 16). Actual: ' + (parseInt("0XA")));52}53//CHECK#B54if (parseInt("0XB") !== parseInt("B", 16)) {55 $ERROR('#B: parseInt("0XB") === parseInt("B", 16). Actual: ' + (parseInt("0XB")));56}57//CHECK#C58if (parseInt("0XC") !== parseInt("C", 16)) {59 $ERROR('#C: parseInt("0XC") === parseInt("C", 16). Actual: ' + (parseInt("0XC")));60}61//CHECK#D62if (parseInt("0XD") !== parseInt("D", 16)) {63 $ERROR('#D: parseInt("0XD") === parseInt("D", 16). Actual: ' + (parseInt("0XD")));64}65//CHECK#E66if (parseInt("0XE") !== parseInt("E", 16)) {67 $ERROR('#E: parseInt("0XE") === parseInt("E", 16). Actual: ' + (parseInt("0XE")));68}69//CHECK#F70if (parseInt("0XF") !== parseInt("F", 16)) {71 $ERROR('#F: parseInt("0XF") === parseInt("F", 16). Actual: ' + (parseInt("0XF")));72}73//CHECK#E74if (parseInt("0XE") !== parseInt("E", 16)) {75 $ERROR('#E: parseInt("0XE") === parseInt("E", 16). Actual: ' + (parseInt("0XE")));76}77//CHECK#ABCDEF78if (parseInt("0XABCDEF") !== parseInt("ABCDEF", 16)) {79 $ERROR('#ABCDEF: parseInt("0XABCDEF") === parseInt("ABCDEF", 16). Actual: ' + (parseInt("0XABCDEF")));...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { parseInt } from '@redwoodjs/api'2export const handler = async (event, context) => {3 const id = parseInt(event.pathParameters.id, 10)4 return {5 body: JSON.stringify({6 data: `Post ${id}`,7 }),8 }9}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { requireAuth } from 'src/lib/auth'2import { db } from 'src/lib/db'3export const posts = () => {4 return db.post.findMany()5}6export const post = ({ id }) => {7 return db.post.findUnique({8 where: { id },9 })10}11export const createPost = ({ input }) => {12 return db.post.create({13 })14}15export const updatePost = ({ id, input }) => {16 return db.post.update({17 where: { id },18 })19}20export const deletePost = ({ id }) => {21 return db.post.delete({22 where: { id },23 })24}25export const Post = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseInt } = require('@redwoodjs/api')2const { parseISO } = require('date-fns')3const db = require('@redwoodjs/api/db')4const { requireAuth } = require('@redwoodjs/auth')5const { requireRole } = require('@redwoodjs/auth')6const { context } = require('@redwoodjs/api')7const { currentUser } = require('@redwoodjs/auth')8const gql = require('graphql-tag')9const { ForbiddenError } = require('@redwoodjs/api')10const { AuthenticationError } = require('@redwoodjs/api')11const { ValidationError } = require('@redwoodjs/api')12const { schema } = require('@redwoodjs/api')13const { dbUtils } = require('@redwoodjs/api')14const { dbAdapter } = require('@redwoodjs/api')15const { logger } = require('@redwoodjs/api/logger')16const { createGraphQLHandler } = require('@redwoodjs/api')17const { createGraphQLSchema } = require('@redwoodjs/api')18const { createGraphQLService } = require('@redwoodjs/api')19const { createGraphQLResolver } = require('@redwoodjs/api')20const { createGraphQLMutationResolver } = require('@redwoodjs/api')21const { create

Full Screen

Using AI Code Generation

copy

Full Screen

1import { db } from 'src/lib/db'2export const users = () => {3 return db.user.findMany()4}5export const user = ({ id }) => {6 return db.user.findUnique({7 where: { id },8 })9}10export const createUser = ({ input }) => {11 return db.user.create({12 })13}14export const updateUser = ({ id, input }) => {15 return db.user.update({16 where: { id },17 })18}19export const deleteUser = ({ id }) => {20 return db.user.delete({21 where: { id },22 })23}

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var a = redwood.parseInt('12');3console.log(a);4var b = redwood.parseInt('12.3');5console.log(b);6var c = redwood.parseInt('12.3.4');7console.log(c);8var d = redwood.parseInt('12.3.4', 10);9console.log(d);10var e = redwood.parseInt('12.3.4', 8);11console.log(e);12var f = redwood.parseInt('12.3.4', 16);13console.log(f);14var g = redwood.parseInt('12.3.4', 2);15console.log(g);16var h = redwood.parseInt('12.3.4', 36);17console.log(h);18var i = redwood.parseInt('12.3.4', 37);19console.log(i);20var j = redwood.parseInt('12.3.4', 0);21console.log(j);22var k = redwood.parseInt('12.3.4', 1);23console.log(k);24var l = redwood.parseInt('12.3.4', -1);25console.log(l);26var m = redwood.parseInt('12.3.4', 35);27console.log(m);28var n = redwood.parseInt('12.3.4', 36);29console.log(n);30var o = redwood.parseInt('12.3.4', 37);31console.log(o);32var p = redwood.parseInt('12.3.4', 38);33console.log(p);34var q = redwood.parseInt('12.3.4', 39);35console.log(q);36var r = redwood.parseInt('12.3.4', 40);37console.log(r);38var s = redwood.parseInt('12.3.4', 41);39console.log(s);40var t = redwood.parseInt('12.3.4', 42);41console.log(t);42var u = redwood.parseInt('12.3.4', 43);43console.log(u);44var v = redwood.parseInt('12.3.4', 44);45console.log(v);46var w = redwood.parseInt('12.3.4', 45);47console.log(w);48var x = redwood.parseInt('12.3.4', 46);49console.log(x);50var y = redwood.parseInt('12.3.4', 47);51console.log(y);

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var num = redwood.parseInt('123');3console.log(num);4### redwood.parseJSON(jsonString)5var redwood = require('redwood');6var json = redwood.parseJSON('{"name":"redwood"}');7console.log(json.name);8### redwood.parseXML(xmlString)9var redwood = require('redwood');10var xml = redwood.parseXML('<name>redwood</name>');11console.log(xml.name);12### redwood.parseYAML(yamlString)13var redwood = require('redwood');14var yaml = redwood.parseYAML('name: redwood');15console.log(yaml.name);16### redwood.parseCSV(csvString)17var redwood = require('redwood');18var csv = redwood.parseCSV('name,redwood');19console.log(csv[0][0]);20### redwood.parseHTML(htmlString)21var redwood = require('redwood');22var html = redwood.parseHTML('<div>redwood</div>');23console.log(html[0].children[0].data);24### redwood.parseCSS(cssString)25var redwood = require('redwood');26var css = redwood.parseCSS('div{color:red}');27console.log(css[0].type);28### redwood.parseSQL(sqlString)29var redwood = require('redwood');30var sql = redwood.parseSQL('select * from table');31console.log(sql[0].type);32### redwood.parseURL(urlString)33var redwood = require('redwood');

Full Screen

Using AI Code Generation

copy

Full Screen

1var x = parseInt('1');2console.log(x);3var x = parseInt('1');4console.log(x);5var redwood = {6 parseInt: function(string) {7 }8};9var x = redwood.parseInt('1');10console.log(x);11var x = redwood.parseInt('1');12console.log(x);13var y = redwood.parseInt('5');14console.log(y);15var x = redwood.parseInt('1');16console.log(x);17var y = redwood.parseInt('5');18console.log(y);19var z = redwood.parseInt('10');20console.log(z);21var x = redwood.parseInt('1');22console.log(x

Full Screen

Using AI Code Generation

copy

Full Screen

1const { redwood } = require('redwood');2const { parse } = redwood.parseInt;3const num = parse('123');4const { redwood } = require('redwood');5const { parseInt } = redwood.parseInt;6const num = parseInt('123');7const { redwood } = require('redwood');8const { parseFloat } = redwood.parseFloat;9const num = parseFloat('123.45');10const { redwood } = require('redwood');11const { isNaN } = redwood.isNaN;12const { redwood } = require('redwood');13const { isFinite } = redwood.isFinite;14const { redwood } = require('redwood');15const { isInteger } = redwood.isInteger;

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 redwood 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