How to use check method in Cypress

Best JavaScript code snippet using cypress

regress-80981.js

Source:regress-80981.js Github

copy

Full Screen

...3094  }3095  b4();3096  b_after();3097}3098function check(status)3099{3100  print('k = ' + k + '    j = ' + j + '   ' + status);3101  for (i = 0; i < i2; i++)3102  {3103    if (n[i] != 1)3104    {3105      print('n[' + i + '] = ' + n[i]);3106      if (i != j)3107      {3108        print('Test failed');3109        err_num++;3110        break;3111      }3112    }...

Full Screen

Full Screen

createElevationBandMaterialSpec.js

Source:createElevationBandMaterialSpec.js Github

copy

Full Screen

1import { Cartesian4 } from "../../Source/Cesium.js";2import { Color } from "../../Source/Cesium.js";3import { createElevationBandMaterial } from "../../Source/Cesium.js";4import { Math as CesiumMath } from "../../Source/Cesium.js";5import { PixelFormat } from "../../Source/Cesium.js";6import { Texture } from "../../Source/Cesium.js";7import { TextureMinificationFilter } from "../../Source/Cesium.js";8import createScene from "../createScene.js";9describe("Scene/createElevationBandMaterial", function () {10  var scene;11  var isHeightDataPacked;12  var heightData;13  var colorData;14  beforeAll(function () {15    scene = createScene();16    // Color and height textures are differentiated by the sampler filter.17    spyOn(Texture, "create").and.callFake(function (options) {18      var data = options.source.arrayBufferView;19      if (20        options.sampler.minificationFilter === TextureMinificationFilter.NEAREST21      ) {22        heightData = data;23        isHeightDataPacked = options.pixelFormat === PixelFormat.RGBA;24      } else if (25        options.sampler.minificationFilter === TextureMinificationFilter.LINEAR26      ) {27        colorData = data;28      }29    });30  });31  afterAll(function () {32    scene.destroyForSpecs();33  });34  function checkTextureDimensions(expectedDimension) {35    var colorDimension = colorData.length / 4;36    expect(colorDimension).toEqual(expectedDimension);37    var heightDimension = isHeightDataPacked38      ? heightData.length / 439      : heightData.length;40    expect(heightDimension).toEqual(expectedDimension);41  }42  function checkTexel(texel, expectedColor, expectedHeight) {43    var r = colorData[texel * 4 + 0];44    var g = colorData[texel * 4 + 1];45    var b = colorData[texel * 4 + 2];46    var a = colorData[texel * 4 + 3];47    var color = [r, g, b, a];48    // The texture stores colors as premultiplied alpha, so we need to convert49    // the expected color to premultiplied alpha before comparing.50    var premulipliedColor = Color.clone(expectedColor, new Color());51    premulipliedColor.red *= premulipliedColor.alpha;52    premulipliedColor.green *= premulipliedColor.alpha;53    premulipliedColor.blue *= premulipliedColor.alpha;54    expect(color).toEqualEpsilon(premulipliedColor.toBytes(), 1);55    var height = isHeightDataPacked56      ? Cartesian4.unpackFloat(Cartesian4.unpack(heightData, texel * 4))57      : heightData[texel];58    expect(height).toEqualEpsilon(expectedHeight, CesiumMath.EPSILON5);59  }60  it("throws without scene", function () {61    expect(function () {62      createElevationBandMaterial();63    }).toThrowDeveloperError();64  });65  it("throws without layers", function () {66    expect(function () {67      createElevationBandMaterial({68        scene: scene,69      });70    }).toThrowDeveloperError();71    var layers = [];72    expect(function () {73      createElevationBandMaterial({74        scene: scene,75        layers: layers,76      });77    }).toThrowDeveloperError();78  });79  it("throws with no entries", function () {80    var layers = [81      {82        entries: [],83      },84    ];85    expect(function () {86      createElevationBandMaterial({87        scene: scene,88        layers: layers,89      });90    }).toThrowDeveloperError();91  });92  it("throws with no height", function () {93    var layers = [94      {95        entries: [96          {97            color: Color.RED,98          },99        ],100      },101    ];102    expect(function () {103      createElevationBandMaterial({104        scene: scene,105        layers: layers,106      });107    }).toThrowDeveloperError();108  });109  it("throws with no color", function () {110    var layers = [111      {112        entries: [113          {114            height: 0.0,115          },116        ],117      },118    ];119    expect(function () {120      createElevationBandMaterial({121        scene: scene,122        layers: layers,123      });124    }).toThrowDeveloperError();125  });126  it("creates material with one entry", function () {127    var layers = [128      {129        entries: [130          {131            height: 0.0,132            color: Color.RED,133          },134        ],135      },136    ];137    createElevationBandMaterial({138      scene: scene,139      layers: layers,140    });141    checkTextureDimensions(2);142    checkTexel(1, Color.RED, createElevationBandMaterial._maximumHeight);143    checkTexel(0, Color.RED, createElevationBandMaterial._minimumHeight);144  });145  it("creates material with one entry that extends upwards", function () {146    var layers = [147      {148        entries: [149          {150            height: 0.0,151            color: Color.RED,152          },153        ],154        extendUpwards: true,155      },156    ];157    createElevationBandMaterial({158      scene: scene,159      layers: layers,160    });161    checkTextureDimensions(2);162    checkTexel(1, Color.RED, createElevationBandMaterial._maximumHeight);163    checkTexel(0, Color.RED, 0.0);164  });165  it("creates material with one entry that extends downwards", function () {166    var layers = [167      {168        entries: [169          {170            height: 0.0,171            color: Color.RED,172          },173        ],174        extendDownwards: true,175      },176    ];177    createElevationBandMaterial({178      scene: scene,179      layers: layers,180    });181    checkTextureDimensions(2);182    checkTexel(1, Color.RED, 0.0);183    checkTexel(0, Color.RED, createElevationBandMaterial._minimumHeight);184  });185  it("creates material with one entry that extends upwards and downwards", function () {186    var layers = [187      {188        entries: [189          {190            height: 0.0,191            color: Color.RED,192          },193        ],194        extendUpwards: true,195        extendDownwards: true,196      },197    ];198    createElevationBandMaterial({199      scene: scene,200      layers: layers,201    });202    checkTextureDimensions(2);203    checkTexel(1, Color.RED, createElevationBandMaterial._maximumHeight);204    checkTexel(0, Color.RED, createElevationBandMaterial._minimumHeight);205  });206  it("removes unused entries", function () {207    var layers = [208      {209        entries: [210          {211            height: 3.0,212            color: new Color(1, 0, 0, 1),213          },214          {215            height: 3.0,216            color: new Color(0, 1, 0, 1),217          },218          {219            height: 2.0,220            color: new Color(0, 1, 0, 1),221          },222          {223            height: 1.0,224            color: new Color(0, 1, 0, 1),225          },226          {227            height: 0.0,228            color: new Color(0, 1, 0, 1),229          },230          {231            height: 0.0,232            color: new Color(1, 0, 0, 1),233          },234          {235            height: 0.0,236            color: new Color(0, 1, 0, 1),237          },238          {239            height: 0.0,240            color: new Color(1, 0, 0, 1),241          },242          {243            height: 0.0,244            color: new Color(1, 0, 0, 1),245          },246        ],247      },248    ];249    createElevationBandMaterial({250      scene: scene,251      layers: layers,252    });253    checkTextureDimensions(2);254    checkTexel(1, new Color(0, 1, 0, 1), 3.0);255    checkTexel(0, new Color(0, 1, 0, 1), 0.0);256  });257  it("sorts entries", function () {258    var layers = [259      {260        entries: [261          {262            height: 1.0,263            color: new Color(0, 1, 0, 1),264          },265          {266            height: 2.0,267            color: new Color(0, 0, 1, 1),268          },269          {270            height: 0.0,271            color: new Color(1, 0, 0, 1),272          },273        ],274      },275    ];276    createElevationBandMaterial({277      scene: scene,278      layers: layers,279    });280    checkTextureDimensions(3);281    checkTexel(2, new Color(0, 0, 1, 1), 2.0);282    checkTexel(1, new Color(0, 1, 0, 1), 1.0);283    checkTexel(0, new Color(1, 0, 0, 1), 0.0);284  });285  it("creates material with antialiased band", function () {286    var layers = [287      {288        entries: [289          {290            height: +1.0,291            color: new Color(1, 0, 0, 0),292          },293          {294            height: +0.9,295            color: new Color(1, 0, 0, 1),296          },297          {298            height: -0.9,299            color: new Color(1, 0, 0, 1),300          },301          {302            height: -1.0,303            color: new Color(1, 0, 0, 0),304          },305        ],306      },307    ];308    createElevationBandMaterial({309      scene: scene,310      layers: layers,311    });312    checkTextureDimensions(4);313    checkTexel(3, new Color(1, 0, 0, 0), +1.0);314    checkTexel(2, new Color(1, 0, 0, 1), +0.9);315    checkTexel(1, new Color(1, 0, 0, 1), -0.9);316    checkTexel(0, new Color(1, 0, 0, 0), -1.0);317  });318  it("creates material with one layer completely before another", function () {319    var layers = [320      {321        entries: [322          {323            height: 1.0,324            color: Color.RED,325          },326          {327            height: 2.0,328            color: Color.RED,329          },330        ],331      },332      {333        entries: [334          {335            height: -1.0,336            color: Color.BLUE,337          },338          {339            height: -2.0,340            color: Color.BLUE,341          },342        ],343      },344    ];345    createElevationBandMaterial({346      scene: scene,347      layers: layers,348    });349    checkTextureDimensions(6);350    checkTexel(5, Color.RED, +2.0);351    checkTexel(4, Color.RED, +1.0);352    checkTexel(3, createElevationBandMaterial._emptyColor, +1.0);353    checkTexel(2, createElevationBandMaterial._emptyColor, -1.0);354    checkTexel(1, Color.BLUE, -1.0);355    checkTexel(0, Color.BLUE, -2.0);356  });357  it("creates material with one layer completely after another", function () {358    var layers = [359      {360        entries: [361          {362            height: -1.0,363            color: Color.BLUE,364          },365          {366            height: -2.0,367            color: Color.BLUE,368          },369        ],370      },371      {372        entries: [373          {374            height: +1.0,375            color: Color.RED,376          },377          {378            height: +2.0,379            color: Color.RED,380          },381        ],382      },383    ];384    createElevationBandMaterial({385      scene: scene,386      layers: layers,387    });388    checkTextureDimensions(6);389    checkTexel(5, Color.RED, +2.0);390    checkTexel(4, Color.RED, +1.0);391    checkTexel(3, createElevationBandMaterial._emptyColor, +1.0);392    checkTexel(2, createElevationBandMaterial._emptyColor, -1.0);393    checkTexel(1, Color.BLUE, -1.0);394    checkTexel(0, Color.BLUE, -2.0);395  });396  it("creates material with larger transparent layer on top of solid color layer", function () {397    var layers = [398      {399        entries: [400          {401            height: +1.0,402            color: new Color(1.0, 1.0, 1.0, 1.0),403          },404          {405            height: -1.0,406            color: new Color(1.0, 1.0, 1.0, 1.0),407          },408        ],409      },410      {411        entries: [412          {413            height: +2.0,414            color: new Color(1.0, 0.0, 0.0, 0.5),415          },416          {417            height: -2.0,418            color: new Color(1.0, 0.0, 0.0, 0.5),419          },420        ],421      },422    ];423    createElevationBandMaterial({424      scene: scene,425      layers: layers,426    });427    checkTextureDimensions(6);428    checkTexel(5, new Color(1.0, 0.0, 0.0, 0.5), +2.0);429    checkTexel(4, new Color(1.0, 0.0, 0.0, 0.5), +1.0);430    checkTexel(3, new Color(1.0, 0.5, 0.5, 1.0), +1.0);431    checkTexel(2, new Color(1.0, 0.5, 0.5, 1.0), -1.0);432    checkTexel(1, new Color(1.0, 0.0, 0.0, 0.5), -1.0);433    checkTexel(0, new Color(1.0, 0.0, 0.0, 0.5), -2.0);434  });435  it("creates material with smaller transparent layer on top of solid color layer", function () {436    var layers = [437      {438        entries: [439          {440            height: +2.0,441            color: new Color(1.0, 1.0, 1.0, 1.0),442          },443          {444            height: -2.0,445            color: new Color(1.0, 1.0, 1.0, 1.0),446          },447        ],448      },449      {450        entries: [451          {452            height: +1.0,453            color: new Color(1.0, 0.0, 0.0, 0.5),454          },455          {456            height: -1.0,457            color: new Color(1.0, 0.0, 0.0, 0.5),458          },459        ],460      },461    ];462    createElevationBandMaterial({463      scene: scene,464      layers: layers,465    });466    checkTextureDimensions(6);467    checkTexel(5, new Color(1.0, 1.0, 1.0, 1.0), +2.0);468    checkTexel(4, new Color(1.0, 1.0, 1.0, 1.0), +1.0);469    checkTexel(3, new Color(1.0, 0.5, 0.5, 1.0), +1.0);470    checkTexel(2, new Color(1.0, 0.5, 0.5, 1.0), -1.0);471    checkTexel(1, new Color(1.0, 1.0, 1.0, 1.0), -1.0);472    checkTexel(0, new Color(1.0, 1.0, 1.0, 1.0), -2.0);473  });474  it("creates material with transparent bi-color layer on top of bi-color layer", function () {475    var layers = [476      {477        entries: [478          {479            height: +1.0,480            color: new Color(1.0, 1.0, 1.0, 1.0),481          },482          {483            height: 0.0,484            color: new Color(1.0, 1.0, 1.0, 1.0),485          },486          {487            height: 0.0,488            color: new Color(0.0, 0.0, 0.0, 1.0),489          },490          {491            height: -1.0,492            color: new Color(0.0, 0.0, 0.0, 1.0),493          },494        ],495      },496      {497        entries: [498          {499            height: +1.0,500            color: new Color(1.0, 0.0, 0.0, 0.5),501          },502          {503            height: 0.0,504            color: new Color(1.0, 0.0, 0.0, 0.5),505          },506          {507            height: 0.0,508            color: new Color(0.0, 1.0, 0.0, 0.5),509          },510          {511            height: -1.0,512            color: new Color(0.0, 1.0, 0.0, 0.5),513          },514        ],515      },516    ];517    createElevationBandMaterial({518      scene: scene,519      layers: layers,520    });521    checkTextureDimensions(4);522    checkTexel(3, new Color(1.0, 0.5, 0.5, 1.0), +1.0);523    checkTexel(2, new Color(1.0, 0.5, 0.5, 1.0), 0.0);524    checkTexel(1, new Color(0.0, 0.5, 0.0, 1.0), 0.0);525    checkTexel(0, new Color(0.0, 0.5, 0.0, 1.0), -1.0);526  });527  it("creates material with transparent bi-color layer on top of gradient layer", function () {528    var layers = [529      {530        entries: [531          {532            height: +1.0,533            color: new Color(0.0, 0.0, 0.0, 1.0),534          },535          {536            height: 0.0,537            color: new Color(1.0, 1.0, 1.0, 1.0),538          },539          {540            height: -1.0,541            color: new Color(0.0, 0.0, 0.0, 1.0),542          },543        ],544      },545      {546        entries: [547          {548            height: +1.0,549            color: new Color(1.0, 0.0, 0.0, 0.5),550          },551          {552            height: 0.0,553            color: new Color(1.0, 0.0, 0.0, 0.5),554          },555          {556            height: 0.0,557            color: new Color(0.0, 1.0, 0.0, 0.5),558          },559          {560            height: -1.0,561            color: new Color(0.0, 1.0, 0.0, 0.5),562          },563        ],564      },565    ];566    createElevationBandMaterial({567      scene: scene,568      layers: layers,569    });570    checkTextureDimensions(4);571    checkTexel(3, new Color(0.5, 0.0, 0.0, 1.0), +1.0);572    checkTexel(2, new Color(1.0, 0.5, 0.5, 1.0), 0.0);573    checkTexel(1, new Color(0.5, 1.0, 0.5, 1.0), 0.0);574    checkTexel(0, new Color(0.0, 0.5, 0.0, 1.0), -1.0);575  });576  it("creates material with transparent gradient layer on top of bi-color layer", function () {577    var layers = [578      {579        entries: [580          {581            height: +1.0,582            color: new Color(1.0, 1.0, 1.0, 1.0),583          },584          {585            height: 0.0,586            color: new Color(1.0, 1.0, 1.0, 1.0),587          },588          {589            height: 0.0,590            color: new Color(0.0, 0.0, 0.0, 1.0),591          },592          {593            height: -1.0,594            color: new Color(0.0, 0.0, 0.0, 1.0),595          },596        ],597      },598      {599        entries: [600          {601            height: +1.0,602            color: new Color(1.0, 0.0, 0.0, 0.5),603          },604          {605            height: 0.0,606            color: new Color(0.0, 1.0, 0.0, 0.5),607          },608          {609            height: -1.0,610            color: new Color(1.0, 0.0, 0.0, 0.5),611          },612        ],613      },614    ];615    createElevationBandMaterial({616      scene: scene,617      layers: layers,618    });619    checkTextureDimensions(4);620    checkTexel(3, new Color(1.0, 0.5, 0.5, 1.0), +1.0);621    checkTexel(2, new Color(0.5, 1.0, 0.5, 1.0), 0.0);622    checkTexel(1, new Color(0.0, 0.5, 0.0, 1.0), 0.0);623    checkTexel(0, new Color(0.5, 0.0, 0.0, 1.0), -1.0);624  });625  it("creates material with transparent gradient layer on top of gradient layer", function () {626    var layers = [627      {628        entries: [629          {630            height: +1.0,631            color: new Color(1.0, 1.0, 1.0, 1.0),632          },633          {634            height: 0.0,635            color: new Color(0.0, 0.0, 0.0, 1.0),636          },637          {638            height: -1.0,639            color: new Color(1.0, 1.0, 1.0, 1.0),640          },641        ],642      },643      {644        entries: [645          {646            height: +1.0,647            color: new Color(1.0, 0.0, 0.0, 0.5),648          },649          {650            height: 0.0,651            color: new Color(0.0, 1.0, 0.0, 0.5),652          },653          {654            height: -1.0,655            color: new Color(1.0, 0.0, 0.0, 0.5),656          },657        ],658      },659    ];660    createElevationBandMaterial({661      scene: scene,662      layers: layers,663    });664    checkTextureDimensions(3);665    checkTexel(2, new Color(1.0, 0.5, 0.5, 1.0), +1.0);666    checkTexel(1, new Color(0.0, 0.5, 0.0, 1.0), 0.0);667    checkTexel(0, new Color(1.0, 0.5, 0.5, 1.0), -1.0);668  });669  it("creates material with transparent gradient layer on top of solid color layer", function () {670    var layers = [671      {672        entries: [673          {674            height: +1.0,675            color: new Color(1.0, 1.0, 1.0, 1.0),676          },677          {678            height: -1.0,679            color: new Color(1.0, 1.0, 1.0, 1.0),680          },681        ],682      },683      {684        entries: [685          {686            height: +1.0,687            color: new Color(1.0, 0.0, 0.0, 0.5),688          },689          {690            height: 0.0,691            color: new Color(0.0, 1.0, 0.0, 0.5),692          },693          {694            height: -1.0,695            color: new Color(1.0, 0.0, 0.0, 0.5),696          },697        ],698      },699    ];700    createElevationBandMaterial({701      scene: scene,702      layers: layers,703    });704    checkTextureDimensions(3);705    checkTexel(2, new Color(1.0, 0.5, 0.5, 1.0), +1.0);706    checkTexel(1, new Color(0.5, 1.0, 0.5, 1.0), 0.0);707    checkTexel(0, new Color(1.0, 0.5, 0.5, 1.0), -1.0);708  });709  it("creates material with transparent layer on top of gradient layer", function () {710    var layers = [711      {712        entries: [713          {714            height: +1.0,715            color: new Color(1.0, 0.0, 0.0, 1.0),716          },717          {718            height: 0.0,719            color: new Color(0.0, 1.0, 0.0, 1.0),720          },721          {722            height: -1.0,723            color: new Color(1.0, 0.0, 0.0, 1.0),724          },725        ],726      },727      {728        entries: [729          {730            height: +1.0,731            color: new Color(1.0, 1.0, 1.0, 0.5),732          },733          {734            height: -1.0,735            color: new Color(1.0, 1.0, 1.0, 0.5),736          },737        ],738      },739    ];740    createElevationBandMaterial({741      scene: scene,742      layers: layers,743    });744    checkTextureDimensions(3);745    checkTexel(2, new Color(1.0, 0.5, 0.5, 1.0), +1.0);746    checkTexel(1, new Color(0.5, 1.0, 0.5, 1.0), 0.0);747    checkTexel(0, new Color(1.0, 0.5, 0.5, 1.0), -1.0);748  });749  it("creates material with higher layer starting and ending on middle of lower layer", function () {750    var layers = [751      {752        entries: [753          {754            height: +1.0,755            color: new Color(1.0, 1.0, 1.0, 1.0),756          },757          {758            height: +0.5,759            color: new Color(1.0, 1.0, 1.0, 1.0),760          },761          {762            height: -0.5,763            color: new Color(0.0, 0.0, 0.0, 1.0),764          },765          {766            height: -1.0,767            color: new Color(0.0, 0.0, 0.0, 1.0),768          },769        ],770      },771      {772        entries: [773          {774            height: +0.5,775            color: new Color(1.0, 0.0, 0.0, 0.5),776          },777          {778            height: -0.5,779            color: new Color(0.0, 1.0, 0.0, 0.5),780          },781        ],782      },783    ];784    createElevationBandMaterial({785      scene: scene,786      layers: layers,787    });788    checkTextureDimensions(6);789    checkTexel(5, new Color(1.0, 1.0, 1.0, 1.0), +1.0);790    checkTexel(4, new Color(1.0, 1.0, 1.0, 1.0), +0.5);791    checkTexel(3, new Color(1.0, 0.5, 0.5, 1.0), +0.5);792    checkTexel(2, new Color(0.0, 0.5, 0.0, 1.0), -0.5);793    checkTexel(1, new Color(0.0, 0.0, 0.0, 1.0), -0.5);794    checkTexel(0, new Color(0.0, 0.0, 0.0, 1.0), -1.0);795  });796  it("creates material with lower layer starting and ending on middle of higher layer", function () {797    var layers = [798      {799        entries: [800          {801            height: +1.0,802            color: Color.WHITE,803          },804          {805            height: -1.0,806            color: Color.WHITE,807          },808        ],809      },810      {811        entries: [812          {813            height: +2.0,814            color: new Color(1.0, 0.0, 0.0, 0.5),815          },816          {817            height: +1.0,818            color: new Color(0.0, 1.0, 0.0, 0.5),819          },820          {821            height: -1.0,822            color: new Color(0.0, 1.0, 0.0, 0.5),823          },824          {825            height: -2.0,826            color: new Color(1.0, 0.0, 0.0, 0.5),827          },828        ],829      },830    ];831    createElevationBandMaterial({832      scene: scene,833      layers: layers,834    });835    checkTextureDimensions(6);836    checkTexel(5, new Color(1.0, 0.0, 0.0, 0.5), +2.0);837    checkTexel(4, new Color(0.0, 1.0, 0.0, 0.5), +1.0);838    checkTexel(3, new Color(0.5, 1.0, 0.5, 1.0), +1.0);839    checkTexel(2, new Color(0.5, 1.0, 0.5, 1.0), -1.0);840    checkTexel(1, new Color(0.0, 1.0, 0.0, 0.5), -1.0);841    checkTexel(0, new Color(1.0, 0.0, 0.0, 0.5), -2.0);842  });843  it("creates multi-layered material", function () {844    var layers = [845      {846        entries: [847          {848            height: +1.0,849            color: Color.BLACK,850          },851          {852            height: 0.0,853            color: Color.WHITE,854          },855          {856            height: -1.0,857            color: Color.BLACK,858          },859        ],860      },861      {862        entries: [863          {864            height: +2.0,865            color: new Color(1.0, 0.0, 0.0, 1.0),866          },867          {868            height: +1.0,869            color: new Color(1.0, 0.0, 0.0, 1.0),870          },871        ],872      },873      {874        entries: [875          {876            height: -1.0,877            color: new Color(1.0, 0.0, 0.0, 1.0),878          },879          {880            height: -2.0,881            color: new Color(1.0, 0.0, 0.0, 1.0),882          },883        ],884      },885      {886        entries: [887          {888            height: +0.5,889            color: new Color(0.0, 1.0, 0.0, 0.5),890          },891          {892            height: 0.0,893            color: new Color(0.0, 1.0, 0.0, 0.5),894          },895        ],896      },897      {898        entries: [899          {900            height: 0.0,901            color: new Color(0.0, 0.0, 1.0, 0.5),902          },903          {904            height: -0.5,905            color: new Color(0.0, 0.0, 1.0, 0.5),906          },907        ],908      },909    ];910    createElevationBandMaterial({911      scene: scene,912      layers: layers,913    });914    checkTextureDimensions(12);915    checkTexel(11, new Color(1.0, 0.0, 0.0, 1.0), +2.0);916    checkTexel(10, new Color(1.0, 0.0, 0.0, 1.0), +1.0);917    checkTexel(9, new Color(0.0, 0.0, 0.0, 1.0), +1.0);918    checkTexel(8, new Color(0.5, 0.5, 0.5, 1.0), +0.5);919    checkTexel(7, new Color(0.25, 0.75, 0.25, 1.0), +0.5);920    checkTexel(6, new Color(0.5, 1.0, 0.5, 1.0), 0.0);921    checkTexel(5, new Color(0.5, 0.5, 1.0, 1.0), 0.0);922    checkTexel(4, new Color(0.25, 0.25, 0.75, 1.0), -0.5);923    checkTexel(3, new Color(0.5, 0.5, 0.5, 1.0), -0.5);924    checkTexel(2, new Color(0.0, 0.0, 0.0, 1.0), -1.0);925    checkTexel(1, new Color(1.0, 0.0, 0.0, 1.0), -1.0);926    checkTexel(0, new Color(1.0, 0.0, 0.0, 1.0), -2.0);927  });928  it("creates another multi-layered material", function () {929    var layers = [930      {931        entries: [932          {933            height: +1.0,934            color: Color.BLACK,935          },936          {937            height: 0.0,938            color: Color.BLACK,939          },940          {941            height: 0.0,942            color: Color.WHITE,943          },944          {945            height: -1.0,946            color: Color.WHITE,947          },948        ],949      },950      {951        entries: [952          {953            height: 0.5,954            color: new Color(0.0, 0.0, 1.0, 1.0),955          },956          {957            height: 0.0,958            color: new Color(0.0, 0.0, 1.0, 1.0),959          },960        ],961      },962      {963        entries: [964          {965            height: +1.1,966            color: new Color(1.0, 0.0, 0.0, 0.5),967          },968          {969            height: +1.0,970            color: new Color(1.0, 0.0, 0.0, 0.5),971          },972          {973            height: +1.0,974            color: new Color(0.0, 1.0, 0.0, 0.5),975          },976          {977            height: +0.9,978            color: new Color(0.0, 1.0, 0.0, 0.5),979          },980        ],981      },982      {983        entries: [984          {985            height: -0.9,986            color: new Color(1.0, 0.0, 0.0, 0.5),987          },988          {989            height: -1.0,990            color: new Color(1.0, 0.0, 0.0, 0.5),991          },992          {993            height: -1.0,994            color: new Color(0.0, 1.0, 0.0, 0.5),995          },996          {997            height: -1.1,998            color: new Color(0.0, 1.0, 0.0, 0.5),999          },1000        ],1001      },1002    ];1003    createElevationBandMaterial({1004      scene: scene,1005      layers: layers,1006    });1007    checkTextureDimensions(14);1008    checkTexel(13, new Color(1.0, 0.0, 0.0, 0.5), +1.1);1009    checkTexel(12, new Color(1.0, 0.0, 0.0, 0.5), +1.0);1010    checkTexel(11, new Color(0.0, 0.5, 0.0, 1.0), +1.0);1011    checkTexel(10, new Color(0.0, 0.5, 0.0, 1.0), +0.9);1012    checkTexel(9, new Color(0.0, 0.0, 0.0, 1.0), +0.9);1013    checkTexel(8, new Color(0.0, 0.0, 0.0, 1.0), 0.5);1014    checkTexel(7, new Color(0.0, 0.0, 1.0, 1.0), 0.5);1015    checkTexel(6, new Color(0.0, 0.0, 1.0, 1.0), 0.0);1016    checkTexel(5, new Color(1.0, 1.0, 1.0, 1.0), 0.0);1017    checkTexel(4, new Color(1.0, 1.0, 1.0, 1.0), -0.9);1018    checkTexel(3, new Color(1.0, 0.5, 0.5, 1.0), -0.9);1019    checkTexel(2, new Color(1.0, 0.5, 0.5, 1.0), -1.0);1020    checkTexel(1, new Color(0.0, 1.0, 0.0, 0.5), -1.0);1021    checkTexel(0, new Color(0.0, 1.0, 0.0, 0.5), -1.1);1022  });1023  it("creates material with complex layers", function () {1024    var layers = [1025      {1026        entries: [1027          {1028            height: +1000.0,1029            color: Color.WHITE,1030          },1031          {1032            height: -1000.0,1033            color: Color.BLACK,1034          },1035        ],1036        extendDownwards: true,1037      },1038      {1039        entries: [1040          {1041            height: +500.0,1042            color: new Color(1.0, 0.0, 0.0, 1.0),1043          },1044          {1045            height: -500.0,1046            color: new Color(1.0, 0.0, 0.0, 0.5),1047          },1048        ],1049      },1050    ];1051    createElevationBandMaterial({1052      scene: scene,1053      layers: layers,1054    });1055    checkTextureDimensions(7);1056    checkTexel(6, new Color(1, 1, 1, 1), +1000.0);1057    checkTexel(5, new Color(0.75, 0.75, 0.75, 1), +500.0);1058    checkTexel(4, new Color(1, 0, 0, 1), +500.0);1059    checkTexel(3, new Color(0.625, 0.125, 0.125, 1), -500.0);1060    checkTexel(2, new Color(0.25, 0.25, 0.25, 1), -500.0);1061    checkTexel(1, new Color(0, 0, 0, 1), -1000.0);1062    checkTexel(1063      0,1064      new Color(0, 0, 0, 1),1065      createElevationBandMaterial._minimumHeight1066    );1067  });1068  it("creates material with unpacked height", function () {1069    var layers = [1070      {1071        entries: [1072          {1073            height: 0.0,1074            color: Color.RED,1075          },1076          {1077            height: 1.0,1078            color: Color.RED,1079          },1080        ],1081      },1082    ];1083    spyOn(createElevationBandMaterial, "_useFloatTexture").and.returnValue(1084      false1085    );1086    createElevationBandMaterial({1087      scene: scene,1088      layers: layers,1089    });1090    checkTextureDimensions(2);1091    checkTexel(1, Color.RED, 1.0);1092    checkTexel(0, Color.RED, 0.0);1093  });1094  it("creates material with packed height", function () {1095    var layers = [1096      {1097        entries: [1098          {1099            height: 0.0,1100            color: Color.RED,1101          },1102          {1103            height: 1.0,1104            color: Color.RED,1105          },1106        ],1107      },1108    ];1109    spyOn(createElevationBandMaterial, "_useFloatTexture").and.returnValue(1110      true1111    );1112    createElevationBandMaterial({1113      scene: scene,1114      layers: layers,1115    });1116    checkTextureDimensions(2);1117    checkTexel(1, Color.RED, 1.0);1118    checkTexel(0, Color.RED, 0.0);1119  });...

Full Screen

Full Screen

cpp11_strongly_typed_enumerations_runme.js

Source:cpp11_strongly_typed_enumerations_runme.js Github

copy

Full Screen

1var cpp11_strongly_typed_enumerations = require("cpp11_strongly_typed_enumerations");2function enumCheck(actual, expected) {3  if (actual != expected) {4    throw new Error("Enum value mismatch. Expected: " + expected + " Actual: " + actual);5  }6  return expected + 1;7}8val = 0;9val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val1, val);10val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val2, val);11val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val3, 13);12val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val4, val);13val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val5a, 13);14val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val6a, val);15val = 0;16val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val1, val);17val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val2, val);18val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val3, 23);19val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val4, val);20val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val5b, 23);21val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val6b, val);22val = 0;23val = enumCheck(cpp11_strongly_typed_enumerations.Val1, val);24val = enumCheck(cpp11_strongly_typed_enumerations.Val2, val);25val = enumCheck(cpp11_strongly_typed_enumerations.Val3, 43);26val = enumCheck(cpp11_strongly_typed_enumerations.Val4, val);27val = 0;28val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val1, val);29val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val2, val);30val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val3, 53);31val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val4, val);32val = 0;33val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val1, val);34val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val2, val);35val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val3, 63);36val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val4, val);37val = 0;38val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val1, val);39val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val2, val);40val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val3, 73);41val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val4, val);42val = 0;43val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val1, val);44val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val2, val);45val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val3, 83);46val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val4, val);47val = 0;48val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val1, val);49val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val2, val);50val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val3, 103);51val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val4, val);52val = 0;53val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val1, 1121);54val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val2, 1122);55val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val3, val);56val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val4, val);57val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c, 1121);58val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val6c, val);59val = 0;60val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val1, 1131);61val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val2, 1132);62val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val3, val);63val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val4, val);64val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val5d, 1131);65val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val6d, val);66val = 0;67val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val1, 1141);68val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val2, 1142);69val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val3, val);70val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val4, val);71val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val5e, 1141);72val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val6e, val);73// Requires nested class support to work74//val = 0;75//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val1, 3121);76//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val2, 3122);77//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val3, val);78//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val4, val);79//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f, 3121);80//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val6f, val);81//82//val = 0;83//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val1, 3131);84//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val2, 3132);85//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val3, val);86//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val4, val);87//88//val = 0;89//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val1, 3141);90//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val2, 3142);91//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val3, val);92//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val4, val);93//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val5g, 3141);94//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val6g, val);95val = 0;96val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val1, 2121);97val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val2, 2122);98val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val3, val);99val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val4, val);100val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val5h, 2121);101val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val6h, val);102val = 0;103val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val1, 2131);104val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val2, 2132);105val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val3, val);106val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val4, val);107val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val5i, 2131);108val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val6i, val);109val = 0;110val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val1, 2141);111val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val2, 2142);112val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val3, val);113val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val4, val);114val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val5j, 2141);115val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val6j, val);116// Requires nested class support to work117//val = 0;118//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val1, 4121);119//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val2, 4122);120//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val3, val);121//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val4, val);122//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val5k, 4121);123//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val6k, val);124//125//val = 0;126//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val1, 4131);127//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val2, 4132);128//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val3, val);129//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val4, val);130//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val5l, 4131);131//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val6l, val);132//133//val = 0;134//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val1, 4141);135//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val2, 4142);136//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val3, val);137//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val4, val);138//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val5m, 4141);139//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val6m, val);140class1 = new cpp11_strongly_typed_enumerations.Class1();141enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);142enumCheck(class1.class1Test2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121);143//enumCheck(class1.class1Test3(cpp11_strongly_typed_enumerations.Class1.Struct1_Enum12_Val5f), 3121);144enumCheck(cpp11_strongly_typed_enumerations.globalTest1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);145enumCheck(cpp11_strongly_typed_enumerations.globalTest2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121);...

Full Screen

Full Screen

code2.js

Source:code2.js Github

copy

Full Screen

1gdjs.SynchronisedCheckBoxCode = {};2gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1= [];3gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2= [];4gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects3= [];5gdjs.SynchronisedCheckBoxCode.conditionTrue_0 = {val:false};6gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0 = {val:false};7gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0 = {val:false};8gdjs.SynchronisedCheckBoxCode.condition2IsTrue_0 = {val:false};9gdjs.SynchronisedCheckBoxCode.condition3IsTrue_0 = {val:false};10gdjs.SynchronisedCheckBoxCode.conditionTrue_1 = {val:false};11gdjs.SynchronisedCheckBoxCode.condition0IsTrue_1 = {val:false};12gdjs.SynchronisedCheckBoxCode.condition1IsTrue_1 = {val:false};13gdjs.SynchronisedCheckBoxCode.condition2IsTrue_1 = {val:false};14gdjs.SynchronisedCheckBoxCode.condition3IsTrue_1 = {val:false};15gdjs.SynchronisedCheckBoxCode.mapOfGDgdjs_46SynchronisedCheckBoxCode_46GDcheckboxObjects1Objects = Hashtable.newFrom({"checkbox": gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1});gdjs.SynchronisedCheckBoxCode.eventsList0 = function(runtimeScene) {16{17gdjs.copyArray(gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1, gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2);18gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = false;19{20for(var i = 0, k = 0, l = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2.length;i<l;++i) {21    if ( gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2[i].isCurrentAnimationName("checked") ) {22        gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = true;23        gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2[k] = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2[i];24        ++k;25    }26}27gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2.length = k;}if (gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val) {28/* Reuse gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2 */29{gdjs.evtTools.p2p.sendDataToAll("uncheck", (gdjs.RuntimeObject.getVariableString(((gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2.length === 0 ) ? gdjs.VariablesContainer.badVariablesContainer : gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2[0].getVariables()).getFromIndex(0))));30}{for(var i = 0, len = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2.length ;i < len;++i) {31    gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2[i].setAnimationName("unchecked");32}33}{runtimeScene.getVariables().get("temp").setNumber(1);34}}35}36{37/* Reuse gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1 */38gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = false;39gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val = false;40{41gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = gdjs.evtTools.variable.getVariableNumber(runtimeScene.getVariables().get("temp")) == 0;42}if ( gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val ) {43{44for(var i = 0, k = 0, l = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length;i<l;++i) {45    if ( gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i].isCurrentAnimationName("unchecked") ) {46        gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val = true;47        gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[k] = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i];48        ++k;49    }50}51gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length = k;}}52if (gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val) {53/* Reuse gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1 */54{gdjs.evtTools.p2p.sendDataToAll("check", (gdjs.RuntimeObject.getVariableString(((gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length === 0 ) ? gdjs.VariablesContainer.badVariablesContainer : gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[0].getVariables()).getFromIndex(0))));55}{for(var i = 0, len = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length ;i < len;++i) {56    gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i].setAnimationName("checked");57}58}}59}60};gdjs.SynchronisedCheckBoxCode.eventsList1 = function(runtimeScene) {61{62}63{64gdjs.copyArray(runtimeScene.getObjects("checkbox"), gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1);65gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = false;66gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val = false;67gdjs.SynchronisedCheckBoxCode.condition2IsTrue_0.val = false;68{69gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = gdjs.evtTools.input.isMouseButtonPressed(runtimeScene, "Left");70}if ( gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val ) {71{72{gdjs.SynchronisedCheckBoxCode.conditionTrue_1 = gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0;73gdjs.SynchronisedCheckBoxCode.conditionTrue_1.val = runtimeScene.getOnceTriggers().triggerOnce(9317612);74}75}if ( gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val ) {76{77gdjs.SynchronisedCheckBoxCode.condition2IsTrue_0.val = gdjs.evtTools.input.cursorOnObject(gdjs.SynchronisedCheckBoxCode.mapOfGDgdjs_46SynchronisedCheckBoxCode_46GDcheckboxObjects1Objects, runtimeScene, true, false);78}}79}80if (gdjs.SynchronisedCheckBoxCode.condition2IsTrue_0.val) {81{runtimeScene.getVariables().get("temp").setNumber(0);82}83{ //Subevents84gdjs.SynchronisedCheckBoxCode.eventsList0(runtimeScene);} //End of subevents85}86}87{88}89{90gdjs.copyArray(runtimeScene.getObjects("checkbox"), gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1);91gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = false;92gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val = false;93{94gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = gdjs.evtTools.p2p.onEvent("check", false);95}if ( gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val ) {96{97for(var i = 0, k = 0, l = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length;i<l;++i) {98    if ( gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i].getVariableNumber(gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i].getVariables().getFromIndex(0)) == gdjs.evtTools.common.toNumber(gdjs.evtTools.p2p.getEventData("check")) ) {99        gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val = true;100        gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[k] = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i];101        ++k;102    }103}104gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length = k;}}105if (gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val) {106/* Reuse gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1 */107{for(var i = 0, len = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length ;i < len;++i) {108    gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i].setAnimationName("checked");109}110}}111}112{113gdjs.copyArray(runtimeScene.getObjects("checkbox"), gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1);114gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = false;115gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val = false;116{117gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = gdjs.evtTools.p2p.onEvent("uncheck", false);118}if ( gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val ) {119{120for(var i = 0, k = 0, l = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length;i<l;++i) {121    if ( gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i].getVariableNumber(gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i].getVariables().getFromIndex(0)) == gdjs.evtTools.common.toNumber(gdjs.evtTools.p2p.getEventData("uncheck")) ) {122        gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val = true;123        gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[k] = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i];124        ++k;125    }126}127gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length = k;}}128if (gdjs.SynchronisedCheckBoxCode.condition1IsTrue_0.val) {129/* Reuse gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1 */130{for(var i = 0, len = gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length ;i < len;++i) {131    gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1[i].setAnimationName("unchecked");132}133}}134}135{136}137{138gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val = false;139{140{gdjs.SynchronisedCheckBoxCode.conditionTrue_1 = gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0;141gdjs.SynchronisedCheckBoxCode.condition0IsTrue_1.val = false;142gdjs.SynchronisedCheckBoxCode.condition1IsTrue_1.val = false;143{144gdjs.SynchronisedCheckBoxCode.condition0IsTrue_1.val = gdjs.evtTools.p2p.onError();145if( gdjs.SynchronisedCheckBoxCode.condition0IsTrue_1.val ) {146    gdjs.SynchronisedCheckBoxCode.conditionTrue_1.val = true;147}148}149{150gdjs.SynchronisedCheckBoxCode.condition1IsTrue_1.val = gdjs.evtTools.p2p.onDisconnect();151if( gdjs.SynchronisedCheckBoxCode.condition1IsTrue_1.val ) {152    gdjs.SynchronisedCheckBoxCode.conditionTrue_1.val = true;153}154}155{156}157}158}if (gdjs.SynchronisedCheckBoxCode.condition0IsTrue_0.val) {159{gdjs.evtTools.runtimeScene.replaceScene(runtimeScene, "Disconnected", true);160}}161}162};163gdjs.SynchronisedCheckBoxCode.func = function(runtimeScene) {164runtimeScene.getOnceTriggers().startNewFrame();165gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects1.length = 0;166gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects2.length = 0;167gdjs.SynchronisedCheckBoxCode.GDcheckboxObjects3.length = 0;168gdjs.SynchronisedCheckBoxCode.eventsList1(runtimeScene);169return;170}...

Full Screen

Full Screen

ValidityState-rangeUnderflow.js

Source:ValidityState-rangeUnderflow.js Github

copy

Full Screen

1description('This test aims to check for rangeUnderflow flag with input fields');2var input = document.createElement('input');3function checkUnderflow(value, min)4{5    input.value = value;6    input.min = min;7    var underflow = input.validity.rangeUnderflow;8    var resultText = 'The value "' + input.value + '" ' +9        (underflow ? 'undeflows' : 'doesn\'t underflow') +10        ' the minimum value "' + input.min + '".';11    if (underflow)12        testPassed(resultText);13    else14        testFailed(resultText);15}16function checkNotUnderflow(value, min)17{18    input.value = value;19    input.min = min;20    var underflow = input.validity.rangeUnderflow;21    var resultText = 'The value "' + input.value + '" ' +22        (underflow ? 'underflows' : 'doesn\'t underflow') +23        ' the minimum value "' + input.min + '".';24    if (underflow)25        testFailed(resultText);26    else27        testPassed(resultText);28}29// ----------------------------------------------------------------30debug('Type=text');31input.type = 'text';  // No underflow for type=text.32checkNotUnderflow('99', '100');33// ----------------------------------------------------------------34debug('');35debug('Type=date');36input.type = 'date';37input.max = '';38// No underflow cases39checkNotUnderflow('2010-01-27', null);40checkNotUnderflow('2010-01-27', '');41checkNotUnderflow('2010-01-27', 'foo');42// 1000-01-01 is smaller than the implicit minimum value.43// But the date parser rejects it before comparing the minimum value.44checkNotUnderflow('1000-01-01', '');45checkNotUnderflow('1582-10-15', '');46checkNotUnderflow('2010-01-27', '2010-01-26');47checkNotUnderflow('2010-01-27', '2009-01-28');48checkNotUnderflow('foo', '2011-01-26');49// Underflow cases50checkUnderflow('2010-01-27', '2010-01-28');51checkUnderflow('9999-01-01', '10000-12-31');52input.max = '2010-01-01';  // value < min && value > max53checkUnderflow('2010-01-27', '2010-02-01');54// ----------------------------------------------------------------55debug('');56debug('Type=datetime');57input.type = 'datetime';58input.max = '';59// No underflow cases60checkNotUnderflow('2010-01-27T12:34Z', null);61checkNotUnderflow('2010-01-27T12:34Z', '');62checkNotUnderflow('2010-01-27T12:34Z', 'foo');63// 1000-01-01 is smaller than the implicit minimum value.64// But the date parser rejects it before comparing the minimum value.65checkNotUnderflow('1000-01-01T12:34Z', '');66checkNotUnderflow('1582-10-15T00:00Z', '');67checkNotUnderflow('2010-01-27T12:34Z', '2010-01-26T00:00Z');68checkNotUnderflow('2010-01-27T12:34Z', '2009-01-28T00:00Z');69checkNotUnderflow('foo', '2011-01-26T00:00Z');70// Underflow cases71checkUnderflow('2010-01-27T12:34Z', '2010-01-27T13:00Z');72checkUnderflow('9999-01-01T12:00Z', '10000-12-31T12:00Z');73input.max = '2010-01-01T12:00Z';  // value < min && value > max74checkUnderflow('2010-01-27T12:00Z', '2010-02-01T12:00Z');75// ----------------------------------------------------------------76debug('');77debug('Type=datetime-local');78input.type = 'datetime-local';79input.max = '';80// No underflow cases81checkNotUnderflow('2010-01-27T12:34', null);82checkNotUnderflow('2010-01-27T12:34', '');83checkNotUnderflow('2010-01-27T12:34', 'foo');84// 1000-01-01 is smaller than the implicit minimum value.85// But the date parser rejects it before comparing the minimum value.86checkNotUnderflow('1000-01-01T12:34', '');87checkNotUnderflow('1582-10-15T00:00', '');88checkNotUnderflow('2010-01-27T12:34', '2010-01-26T00:00');89checkNotUnderflow('2010-01-27T12:34', '2009-01-28T00:00');90checkNotUnderflow('foo', '2011-01-26T00:00');91// Underflow cases92checkUnderflow('2010-01-27T12:34', '2010-01-27T13:00');93checkUnderflow('9999-01-01T12:00', '10000-12-31T12:00');94input.max = '2010-01-01T12:00';  // value < min && value > max95checkUnderflow('2010-01-27T12:00', '2010-02-01T12:00');96// ----------------------------------------------------------------97debug('');98debug('Type=month');99input.type = 'month';100input.max = '';101// No underflow cases102checkNotUnderflow('2010-01', null);103checkNotUnderflow('2010-01', '');104checkNotUnderflow('2010-01', 'foo');105// 1000-01 is smaller than the implicit minimum value.106// But the month parser rejects it before comparing the minimum value.107checkNotUnderflow('1000-01', '');108checkNotUnderflow('1582-10', '');109checkNotUnderflow('2010-01', '2009-12');110checkNotUnderflow('2010-01', '2009-01');111checkNotUnderflow('foo', '2011-01');112// Underflow cases113checkUnderflow('2010-01', '2010-02');114checkUnderflow('9999-01', '10000-12');115input.max = '2009-12';  // value < min && value > max116checkUnderflow('2010-01', '2010-02');117// ----------------------------------------------------------------118debug('');119debug('Type=number');120input.type = 'number';121input.max = '';122// No underflow cases123input.type = 'number';124checkNotUnderflow('101', '100');  // Very normal case.125checkNotUnderflow('-99', '-100');126checkNotUnderflow('101', '1E+2');127checkNotUnderflow('1.01', '1.00');128checkNotUnderflow('abc', '100');  // Invalid value.129checkNotUnderflow('', '1');  // No value.130checkNotUnderflow('-1', '');  // No min.131checkNotUnderflow('-1', 'xxx');  // Invalid min.132// The following case should be rangeUnderflow==true ideally.  But the "double" type doesn't have enough precision.133checkNotUnderflow('0.999999999999999999999999999999999999999998', '0.999999999999999999999999999999999999999999');134// Underflow cases135checkUnderflow('99', '100');136checkUnderflow('-101', '-100');137checkUnderflow('99', '1E+2');138input.max = '100';  // value < min && value > max139checkUnderflow('101', '200');140// ----------------------------------------------------------------141debug('');142debug('Type=time');143input.type = 'time';144input.max = '';145// No underflow cases146checkNotUnderflow('13:16', null);147checkNotUnderflow('13:16', '');148checkNotUnderflow('13:16', 'foo');149checkNotUnderflow('00:00:00.000', '');150checkNotUnderflow('23:59:59.999', '');151checkNotUnderflow('13:16', '11:00');152checkNotUnderflow('13:16', '13:16');153checkNotUnderflow('foo', '11:00');154// Underflow cases155checkUnderflow('13:16', '13:17');156checkUnderflow('23:59', '23:59:30');157input.max = '11:00';  // value < min && value > max158checkUnderflow('13:16', '14:00');159// ----------------------------------------------------------------160debug('');161debug('Type=week');162input.type = 'week';163input.max = '';164// No underflow cases165checkNotUnderflow('2010-W01', null);166checkNotUnderflow('2010-W01', '');167checkNotUnderflow('2010-W01', 'foo');168// 1000-W01 is smaller than the implicit minimum value.169// But the month parser rejects it before comparing the minimum value.170checkNotUnderflow('1000-W01', '');171checkNotUnderflow('1583-W01', '');172checkNotUnderflow('2010-W01', '2009-W51');173checkNotUnderflow('2010-W01', '2009-W01');174checkNotUnderflow('foo', '2011-W01');175// Underflow cases176checkUnderflow('2010-W01', '2010-W02');177checkUnderflow('9999-W01', '10000-W12');178input.max = '2009-W52';  // value < min && value > max179checkUnderflow('2010-W01', '2010-W02');...

Full Screen

Full Screen

ValidityState-rangeOverflow.js

Source:ValidityState-rangeOverflow.js Github

copy

Full Screen

1description('This test aims to check for rangeOverflow flag with input fields');2var input = document.createElement('input');3function checkOverflow(value, max)4{5    input.value = value;6    input.max = max;7    var overflow = input.validity.rangeOverflow;8    var resultText = 'The value "' + input.value + '" ' +9        (overflow ? 'overflows' : 'doesn\'t overflow') +10        ' the maximum value "' + input.max + '".';11    if (overflow)12        testPassed(resultText);13    else14        testFailed(resultText);15}16function checkNotOverflow(value, max)17{18    input.value = value;19    input.max = max;20    var overflow = input.validity.rangeOverflow;21    var resultText = 'The value "' + input.value + '" ' +22        (overflow ? 'overflows' : 'doesn\'t overflow') +23        ' the maximum value "' + input.max + '".';24    if (overflow)25        testFailed(resultText);26    else27        testPassed(resultText);28}29// ----------------------------------------------------------------30debug('Type=text');31input.type = 'text';  // No overflow for type=text.32checkNotOverflow('101', '100');33// ----------------------------------------------------------------34debug('');35debug('Type=date');36input.type = 'date';37input.min = '';38// No overflow cases39checkNotOverflow('2010-01-27', null);40checkNotOverflow('2010-01-27', '');41checkNotOverflow('2010-01-27', 'foo');42checkNotOverflow('2010-01-27', '2010-01-27');43checkNotOverflow('2010-01-27', '2010-01-28');44checkNotOverflow('2010-01-27', '2011-01-26');45checkNotOverflow('foo', '2011-01-26');46checkNotOverflow('2010-01-27', '1000-01-01'); // Too small max value.47// Overflow cases48checkOverflow('2010-01-27', '2010-01-26');49checkOverflow('9999-01-01', '2010-12-31');50input.min = '2010-01-28';  // value < min && value > max51checkOverflow('2010-01-27', '2010-01-26');52// ----------------------------------------------------------------53debug('');54debug('Type=datetime');55input.type = 'datetime';56input.min = '';57// No overflow cases58checkNotOverflow('2010-01-27T12:34Z', null);59checkNotOverflow('2010-01-27T12:34Z', '');60checkNotOverflow('2010-01-27T12:34Z', 'foo');61checkNotOverflow('2010-01-27T12:34Z', '2010-01-27T12:34Z');62checkNotOverflow('2010-01-27T12:34Z', '2010-01-27T12:34:56Z');63checkNotOverflow('2010-01-27T12:34Z', '2011-01-26T12:34Z');64checkNotOverflow('foo', '2011-01-26T12:34Z');65checkNotOverflow('2010-01-27T12:34Z', '1000-01-01T00:00Z'); // Too small max value.66// Overflow cases67checkOverflow('2010-01-27T12:34Z', '2010-01-26T12:33:59.999Z');68checkOverflow('9999-01-01T23:59Z', '2010-12-31T00:00Z');69input.min = '2010-01-28T12:00Z';  // value < min && value > max70checkOverflow('2010-01-27T12:34Z', '2010-01-26T12:34Z');71// ----------------------------------------------------------------72debug('');73debug('Type=datetime-local');74input.type = 'datetime-local';75input.min = '';76// No overflow cases77checkNotOverflow('2010-01-27T12:34', null);78checkNotOverflow('2010-01-27T12:34', '');79checkNotOverflow('2010-01-27T12:34', 'foo');80checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34');81checkNotOverflow('2010-01-27T12:34', '2010-01-27T12:34:56');82checkNotOverflow('2010-01-27T12:34', '2011-01-26T12:34');83checkNotOverflow('foo', '2011-01-26T12:34');84checkNotOverflow('2010-01-27T12:34', '1000-01-01T00:00'); // Too small max value.85// Overflow cases86checkOverflow('2010-01-27T12:34', '2010-01-26T12:33:59.999');87checkOverflow('9999-01-01T23:59', '2010-12-31T00:00');88input.min = '2010-01-28T12:00';  // value < min && value > max89checkOverflow('2010-01-27T12:34', '2010-01-26T12:34');90// ----------------------------------------------------------------91debug('');92debug('Type=month');93input.type = 'month';94input.min = '';95// No overflow cases96checkNotOverflow('2010-01', null);97checkNotOverflow('2010-01', '');98checkNotOverflow('2010-01', 'foo');99checkNotOverflow('2010-01', '2010-01');100checkNotOverflow('2010-01', '2010-02');101checkNotOverflow('2010-01', '2011-01');102checkNotOverflow('foo', '2011-01');103checkNotOverflow('2010-01', '1000-01'); // Too small max value.104// Overflow cases105checkOverflow('2010-01', '2009-12');106checkOverflow('9999-01', '2010-12');107input.min = '2010-02';  // value < min && value > max108checkOverflow('2010-01', '2009-12');109// ----------------------------------------------------------------110debug('');111debug('Type=number');112input.type = 'number';113input.min = '';114checkNotOverflow('99', '100');  // Very normal case.115checkNotOverflow('-101', '-100');116checkNotOverflow('99', '1E+2');117checkNotOverflow('0.99', '1.00');118checkNotOverflow('abc', '100');  // Invalid value.119checkNotOverflow('', '-1');  // No value.120checkNotOverflow('101', '');  // No max.121checkNotOverflow('101', 'xxx');  // Invalid max.122// The following case should be rangeOverflow==true ideally.  But the "double" type doesn't have enough precision.123checkNotOverflow('0.999999999999999999999999999999999999999999', '0.999999999999999999999999999999999999999998');124// Overflow cases125checkOverflow('101', '100');126checkOverflow('-99', '-100');127checkOverflow('101', '1E+2');128input.min = '200';  // value < min && value > max129checkOverflow('101', '100');130// ----------------------------------------------------------------131debug('');132debug('Type=time');133input.type = 'time';134input.min = '';135// No overflow cases136checkNotOverflow('13:16', null);137checkNotOverflow('13:16', '');138checkNotOverflow('13:16', 'foo');139checkNotOverflow('13:16', '13:16');140checkNotOverflow('13:16', '13:17');141checkNotOverflow('13:16', '14:15');142checkNotOverflow('foo', '13:16');143// Overflow cases144checkOverflow('13:16', '13:15');145checkOverflow('23:59:59.999', '13:16');146input.min = '14:00';  // value < min && value > max147checkOverflow('13:16', '12:00');148// ----------------------------------------------------------------149debug('');150debug('Type=week');151input.type = 'week';152input.min = '';153// No overflow cases154checkNotOverflow('2010-W01', null);155checkNotOverflow('2010-W01', '');156checkNotOverflow('2010-W01', 'foo');157checkNotOverflow('2010-W01', '2010-W01');158checkNotOverflow('2010-W01', '2010-W02');159checkNotOverflow('2010-W01', '2011-W01');160checkNotOverflow('foo', '2011-W01');161checkNotOverflow('2010-W01', '1582-W01'); // Too small max value.162// Overflow cases163checkOverflow('2010-W01', '2009-W12');164checkOverflow('9999-W01', '2010-W12');165input.min = '2010-W02';  // value < min && value > max166checkOverflow('2010-W01', '2009-W50');...

Full Screen

Full Screen

day11.js

Source:day11.js Github

copy

Full Screen

1let input = `L.LL.LL.LL2LLLLLLL.LL3L.L.L..L..4LLLL.LL.LL5L.LL.LL.LL6L.LLLLL.LL7..L.L.....8LLLLLLLLLL9L.LLLLLL.L10L.LLLLL.LL`;11let inputArr = input.split('\n');12function part1() {13  performSeatSwaps(false);14  return finalOccupied(inputArr);15}16function performSeatSwaps(isPart2) {17  let minToBecomeEmpty = isPart2 ? 5 : 4;18  let didMakeChanges = true;19  while (didMakeChanges) {20    let cleanArr = inputArr.slice();21    didMakeChanges = false;22    for (let row = 0; row < inputArr.length; row++) {23      for (let column = 0; column < inputArr[0].length; column++) {24        let char = cleanArr[row][column];25        if (char == '.') {26          // do nothing27          continue;28        } else if (char == 'L') {29          // check all 8 adjacent30          let occupied = getOccupiedCount(cleanArr, row, column, isPart2);31          if (occupied == 0) {32            str = inputArr[row];33            strArr = str.split('')34            strArr[column] = '#'35            inputArr[row] = strArr.join('');36            didMakeChanges = true;37          }38        } else if (char == '#') {39          // check four or more adjacent40          let occupied = getOccupiedCount(cleanArr, row, column, isPart2);41          if (occupied >= minToBecomeEmpty) {42            str = inputArr[row];43            strArr = str.split('')44            strArr[column] = 'L'45            inputArr[row] = strArr.join('');46            didMakeChanges = true;47          }48        }49      }50    }51  }52}53function finalOccupied(inputArr) {54  let count = 0;55  for (let row = 0; row < inputArr.length; row++) {56    for (let column = 0; column < inputArr[0].length; column++) {57      let char = inputArr[row][column];58      if (char == '#') {59        count++;60      }61    }62  }63  return count;64}65function part2() {66  performSeatSwaps(true);67  return finalOccupied(inputArr);68}69function getOccupiedCount(arr, row, col, shouldExtend) {70  let count = 0;71  let rowToCheck = row - 1;72  let colToCheck = col - 1;73  while (shouldExtend && rowToCheck >= 0 && colToCheck >= 0 && arr[rowToCheck][colToCheck] == '.') {74    rowToCheck -= 1;75    colToCheck -= 1;76  }77  if (rowToCheck >= 0 && colToCheck >= 0 && arr[rowToCheck][colToCheck] == '#') {78    count++;79  }80  rowToCheck = row - 1;81  colToCheck = col;82  while (shouldExtend && rowToCheck >= 0 && arr[rowToCheck][colToCheck] == '.') {83    rowToCheck -= 1;84  }85  if (rowToCheck >= 0 && arr[rowToCheck][colToCheck] == '#') {86    count++;87  }88  rowToCheck = row - 1;89  colToCheck = col + 1;90  while (shouldExtend && rowToCheck >= 0 && colToCheck < arr[0].length && arr[rowToCheck][colToCheck] == '.') {91    rowToCheck -= 1;92    colToCheck += 1;93  }94  if (rowToCheck >= 0 && colToCheck < arr[0].length && arr[rowToCheck][colToCheck] == '#') {95    count++;96  }97  rowToCheck = row;98  colToCheck = col - 1;99  while (shouldExtend && colToCheck >= 0 && arr[rowToCheck][colToCheck] == '.') {100    colToCheck -= 1;101  }102  if (colToCheck >= 0 && arr[rowToCheck][colToCheck] == '#') {103    count++;104  }105  rowToCheck = row;106  colToCheck = col + 1;107  while (shouldExtend && colToCheck < arr[0].length && arr[rowToCheck][colToCheck] == '.') {108    colToCheck += 1;109  }110  if (colToCheck < arr[0].length && arr[rowToCheck][colToCheck] == '#') {111    count++;112  }113  rowToCheck = row + 1;114  colToCheck = col - 1;115  while (shouldExtend && rowToCheck < arr.length && colToCheck >= 0 && arr[rowToCheck][colToCheck] == '.') {116    rowToCheck += 1;117    colToCheck -= 1;118  }119  if (rowToCheck < arr.length && colToCheck >= 0 && arr[rowToCheck][colToCheck] == '#') {120    count++;121  }122  rowToCheck = row + 1;123  colToCheck = col;124  while (shouldExtend && rowToCheck < arr.length && arr[rowToCheck][colToCheck] == '.') {125    rowToCheck += 1;126  }127  if (rowToCheck < arr.length && arr[rowToCheck][colToCheck] == '#') {128    count++;129  }130  rowToCheck = row + 1;131  colToCheck = col + 1;132  while (shouldExtend && rowToCheck < arr.length && colToCheck < arr[0].length && arr[rowToCheck][colToCheck] == '.') {133    rowToCheck += 1;134    colToCheck += 1;135  }136  if (rowToCheck < arr.length && colToCheck < arr[0].length && arr[rowToCheck][colToCheck] == '#') {137    count++;138  }139  return count;...

Full Screen

Full Screen

input-type-change3.js

Source:input-type-change3.js Github

copy

Full Screen

2var input = document.createElement('input');3document.body.appendChild(input);4// The default type is "text".5shouldBe('input.type', '"text"');6function check(value, expected)7{8    input.type = value;9    if (input.type == expected)10        testPassed('input.type for "' + value + '" is correctly "' + input.type + '".');11    else12        testFailed('input.type for "' + value + '" is incorrectly "' + input.type + '", should be "' + expected + '".');13}14// The type is not specified explicitly.  We can change it to "file".15check("file", "file");16check("text", "text");17check("TEXT", "text");  // input.type must return a lower case value according to DOM Level 2.18check(" text ", "text");19check("button", "button");20check(" button ", "text");21check("checkbox", "checkbox");22check("color", "color");23check("date", "date");24check("datetime", "datetime");25check("datetime-local", "datetime-local");26check("datetimelocal", "text");27check("datetime_local", "text");28check("email", "email");29check("file", "email"); // We can't change a concrete type to file for a security reason.30check("hidden", "hidden");31check("image", "image");32check("isindex", "text");33check("khtml_isindex", "");34check("month", "month");35check("number", "number");36check("password", "password");37check("passwd", "text");38check("radio", "radio");39check("range", "range");40check("reset", "reset");41check("search", "search");42check("submit", "submit");43check("tel", "tel");44check("telephone", "text");45check("time", "time");46check("url", "url");47check("uri", "text");48check("week", "week");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2  it('Does not do much!', function() {3    expect(true).to.equal(true)4  })5})6describe('My First Test', function() {7  it('Does not do much!', function() {8    expect(true).to.equal(true)9  })10})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', () => {2  it('Test', () => {3    cy.contains('type').click();4    cy.url().should('include', '/commands/actions');5    cy.get('.action-email')6      .type('email')7      .should('have.value', 'email');8  });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("My First Test", () => {2  it("Does not do much!", () => {3    expect(true).to.equal(true);4  });5});6describe("My First Test", () => {7  it("Does not do much!", () => {8    expect(true).to.equal(true);9  });10});11describe("My First Test", () => {12  it("Does not do much!", () => {13    expect(true).to.equal(true);14  });15});16describe("My First Test", () => {17  it("Does not do much!", () => {18    expect(true).to.equal(true);19  });20});21describe("My First Test", () => {22  it("Does not do much!", () => {23    expect(true).to.equal(true);24  });25});26describe("My First Test", () => {27  it("Does not do much!", () => {28    expect(true).to.equal(true);29  });30});31describe("My First Test", () => {32  it("Does not do much!", () => {33    expect(true).to.equal(true);34  });35});36describe("My First Test", () => {37  it("Does not do much!", () => {38    expect(true).to.equal(true);39  });40});41describe("My First Test", () => {42  it("Does not do much!", () => {43    expect(true).to.equal(true);44  });45});46describe("My First Test", () => {47  it("Does not do much!", () => {48    expect(true).to.equal(true);49  });50});51describe("My First Test", () => {52  it("Does not do much!", () => {53    expect(true).to.equal

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('input[name="username"]').check({force: true})2cy.get('input[name="username"]').uncheck({force: true})3cy.get('input[name="username"]').select({force: true})4cy.get('input[name="username"]').check()5cy.get('input[name="username"]').uncheck()6cy.get('input[name="username"]').select()7cy.get('input[name="username"]').check({force: true})8cy.get('input[name="username"]').uncheck({force: true})9cy.get('input[name="username"]').select({force: true})10cy.get('input[name="username"]').check()11cy.get('input[name="username"]').uncheck()12cy.get('input[name="username"]').select()13cy.get('input[name="username"]').check({force: true})14cy.get('input[name="username"]').uncheck({force: true})15cy.get('input[name="username"]').select({force: true})16cy.get('input[name="username"]').check()17cy.get('input[name="username"]').uncheck()18cy.get('input[name="username"]').select()19cy.get('input[name="username"]').check({force: true})20cy.get('input[name="username"]').uncheck({force: true})21cy.get('input[name="username"]').select({force: true})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2  it('Does not do much!', () => {3    expect(true).to.equal(true)4  })5})6it('Check box', () => {7  cy.get('.action-checkboxes [type="checkbox"]').check(['checkbox1', 'checkbox2'])8})9it('Uncheck box', () => {10  cy.get('.action-checkboxes [type="checkbox"]').uncheck(['checkbox1', 'checkbox2'])11})12it('check box', () => {13  cy.get('.action-radios [type="radio"]')14    .check('radio1')15    .should('be.checked')16})17it('check box', () => {18  cy.get('.action-radios [type="radio"]')19    .check('radio1')20    .should('be.checked')21})22it('check box', () => {23  cy.get('.action-radios [type="radio"]')24    .check('radio1')25    .should('be.checked')26})27it('check box', () => {28  cy.get('.action-radios [type="radio"]')29    .check('radio1')30    .should('be.checked')31})32it('check box', () => {33  cy.get('.action-radios [type="radio"]')34    .check('radio1')35    .should('be.checked')36})37it('check box', () => {38  cy.get('.action-radios [type="radio"]')39    .check('radio1')40    .should('be.checked')

Full Screen

Using AI Code Generation

copy

Full Screen

1it('Check the element', () => {2  cy.get('input[name="q"]').check()3})4it('Uncheck the element', () => {5  cy.get('input[name="q"]').uncheck()6})7it('Click the element', () => {8  cy.get('input[name="q"]').click()9})10it('Double click the element', () => {11  cy.get('input[name="q"]').dblclick()12})13it('Right click the element', () => {14  cy.get('input[name="q"]').rightclick()15})16it('Focus the element', () => {17  cy.get('input[name="q"]').focus()18})19it('Blur the element', () => {20  cy.get('input[name="q"]').blur()21})22it('Clear the element', () => {23  cy.get('input[name="q"]').clear()24})25it('Submit the element', () => {26  cy.get('input[name="q"]').submit()27})28it('Type the element', () => {29  cy.get('input[name="q"]').type('Cypress')30})31it('Clear the element', () => {32  cy.get('input[name="q

Full Screen

Using AI Code Generation

copy

Full Screen

1it('test1', () => {2  cy.get('input[type="text"]').type('cypress')3  cy.get('input[type="submit"]').click()4})5it('test2', () => {6  cy.get('input[type="text"]').type('cypress')7  cy.get('input[type="submit"]').click()8})9it('test3', () => {10  cy.get('input[type="text"]').type('cypress')11  cy.get('input[type="submit"]').click()12})13it('test4', () => {14  cy.get('input[type="text"]').type('cypress')15  cy.get('input[type="submit"]').click()16})17it('test5', () => {18  cy.get('input[type="text"]').type('cypress')19  cy.get('input[type="submit"]').click()20})21it('test6', () => {22  cy.get('input[type="text"]').type('cypress')23  cy.get('input[type="submit"]').click()24})25it('test7', () => {26  cy.get('input[type="text"]').type('cypress')27  cy.get('input[type="submit"]').click()28})

Full Screen

Using AI Code Generation

copy

Full Screen

1it("test", () => {2  cy.get("button").click();3  cy.get("div").contains("Hello World").should("be.visible");4});5it("test", () => {6  cy.get("button").click();7  cy.get("div").contains("Hello World").should("be.visible");8});

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

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