How to use setup method in Molotov

Best Python code snippet using molotov_python

test_pubsub_3_1.js

Source:test_pubsub_3_1.js Github

copy

Full Screen

1/*******************************************************************************2 * test_pubsub_3_1.js:3 * Component of the DOH-based test suite for the OpenAjax Hub.4 *5 * JavaScript logic for the unit test for routines having to do with managing event6 * publishing and event subscribing. (The "event hub" or "topic bus".)7 * [ This is a port of the Hub 1.0 testcases found in _TestPubSub.js. ]8 *9 * Copyright 2008 OpenAjax Alliance10 *11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 12 * use this file except in compliance with the License. You may obtain a copy 13 * of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless 14 * required by applicable law or agreed to in writing, software distributed 15 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 16 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations under the License.18 *19 ******************************************************************************/20/***********************************************************************21 * js3_122 **********************************************************************/23var js3_1 = {};24js3_1_0 = {};25js3_1_1 = {};26js3_1_2 = {};27js3_1_3 = {};28js3_1_4 = {};29js3_1_5 = {};30js3_1_6 = {};31js3_1_7 = {};32js3_1_8 = {};33//////////////////////////////////////////////////////34js3_1_0.run = function(scriptnum) {35 js3_1_0.scriptnum = scriptnum;36 js3_1_0.subscribe = {};37 js3_1_0.setup = {};38 js3_1_0.fire = {};39 js3_1_0.check = {};40 // In callback for topic X, publish on topic X 41 this.hubClient.subscribe("pub.same", js3_1.cbPubSame, this, function( subscriptionID, success, errCode ) {42 js3_1_0.do_setup.call(this, "_trigger");43 }, "_trigger");44}45js3_1.cbPubSame = function(subject, message, subscriberData) {46 if(message.step == "setup") {47 js3_1_0.do_fire.call(this, subscriberData);48 } else if(message.step == "fire") { 49 js3_1_0.do_check.call(this, subscriberData);50 } else if(message.step == "check") {51 js3_1_0.do_finish.call(this, subscriberData);52 } else {53 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] );54 }55 return;56}57js3_1_0.do_setup = function(subscriberName) {58 js3_1_0.subscribe[subscriberName] = true;59 if (js3_1_0.subscribe["_trigger"] === true) {60 this.hubClient.publish("pub.same", { step: "setup" }); 61 }62}63js3_1_0.do_fire = function(data) {64 js3_1_0.setup[data] = true;65 if (js3_1_0.setup["_trigger"] === true) {66 this.hubClient.publish("pub.same", { step: "fire" });67 }68}69js3_1_0.do_check = function(data) {70 js3_1_0.fire[data] = true;71 if (js3_1_0.fire["_trigger"] === true) {72 this.hubClient.publish("pub.same", { step: "check" });73 }74}75js3_1_0.do_finish = function(data) {76 js3_1_0.check[data] = true;77 if (js3_1_0.check["_trigger"] === true) {78 if (js3_1_0.setup["_trigger"] === true && 79 js3_1_0.fire["_trigger"] === true && 80 js3_1_0.check["_trigger"] === true) {81 this.sendMsg( ["done"] );82 } else {83 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.0"] );84 }85 }86}87//////////////////////////////////////////////////////88js3_1_1.run = function(scriptnum) {89 js3_1_1.scriptnum = scriptnum;90 js3_1_1.subscribe = {};91 js3_1_1.setup = {};92 js3_1_1.fire = {};93 js3_1_1.check = {};94 // In callback for topic X, subscribe to topic X 95 this.hubClient.subscribe("pub.other.trigger", js3_1.cbPubOther, this, function( subscriptionID, success, errCode ) {96 js3_1_1.do_setup.call(this, "_trigger");97 }, "_trigger");98 this.hubClient.subscribe("pub.other.target", js3_1.cbPubOther, this, function( subscriptionID, success, errCode ) {99 js3_1_1.do_setup.call(this, "_target");100 }, "_target");101}102js3_1.cbPubOther = function(subject, message, subscriberData) {103 if(message.step == "setup") {104 js3_1_1.do_fire.call(this, subscriberData);105 } else if(message.step == "fire") {106 js3_1_1.do_check.call(this, subscriberData);107 } else if(message.step == "check") {108 js3_1_1.do_finish.call(this, subscriberData);109 } else {110 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] );111 }112 return;113}114js3_1_1.do_setup = function(subscriberName) {115 js3_1_1.subscribe[subscriberName] = true;116 if (js3_1_1.subscribe["_trigger"] === true && js3_1_1.subscribe["_target"] === true) {117 this.hubClient.publish("pub.other.trigger", { step: "setup" }); 118 this.hubClient.publish("pub.other.target", { step: "setup" }); 119 }120}121js3_1_1.do_fire = function(data) {122 js3_1_1.setup[data] = true;123 if (js3_1_1.setup["_trigger"] === true && js3_1_1.setup["_target"] === true) {124 this.hubClient.publish("pub.other.trigger", { step: "fire" });125 }126}127js3_1_1.do_check = function(data) {128 js3_1_1.fire[data] = true;129 if (js3_1_1.fire["_trigger"] === true) {130 this.hubClient.publish("pub.other.target", { step: "check" });131 }132}133js3_1_1.do_finish = function(data) {134 js3_1_1.check[data] = true;135 if (js3_1_1.check["_target"] === true) {136 if (js3_1_1.setup["_trigger"] === true && js3_1_1.setup["_target"] === true &&137 js3_1_1.fire["_trigger"] === true && typeof js3_1_1.fire["_target"] === "undefined" &&138 typeof js3_1_1.check["_trigger"] === "undefined" && js3_1_1.check["_target"] === true) {139 this.sendMsg( ["done"] );140 } else {141 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.1"] );142 }143 }144}145//////////////////////////////////////////////////////146js3_1_2.run = function(scriptnum) {147 js3_1_2.scriptnum = scriptnum;148 js3_1_2.subscribe = {};149 js3_1_2.setup = {};150 js3_1_2.fire = {};151 js3_1_2.check = {};152 // In callback for topic X, subscribe to topic X 153 this.hubClient.subscribe("sub.same", js3_1.cbSubSame, this, function( subscriptionID, success, errCode ) {154 js3_1_2.do_setup.call(this, "_trigger");155 }, "_trigger");156}157js3_1.cbSubSame = function(subject, message, subscriberData) {158 if(message.step == "setup") {159 js3_1_2.do_fire.call(this, subscriberData);160 } else if(message.step == "fire") {161 this.hubClient.subscribe(subject, js3_1.cbSubSame, this, function( subscriptionID, success, errCode ) {162 js3_1_2.do_check.call(this, subscriberData);163 }, "_target");164 } else if(message.step == "check") {165 js3_1_2.do_finish.call(this, subscriberData);166 } else {167 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 168 }169 return;170}171js3_1_2.do_setup = function(subscriberName) {172 js3_1_2.subscribe[subscriberName] = true;173 if (js3_1_2.subscribe["_trigger"] === true) {174 this.hubClient.publish("sub.same", { step: "setup" }); 175 }176}177js3_1_2.do_fire = function(data) {178 js3_1_2.setup[data] = true;179 if (js3_1_2.setup["_trigger"] === true) {180 this.hubClient.publish("sub.same", { step: "fire" });181 }182}183js3_1_2.do_check = function(data) {184 js3_1_2.fire[data] = true;185 if (js3_1_2.fire["_trigger"] === true) {186 this.hubClient.publish("sub.same", { step: "check" });187 }188}189js3_1_2.do_finish = function(data) {190 js3_1_2.check[data] = true;191 if (js3_1_2.check["_trigger"] === true && js3_1_2.check["_target"] === true) {192 if (js3_1_2.setup["_trigger"] === true && typeof js3_1_2.setup["_target"] === "undefined" &&193 js3_1_2.fire["_trigger"] === true && typeof js3_1_2.fire["_target"] === "undefined" &&194 js3_1_2.check["_trigger"] === true && js3_1_2.check["_target"] === true) {195 this.sendMsg( ["done"] );196 } else {197 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.2"] );198 }199 }200}201//////////////////////////////////////////////////////202js3_1_3.run = function(scriptnum) {203 js3_1_3.scriptnum = scriptnum;204 js3_1_3.subscribe = {};205 js3_1_3.setup = {};206 js3_1_3.fire = {};207 js3_1_3.check = {};208 // In callback for topic X, subscribe to topic Y 209 this.hubClient.subscribe("sub.other.trigger", js3_1.cbSubOther, this, function( subscriptionID, success, errCode ) {210 js3_1_3.do_setup.call(this, "_trigger");211 }, "_trigger");212}213js3_1.cbSubOther = function(subject, message, subscriberData) {214 if(message.step == "setup") { 215 js3_1_3.do_fire.call(this, subscriberData);216 } else if(message.step == "fire") {217 this.hubClient.subscribe("sub.other.target", js3_1.cbSubOther, this, function( subscriptionID, success, errCode ) {218 js3_1_3.do_check.call(this, subscriberData);219 }, "_target");220 } else if(message.step == "check") {221 js3_1_3.do_finish.call(this, subscriberData);222 } else {223 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 224 }225 return;226}227js3_1_3.do_setup = function(subscriberName) {228 js3_1_3.subscribe[subscriberName] = true;229 if (js3_1_3.subscribe["_trigger"] === true) {230 this.hubClient.publish("sub.other.trigger", { step: "setup" }); 231 this.hubClient.publish("sub.other.target", { step: "setup" }); 232 }233}234js3_1_3.do_fire = function(data) {235 js3_1_3.setup[data] = true;236 if (js3_1_3.setup["_trigger"] === true) {237 this.hubClient.publish("sub.other.trigger", { step: "fire" });238 }239}240js3_1_3.do_check = function(data) {241 js3_1_3.fire[data] = true;242 if (js3_1_3.fire["_trigger"] === true) {243 this.hubClient.publish("sub.other.trigger", { step: "check" });244 this.hubClient.publish("sub.other.target", { step: "check" });245 }246}247js3_1_3.do_finish = function(data) {248 js3_1_3.check[data] = true;249 if (js3_1_3.check["_trigger"] === true && js3_1_3.check["_target"] === true) {250 if (js3_1_3.setup["_trigger"] === true && typeof js3_1_3.setup["_target"] === "undefined" &&251 js3_1_3.fire["_trigger"] === true && typeof js3_1_3.fire["_target"] === "undefined" &&252 js3_1_3.check["_trigger"] === true && js3_1_3.check["_target"] === true) {253 this.sendMsg( ["done"] );254 } else {255 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.3"] );256 }257 }258}259//////////////////////////////////////////////////////260js3_1_4.run = function(scriptnum) {261 js3_1_4.scriptnum = scriptnum;262 js3_1_4.subscribe = {};263 js3_1_4.setup = {};264 js3_1_4.fire = {};265 js3_1_4.check = {};266 // In callback for topic X, cancel another subscription to the same topic X267 this.hubClient.subscribe("unsub.same", js3_1.cbUnsubSame, this, function( subscriptionID, success, errCode ) {268 js3_1_4.do_setup.call(this, "_trigger");269 }, "_trigger");270 this.hubClient.subscribe("unsub.same", js3_1.cbUnsubSame, this, function( subscriptionID, success, errCode ) {271 this.subUnsubSameSubjectTarget = subscriptionID;272 js3_1_4.do_setup.call(this, "_target");273 }, "_target");274}275js3_1.cbUnsubSame = function(subject, message, subscriberData) {276 if(message.step == "setup") { 277 js3_1_4.do_fire.call(this, subscriberData);278 } else if(message.step == "fire") {279 if(subscriberData == "_trigger") {280 this.hubClient.unsubscribe(this.subUnsubSameSubjectTarget, function( subscriptionID, success, errCode ) {281 js3_1_4.do_check.call(this, subscriberData); 282 }, this);283 }284 } else if(message.step == "check") { 285 js3_1_4.do_finish.call(this, subscriberData);286 } else {287 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 288 }289 return;290}291js3_1_4.do_setup = function(subscriberName) {292 js3_1_4.subscribe[subscriberName] = true;293 if (js3_1_4.subscribe["_trigger"] === true && js3_1_4.subscribe["_target"] === true) {294 this.hubClient.publish("unsub.same", { step: "setup" }); 295 }296}297js3_1_4.do_fire = function(data) {298 js3_1_4.setup[data] = true;299 if (js3_1_4.setup["_trigger"] === true && js3_1_4.setup["_target"] === true) {300 this.hubClient.publish("unsub.same", { step: "fire" });301 }302}303js3_1_4.do_check = function(data) {304 js3_1_4.fire[data] = true;305 if (js3_1_4.fire["_trigger"] === true) {306 this.hubClient.publish("unsub.same", { step: "check" });307 }308}309js3_1_4.do_finish = function(data) {310 js3_1_4.check[data] = true;311 if (js3_1_4.check["_trigger"] === true) {312 if (js3_1_4.setup["_trigger"] === true && js3_1_4.setup["_target"] === true &&313 js3_1_4.fire["_trigger"] === true && typeof js3_1_4.fire["_target"] === "undefined" &&314 js3_1_4.check["_trigger"] === true && typeof js3_1_4.check["_target"] === "undefined") {315 this.sendMsg( ["done"] );316 } else {317 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.4"] );318 }319 }320}321//////////////////////////////////////////////////////322js3_1_5.run = function(scriptnum) {323 js3_1_5.scriptnum = scriptnum;324 js3_1_5.subscribe = {};325 js3_1_5.setup = {};326 js3_1_5.fire = {};327 js3_1_5.check = {};328 // In callback for topic X, cancel a subscription to a different topic Y329 this.hubClient.subscribe("unsub.other.trigger", js3_1.cbUnsubOther, this, function( subscriptionID, success, errCode ) {330 js3_1_5.do_setup.call(this, "unsub.other.trigger");331 }, "_trigger");332 this.hubClient.subscribe("unsub.other.target", js3_1.cbUnsubOther, this, function( subscriptionID, success, errCode ) {333 this.subUnsubOtherTarget = subscriptionID;334 js3_1_5.do_setup.call(this, "unsub.other.target");335 }, "_target");336}337js3_1.cbUnsubOther = function(subject, message, subscriberData) {338 if(message.step == "setup") {339 js3_1_5.do_fire.call(this, subject);340 } else if(message.step == "fire") {341 this.hubClient.unsubscribe(this.subUnsubOtherTarget, function( subscriptionID, success, errCode ) {342 js3_1_5.do_check.call(this, subject); 343 }, this);344 } else if(message.step == "check") {345 js3_1_5.do_finish.call(this, subject);346 } else {347 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 348 }349 return;350}351js3_1_5.do_setup = function(subscriberName) {352 js3_1_5.subscribe[subscriberName] = true;353 if (js3_1_5.subscribe["unsub.other.trigger"] === true && js3_1_5.subscribe["unsub.other.target"] === true) {354 this.hubClient.publish("unsub.other.trigger", { step: "setup" }); 355 this.hubClient.publish("unsub.other.target", { step: "setup" });356 }357}358js3_1_5.do_fire = function(data) {359 js3_1_5.setup[data] = true;360 if (js3_1_5.setup["unsub.other.trigger"] === true && js3_1_5.setup["unsub.other.target"] === true) {361 this.hubClient.publish("unsub.other.trigger", { step: "fire" });362 }363}364js3_1_5.do_check = function(data) {365 js3_1_5.fire[data] = true;366 if (js3_1_5.fire["unsub.other.trigger"] === true) {367 this.hubClient.publish("unsub.other.trigger", { step: "check" });368 this.hubClient.publish("unsub.other.target", { step: "check" });369 }370}371js3_1_5.do_finish = function(data) {372 js3_1_5.check[data] = true;373 if (js3_1_5.check["unsub.other.trigger"] === true) {374 if (js3_1_5.setup["unsub.other.trigger"] === true && js3_1_5.setup["unsub.other.target"] === true &&375 js3_1_5.fire["unsub.other.trigger"] === true && typeof js3_1_5.fire["unsub.other.target"] === "undefined" &&376 js3_1_5.check["unsub.other.trigger"] === true && typeof js3_1_5.check["unsub.other.target"] === "undefined") {377 this.sendMsg( ["done"] );378 } else {379 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.5"] );380 }381 }382}383//////////////////////////////////////////////////////384js3_1_6.run = function(scriptnum) {385 this.scriptnum = scriptnum;386 js3_1_6.subscribe = {};387 js3_1_6.setup = {};388 js3_1_6.fire = {};389 js3_1_6.check = {};390 // In callback for topic X, cancel this same subscription 391 this.hubClient.subscribe("unsub.this", js3_1.cbUnsubThis, this, function( subscriptionID, success, errCode ) {392 this.subUnsubThis = subscriptionID;393 js3_1_6.do_setup.call(this, "unsub.this");394 }, "");395}396js3_1.cbUnsubThis = function(subject, message, subscriberData) {397 if(message.step == "setup") {398 js3_1_6.do_fire.call(this, subject);399 } else if(message.step == "fire") {400 this.hubClient.unsubscribe(this.subUnsubThis, function( subscriptionID, success, errCode ) {401 js3_1_6.do_check.call(this, subject); 402 }, this);403 } else if(message.step == "check") {404 this.sendMsg( ["error", "ERROR " + message.step + " should not happen, " ] ); 405 } else {406 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 407 }408 return;409}410js3_1_6.do_setup = function(subscriberName) {411 js3_1_6.subscribe[subscriberName] = true;412 if (js3_1_6.subscribe["unsub.this"] === true) {413 this.hubClient.publish("unsub.this", { step: "setup" }); 414 }415}416js3_1_6.do_fire = function(data) {417 js3_1_6.setup[data] = true;418 if (js3_1_6.setup["unsub.this"] === true) {419 this.hubClient.publish("unsub.this", { step: "fire" });420 }421}422js3_1_6.do_check = function(data) {423 js3_1_6.fire[data] = true;424 if (js3_1_6.fire["unsub.this"] === true) {425 this.hubClient.publish("unsub.this", { step: "check" });426 js3_1_6.do_finish.call(this, null);427 }428}429js3_1_6.do_finish = function(data) {430 if (js3_1_6.setup["unsub.this"] === true && 431 js3_1_6.fire["unsub.this"] === true && 432 typeof js3_1_6.check["unsub.this"] === "undefined") {433 this.sendMsg( ["done"] );434 } else {435 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.6"] );436 }437}438//////////////////////////////////////////////////////439js3_1_7.run = function(scriptnum) {440 this.scriptnum = scriptnum;441 js3_1_7.subscribe = {};442 js3_1_7.setup = {};443 js3_1_7.fire = {};444 js3_1_7.check = {};445 // In callback for topic X, subscribe to X and publish to X446 this.hubClient.subscribe("sub.pub.same", js3_1.cbSubPubSame, this, function( subscriptionID, success, errCode ) {447 js3_1_7.do_setup.call(this, "_trigger");448 }, "_trigger");449}450js3_1.cbSubPubSame = function(subject, message, subscriberData) {451 if(message.step == "setup") 452 js3_1_7.do_fire.call(this, subscriberData);453 else if(message.step == "fire") {454 this.hubClient.subscribe(subject, js3_1.cbSubPubSame, this, function( subscriptionID, success, errCode ) {455 js3_1_7.do_check.call(this, subscriberData); 456 }, "_target");457 } else if(message.step == "check1") {458 /* message received. should be received ONCE FOR _trigger & ONCE FOR _target. */ 459 js3_1_7.do_finish.call(this, message.step+subscriberData); 460 } else if(message.step == "check2") {461 /* message received. should be received ONCE FOR _trigger & ONCE FOR _target. */462 js3_1_7.do_finish.call(this, message.step+subscriberData); 463 } else464 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 465 return;466}467js3_1_7.do_setup = function(subscriberData) {468 js3_1_7.subscribe[subscriberData] = true;469 if (js3_1_7.subscribe["_trigger"] === true) {470 this.hubClient.publish("sub.pub.same", { step: "setup" }); 471 }472}473js3_1_7.do_fire = function(data) {474 js3_1_7.setup[data] = true;475 if (js3_1_7.setup["_trigger"] === true) {476 this.hubClient.publish("sub.pub.same", { step: "fire" });477 }478}479js3_1_7.do_check = function(data) {480 js3_1_7.fire[data] = true;481 if (js3_1_7.fire["_trigger"] === true) {482 this.hubClient.publish("sub.pub.same", { step: "check1" });483 this.hubClient.publish("sub.pub.same", { step: "check2" });484 }485}486js3_1_7.do_finish = function(data) {487 js3_1_7.check[data] = true;488 if (js3_1_7.check["check1_trigger"] === true && js3_1_7.check["check1_target"] === true && 489 js3_1_7.check["check2_trigger"] === true && js3_1_7.check["check2_target"] === true) {490 if (js3_1_7.setup["_trigger"] === true && typeof js3_1_7.setup["_target"] === "undefined" &&491 js3_1_7.fire["_trigger"] === true && typeof js3_1_7.fire["_target"] === "undefined" &&492 js3_1_7.check["check1_trigger"] === true && js3_1_7.check["check1_target"] === true && 493 js3_1_7.check["check2_trigger"] === true && js3_1_7.check["check2_target"] === true) {494 this.sendMsg( ["done"] );495 } else {496 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.7"] );497 }498 }499}500//////////////////////////////////////////////////////501js3_1_8.run = function(scriptnum) {502 js3_1_8.scriptnum = scriptnum;503 js3_1_8.subscribe = {};504 js3_1_8.setup = {};505 js3_1_8.fire = {};506 js3_1_8.check = {};507 this.hubClient.subscribe("sub.pub.other.trigger", js3_1.cbSubPubOther, this, function( subscriptionID, success, errCode ) {508 js3_1_8.do_setup.call(this, "sub.pub.other.trigger");509 }, "_trigger");510}511js3_1.cbSubPubOther = function(subject, message, subscriberData) {512 var pubSubject = "sub.pub.other.target";513 if(message.step == "setup") 514 js3_1_8.do_fire.call(this, subject);515 else if(message.step == "fire") {516 this.hubClient.subscribe(pubSubject, js3_1.cbSubPubOther, this, function( subscriptionID, success, errCode ) {517 js3_1_8.do_check.call(this, subject);518 }, "_target");519 } else if(message.step == "check1") {520 /* message received. should be received ONCE FOR _target ONLY. */ 521 js3_1_8.do_finish.call(this, message.step+subscriberData); 522 } else if(message.step == "check2") {523 /* message received. should be received ONCE FOR _target ONLY. */524 js3_1_8.do_finish.call(this, message.step+subscriberData); 525 } else526 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 527 return;528}529js3_1_8.do_setup = function(subscriberName) {530 js3_1_8.subscribe[subscriberName] = true;531 if (js3_1_8.subscribe["sub.pub.other.trigger"] === true) {532 this.hubClient.publish("sub.pub.other.trigger", { step: "setup" }); 533 this.hubClient.publish("sub.pub.other.target", { step: "setup" }); 534 }535}536js3_1_8.do_fire = function(data) {537 js3_1_8.setup[data] = true;538 if (js3_1_8.setup["sub.pub.other.trigger"] === true) {539 this.hubClient.publish("sub.pub.other.trigger", { step: "fire" });540 }541}542js3_1_8.do_check = function(subject) {543 js3_1_8.fire[subject] = true;544 if (js3_1_8.fire["sub.pub.other.trigger"] === true) {545 this.hubClient.publish("sub.pub.other.target", { step: "check1" });546 this.hubClient.publish("sub.pub.other.trigger", { step: "check2" });547 this.hubClient.publish("sub.pub.other.target", { step: "check2" });548 }549}550js3_1_8.do_finish = function(data) {551 js3_1_8.check[data] = true;552 if (js3_1_8.check["check1_target"] === true && 553 js3_1_8.check["check2_trigger"] === true && js3_1_8.check["check2_target"] === true) {554 if (js3_1_8.setup["sub.pub.other.trigger"] === true && typeof js3_1_8.setup["sub.pub.other.target"] === "undefined" &&555 js3_1_8.fire["sub.pub.other.trigger"] === true && typeof js3_1_8.fire["sub.pub.other.target"] === "undefined" &&556 typeof js3_1_8.check["check1_trigger"] === "undefined" && js3_1_8.check["check1_target"] === true && 557 js3_1_8.check["check2_trigger"] === true && js3_1_8.check["check2_target"] === true) {558 this.sendMsg( ["done"] );559 } else {560 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.8"] );561 }562 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...109const benchmarkRunner = new Runner()110 .suite('bsonBench', suite =>111 suite112 .benchmark('flatBsonEncoding', benchmark =>113 benchmark.taskSize(75.31).setup(makeBSONLoader('flat_bson')).task(encodeBSON)114 )115 .benchmark('flatBsonDecoding', benchmark =>116 benchmark.taskSize(75.31).setup(makeBSONLoader('flat_bson')).task(decodeBSON)117 )118 .benchmark('deepBsonEncoding', benchmark =>119 benchmark.taskSize(19.64).setup(makeBSONLoader('deep_bson')).task(encodeBSON)120 )121 .benchmark('deepBsonDecoding', benchmark =>122 benchmark.taskSize(19.64).setup(makeBSONLoader('deep_bson')).task(decodeBSON)123 )124 .benchmark('fullBsonEncoding', benchmark =>125 benchmark.taskSize(57.34).setup(makeBSONLoader('full_bson')).task(encodeBSON)126 )127 .benchmark('fullBsonDecoding', benchmark =>128 benchmark.taskSize(57.34).setup(makeBSONLoader('full_bson')).task(decodeBSON)129 )130 )131 .suite('singleBench', suite =>132 suite133 .benchmark('runCommand', benchmark =>134 benchmark135 .taskSize(0.16)136 .setup(makeClient)137 .setup(connectClient)138 .setup(initDb)139 .task(runCommand)140 .teardown(disconnectClient)141 )142 .benchmark('findOne', benchmark =>143 benchmark144 .taskSize(16.22)145 .setup(makeLoadJSON('tweet.json'))146 .setup(makeClient)147 .setup(connectClient)148 .setup(initDb)149 .setup(dropDb)150 .setup(initCollection)151 .setup(makeLoadTweets(true))152 .task(findOneById)153 .teardown(dropDb)154 .teardown(disconnectClient)155 )156 .benchmark('smallDocInsertOne', benchmark =>157 benchmark158 .taskSize(2.75)159 .setup(makeLoadJSON('small_doc.json'))160 .setup(makeClient)161 .setup(connectClient)162 .setup(initDb)163 .setup(dropDb)164 .setup(initDb)165 .setup(initCollection)166 .setup(createCollection)167 .beforeTask(dropCollection)168 .beforeTask(createCollection)169 .beforeTask(initCollection)170 .task(makeTestInsertOne(10000))171 .teardown(dropDb)172 .teardown(disconnectClient)173 )174 .benchmark('largeDocInsertOne', benchmark =>175 benchmark176 .taskSize(27.31)177 .setup(makeLoadJSON('large_doc.json'))178 .setup(makeClient)179 .setup(connectClient)180 .setup(initDb)181 .setup(dropDb)182 .setup(initDb)183 .setup(initCollection)184 .setup(createCollection)185 .beforeTask(dropCollection)186 .beforeTask(createCollection)187 .beforeTask(initCollection)188 .task(makeTestInsertOne(10))189 .teardown(dropDb)190 .teardown(disconnectClient)191 )192 )193 .suite('multiBench', suite =>194 suite195 .benchmark('findManyAndEmptyCursor', benchmark =>196 benchmark197 .taskSize(16.22)198 .setup(makeLoadJSON('tweet.json'))199 .setup(makeClient)200 .setup(connectClient)201 .setup(initDb)202 .setup(dropDb)203 .setup(initCollection)204 .setup(makeLoadTweets(false))205 .task(findManyAndEmptyCursor)206 .teardown(dropDb)207 .teardown(disconnectClient)208 )209 .benchmark('smallDocBulkInsert', benchmark =>210 benchmark211 .taskSize(2.75)212 .setup(makeLoadJSON('small_doc.json'))213 .setup(makeLoadInsertDocs(10000))214 .setup(makeClient)215 .setup(connectClient)216 .setup(initDb)217 .setup(dropDb)218 .setup(initDb)219 .setup(initCollection)220 .setup(createCollection)221 .beforeTask(dropCollection)222 .beforeTask(createCollection)223 .beforeTask(initCollection)224 .task(docBulkInsert)225 .teardown(dropDb)226 .teardown(disconnectClient)227 )228 .benchmark('largeDocBulkInsert', benchmark =>229 benchmark230 .taskSize(27.31)231 .setup(makeLoadJSON('large_doc.json'))232 .setup(makeLoadInsertDocs(10))233 .setup(makeClient)234 .setup(connectClient)235 .setup(initDb)236 .setup(dropDb)237 .setup(initDb)238 .setup(initCollection)239 .setup(createCollection)240 .beforeTask(dropCollection)241 .beforeTask(createCollection)242 .beforeTask(initCollection)243 .task(docBulkInsert)244 .teardown(dropDb)245 .teardown(disconnectClient)246 )247 .benchmark('gridFsUpload', benchmark =>248 benchmark249 .taskSize(52.43)250 .setup(loadGridFs)251 .setup(makeClient)252 .setup(connectClient)253 .setup(initDb)254 .setup(dropDb)255 .setup(initDb)256 .setup(initCollection)257 .beforeTask(dropBucket)258 .beforeTask(initBucket)259 .beforeTask(gridFsInitUploadStream)260 .beforeTask(writeSingleByteToUploadStream)261 .task(function (done) {262 this.stream.on('error', done).end(this.bin, null, () => done());263 })264 .teardown(dropDb)265 .teardown(disconnectClient)266 )267 .benchmark('gridFsDownload', benchmark =>268 benchmark269 .taskSize(52.43)270 .setup(loadGridFs)271 .setup(makeClient)272 .setup(connectClient)273 .setup(initDb)274 .setup(dropDb)275 .setup(initDb)276 .setup(initCollection)277 .setup(dropBucket)278 .setup(initBucket)279 .setup(gridFsInitUploadStream)280 .setup(function () {281 return new Promise((resolve, reject) => {282 this.stream.end(this.bin, null, err => {283 if (err) {284 return reject(err);285 }286 this.id = this.stream.id;287 this.stream = undefined;288 resolve();289 });290 });291 })292 .task(function (done) {293 this.bucket.openDownloadStream(this.id).resume().on('end', done);294 })...

Full Screen

Full Screen

testFloat32-correctness.js

Source:testFloat32-correctness.js Github

copy

Full Screen

...4 if (f === undefined) {5 f = setup;6 setup = function(){};7 }8 setup();9 for(var n = 200; n; --n) {10 f();11 }12}13// Basic arithmetic14function setupBasicArith() {15 f32[0] = -Infinity;16 f32[1] = -1;17 f32[2] = -0;18 f32[3] = 0;19 f32[4] = 1.337;20 f32[5] = 42;21 f32[6] = Infinity;22 f32[7] = NaN;...

Full Screen

Full Screen

PairDevice.js

Source:PairDevice.js Github

copy

Full Screen

1/**2 * comma SetupEonPairing Screen3 */4import React, {useState, useEffect} from 'react';5import {View, Linking, StyleSheet, Text, Button} from 'react-native';6import {useNavigation} from '@react-navigation/native';7import Permissions from 'react-native-permissions';8import QRCodeScanner from 'react-native-qrcode-scanner';9import X from '../../theme';10import BasePage from '../Util/BasePage';11// import WideButton from '../../components/Util/WideButton';12// import {Alert, Spinner} from '../../components';13import {14 pilotPair,15 fetchDevices,16 fetchDevice,17 fetchDeviceSubscription,18} from '../../actions/Devices';19import gStyles from '../../constants/styles';20export default SetupEonPairing = () => {21 const [wantsCameraPermissions, setWantsCameraPermissions] = useState(false);22 const [hasCameraPermissions, setHasCameraPermissions] = useState(false);23 const [attemptingPair, setAttemptingPair] = useState(false);24 const navigation = useNavigation();25 useEffect(() => {26 Permissions.check('camera').then((response) => {27 if (response == 'authorized') {28 setHasCameraPermissions(true);29 }30 });31 }, []);32 const pairDevice = (imei, serial, pairToken) => {33 return pilotPair(imei, serial, pairToken)34 .then((dongleId) => {35 // dispatch(fetchDevices());36 return Promise.all([37 fetchDevice(dongleId),38 fetchDeviceSubscription(dongleId),39 ]);40 })41 .then(([device, deviceSubscription]) => {42 if (deviceSubscription && deviceSubscription.trial_claimable) {43 navigation.navigate('PrimeSignup', {dongleId: device.dongle_id});44 } else {45 navigation.navigate('AppDrawer');46 }47 });48 };49 const handleConfirmPressed = () => {50 setWantsCameraPermissions(true);51 };52 const handleDismissPressed = () => {53 navigation.navigate('Home');54 };55 const handleViewSetupGuidePressed = () => {56 Linking.openURL('https://comma.ai/setup');57 };58 const handleScannedQRCode = (e) => {59 setAttemptingPair(true);60 let imei, serial, pairToken;61 let qrDataSplit = e.data.split('--');62 if (qrDataSplit.length === 2) {63 imei = qrDataSplit[0];64 serial = qrDataSplit[1];65 } else if (qrDataSplit.length >= 3) {66 imei = qrDataSplit[0];67 serial = qrDataSplit[1];68 pairToken = qrDataSplit.slice(2).join('--');69 }70 if (imei === undefined || serial === undefined) {71 setAttemptingPair(false);72 }73 pairDevice(imei, serial, pairToken).catch((err) => {74 setAttemptingPair(false);75 console.log(err);76 });77 };78 if (attemptingPair) {79 return (80 <View style={styles.setupEonPairingContainer}>81 <Text style={{color: '#fff', fontSize: 20}}>Spinner</Text>82 {/* <Spinner spinnerMessage="Pairing Device..." /> */}83 </View>84 );85 // } else if (wantsCameraPermissions || hasCameraPermissions) {86 } else {87 return (88 <BasePage title="Pair Your Device">89 <View style={styles.setupEonPairingContainer}>90 <X.Entrance style={styles.setupEonPairingCamera}>91 <QRCodeScanner92 onRead={handleScannedQRCode}93 topContent={null}94 bottomContent={null}95 cameraProps={{captureAudio: false}}96 />97 </X.Entrance>98 <View style={styles.setupEonPairingInstruction}>99 <X.Text style={styles.setupEonPairingInstructionText}>100 Place the QR code from your device during setup within the frame.101 </X.Text>102 <Button103 onPress={handleViewSetupGuidePressed}104 title="View Setup Guide"105 color="#fff"></Button>106 </View>107 </View>108 </BasePage>109 );110 // } else {111 // return (112 // <BasePage>113 // <View style={styles.setupEonPairingContainer}>114 // <X.Entrance style={{height: '100%'}}>115 // <Text style={{color:'#fff', fontSize: 20}}>Alert</Text>116 {117 /* <Alert118 title="Camera Access"119 message="We need camera access so you can finish setting up your device"120 dismissButtonAction={handleDismissPressed}121 confirmButtonAction={handleConfirmPressed}122 dismissButtonTitle="Not now"123 confirmButtonTitle="Yes!"124 /> */125 }126 // </X.Entrance>127 // </View>128 // </BasePage>129 // );130 }131};132const styles = StyleSheet.create({133 setupDevicesContainer: {134 backgroundColor: '#080808',135 height: '100%',136 width: '100%',137 },138 setupDevicesHeader: {139 alignItems: 'center',140 paddingLeft: 30,141 paddingRight: 30,142 },143 setupDevicesOptions: {144 marginTop: '10%',145 },146 setupDeviceOptionEON: {147 backgroundColor: 'rgba(255,255,255,.1)',148 borderRadius: 8,149 height: 240,150 marginBottom: '10%',151 alignItems: 'center',152 justifyContent: 'center',153 width: '100%',154 },155 setupDeviceOptionEONImage: {156 maxHeight: 120,157 marginBottom: 20,158 width: '80%',159 },160 setupDeviceOptionPanda: {161 justifyContent: 'center',162 backgroundColor: 'rgba(255,255,255,.1)',163 borderRadius: 8,164 flexDirection: 'row',165 height: 160,166 width: '100%',167 },168 setupDeviceOptionPandaImage: {169 maxWidth: 100,170 },171 setupDeviceOptionPandaText: {172 alignSelf: 'center',173 paddingLeft: '8%',174 },175 setupDeviceOptionShopText: {176 textAlign: 'center',177 },178 setupDeviceContainer: {179 width: '100%',180 },181 setupDeviceHeader: {182 alignItems: 'center',183 height: 50,184 },185 setupDeviceBody: {186 paddingLeft: '3%',187 paddingRight: '3%',188 },189 setupDeviceBodyCentered: {190 height: '90%',191 alignItems: 'center',192 justifyContent: 'center',193 paddingBottom: '20%',194 },195 setupDeviceIntroBodyItem: {196 marginTop: '10%',197 },198 setupDeviceIntroBodyItemHeader: {199 marginBottom: '3.5%',200 },201 setupEonPairingContainer: {202 height: '100%',203 width: '100%',204 },205 setupEonPairingCamera: {206 backgroundColor: 'rgba(255,255,255,.02)',207 height: '50%',208 },209 setupEonPairingInstruction: {210 alignItems: 'center',211 height: '30%',212 justifyContent: 'center',213 padding: '15%',214 paddingBottom: '5%',215 paddingTop: 0,216 fontSize: 30,217 },218 setupEonPairingInstructionHdr: {219 textAlign: 'center',220 color: '#fff',221 fontSize: 30,222 fontWeight: '700',223 },224 setupEonPairingInstructionText: {225 marginTop: '6%',226 marginBottom: '12%',227 textAlign: 'center',228 color: '#aaa',229 fontSize: gStyles.text.small,230 },231 setupEonPairingInstructionButton: {232 backgroundColor: '#fff',233 borderRadius: 30,234 height: 60,235 width: 60,236 },237 setupDeviceInstallPrepContainer: {238 height: '100%',239 width: '100%',240 },241 setupDeviceInstallPrepHeader: {},242 setupDeviceInstallPrepBody: {243 justifyContent: 'center',244 flex: 1,245 },246 setupDeviceInstallSteps: {247 borderTopColor: 'rgba(255,255,255,.2)',248 borderTopWidth: 1,249 paddingTop: 20,250 },251 setupDeviceInstallStep: {252 flexDirection: 'row',253 paddingTop: 20,254 paddingBottom: 20,255 },256 setupDeviceInstallStepNumber: {257 alignItems: 'center',258 backgroundColor: '#fff',259 borderRadius: 15,260 height: 26,261 justifyContent: 'center',262 width: 26,263 },264 setupDeviceInstallStepCopy: {265 paddingLeft: 15,266 paddingRight: 20,267 },268 setupDeviceInstallVideo: {269 backgroundColor: '#fff',270 borderColor: '#fff',271 borderRadius: 8,272 borderWidth: 10,273 marginTop: 10,274 marginBottom: 30,275 height: 200,276 width: '100%',277 alignSelf: 'center',278 },279 setupDeviceInstallVideoCover: {280 borderRadius: 8,281 height: 148,282 },283 setupDeviceInstallVideoButton: {284 alignItems: 'center',285 backgroundColor: '#fff',286 justifyContent: 'center',287 height: 40,288 paddingTop: 10,289 },...

Full Screen

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