Best JavaScript code snippet using wpt
order-super.js
Source:order-super.js
1var BUGNUMBER = 1204028;2var summary = "Destructuring should evaluate lhs reference before rhs in super property";3if (typeof assertEq === "undefined") {4 assertEq = function (a, b) {5 if (a !== b) {6 throw new Error(`expected ${b}, got ${a}\n${new Error().stack}`);7 }8 };9}10print(BUGNUMBER + ": " + summary);11let logs = [];12function log(x) {13 logs.push(x);14}15let unwrapMap = new Map();16function unwrap(maybeWrapped) {17 if (unwrapMap.has(maybeWrapped)) {18 return unwrapMap.get(maybeWrapped);19 }20 return maybeWrapped;21}22function ToString(name) {23 if (name == Symbol.iterator) {24 return "@@iterator";25 }26 return String(name);27}28function logger(obj, prefix = []) {29 let wrapped = new Proxy(obj, {30 get(that, name) {31 if (name == "return") {32 // FIXME: Bug 1147371.33 // We ignore IteratorClose for now.34 return obj[name];35 }36 let names = prefix.concat(ToString(name));37 log("rhs get " + names.join("::"));38 let v = obj[name];39 if (typeof v === "object" || typeof v === "function") {40 return logger(v, names);41 }42 return v;43 },44 apply(that, thisArg, args) {45 let names = prefix.slice();46 log("rhs call " + names.join("::"));47 let v = obj.apply(unwrap(thisArg), args);48 if (typeof v === "object" || typeof v === "function") {49 names[names.length - 1] += "()";50 return logger(v, names);51 }52 return v;53 }54 });55 unwrapMap.set(wrapped, obj);56 return wrapped;57}58class C1 {59 constructor() {60 this.clear();61 }62 clear() {63 this.values = {};64 }65}66for (let name of ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "length"]) {67 Object.defineProperty(C1.prototype, name, {68 set: function (value) {69 log("lhs set " + name);70 this.values[name] = value;71 }72 });73}74class C2 extends C1 {75 constructor() {76 super();77 let clear = () => {78 logs = [];79 this.clear();80 }; // Array.81 clear();82 [super.a] = logger(["A"]);83 logs.join(",");84 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "lhs set a"].join(",");85 this.values.a;86 "A";87 clear();88 [super[(log("lhs before name a"), "a")]] = logger(["A"]);89 logs.join(",");90 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "lhs before name a", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "lhs set a"].join(",");91 this.values.a;92 "A";93 // Array rest.94 clear();95 [...super.a] = logger(["A", "B", "C"]);96 logs.join(",");97 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "lhs set a"].join(",");98 this.values.a.join(",");99 "A,B,C";100 clear();101 [...super[(log("lhs before name a"), "a")]] = logger(["A", "B", "C"]);102 ;103 logs.join(",");104 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "lhs before name a", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "lhs set a"].join(",");105 this.values.a.join(",");106 "A,B,C";107 // Array combined.108 clear();109 [super.a, super[(log("lhs before name b"), "b")], ...super[(log("lhs before name c"), "c")]] = logger(["A", "B", "C"]);110 logs.join(",");111 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "lhs set a", "lhs before name b", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "lhs set b", "lhs before name c", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "lhs set c"].join(",");112 this.values.a;113 "A";114 this.values.b;115 "B";116 this.values.c.join(",");117 "C";118 // Object.119 clear();120 ({121 a: super.a122 } = logger({123 a: "A"124 }));125 logs.join(",");126 ["rhs get a", "lhs set a"].join(",");127 this.values.a;128 "A";129 clear();130 ({131 a: super[(log("lhs before name a"), "a")]132 } = logger({133 a: "A"134 }));135 logs.join(",");136 ["lhs before name a", "rhs get a", "lhs set a"].join(",");137 this.values.a;138 "A";139 // Object combined.140 clear();141 ({142 a: super.a,143 b: super[(log("lhs before name b"), "b")]144 } = logger({145 a: "A",146 b: "B"147 }));148 logs.join(",");149 ["rhs get a", "lhs set a", "lhs before name b", "rhs get b", "lhs set b"].join(",");150 this.values.a;151 "A";152 this.values.b;153 "B";154 // == Nested ==155 // Array -> Array156 clear();157 [[super[(log("lhs before name a"), "a")], ...super[(log("lhs before name b"), "b")]]] = logger([["A", "B"]]);158 logs.join(",");159 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs get @@iterator()::next()::value::@@iterator", "rhs call @@iterator()::next()::value::@@iterator", "rhs get @@iterator()::next()::value::@@iterator()::next", "lhs before name a", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value", "lhs set a", "lhs before name b", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "lhs set b"].join(",");160 this.values.a;161 "A";162 this.values.b.length;163 1;164 this.values.b[0];165 "B";166 // Array rest -> Array167 clear();168 [...[super[(log("lhs before name a"), "a")], ...super[(log("lhs before name b"), "b")]]] = logger(["A", "B"]);169 logs.join(",");170 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "lhs before name a", "lhs set a", "lhs before name b", "lhs set b"].join(",");171 this.values.a;172 "A";173 this.values.b.join(",");174 "B";175 // Array -> Object176 clear();177 [{178 a: super[(log("lhs before name a"), "a")]179 }] = logger([{180 a: "A"181 }]);182 logs.join(",");183 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "lhs before name a", "rhs get @@iterator()::next()::value::a", "lhs set a"].join(",");184 this.values.a;185 "A";186 // Array rest -> Object187 clear();188 [...{189 0: super[(log("lhs before name 0"), "0")],190 1: super[(log("lhs before name 1"), "1")],191 length: super[(log("lhs before name length"), "length")]192 }] = logger(["A", "B"]);193 logs.join(",");194 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "lhs before name 0", "lhs set 0", "lhs before name 1", "lhs set 1", "lhs before name length", "lhs set length"].join(",");195 this.values["0"];196 "A";197 this.values["1"];198 "B";199 this.values.length;200 2;201 // Object -> Array202 clear();203 ({204 a: [super[(log("lhs before name b"), "b")]]205 } = logger({206 a: ["B"]207 }));208 logs.join(",");209 ["rhs get a", "rhs get a::@@iterator", "rhs call a::@@iterator", "rhs get a::@@iterator()::next", "lhs before name b", "rhs call a::@@iterator()::next", "rhs get a::@@iterator()::next()::done", "rhs get a::@@iterator()::next()::value", "lhs set b"].join(",");210 this.values.b;211 "B";212 // Object -> Object213 clear();214 ({215 a: {216 b: super[(log("lhs before name b"), "b")]217 }218 } = logger({219 a: {220 b: "B"221 }222 }));223 logs.join(",");224 ["rhs get a", "lhs before name b", "rhs get a::b", "lhs set b"].join(",");225 this.values.b;226 "B";227 // All combined228 clear();229 [super[(log("lhs before name a"), "a")], [super[(log("lhs before name b"), "b")], {230 c: super[(log("lhs before name c"), "c")],231 d: {232 e: super[(log("lhs before name e"), "e")],233 f: [super[(log("lhs before name g"), "g")]]234 }235 }], {236 h: super[(log("lhs before name h"), "h")],237 i: [super[(log("lhs before name j"), "j")], {238 k: [super[(log("lhs before name l"), "l")]]239 }]240 }, ...[super[(log("lhs before name m"), "m")], [super[(log("lhs before name n"), "n")], {241 o: super[(log("lhs before name o"), "o")],242 p: {243 q: super[(log("lhs before name q"), "q")],244 r: [super[(log("lhs before name s"), "s")]]245 }246 }], ...{247 0: super[(log("lhs before name t"), "t")],248 1: [super[(log("lhs before name u"), "u")], {249 v: super[(log("lhs before name v"), "v")],250 w: {251 x: super[(log("lhs before name x"), "x")],252 y: [super[(log("lhs before name z"), "z")]]253 }254 }],255 length: super[(log("lhs before name length"), "length")]256 }]] = logger(["A", ["B", {257 c: "C",258 d: {259 e: "E",260 f: ["G"]261 }262 }], {263 h: "H",264 i: ["J", {265 k: ["L"]266 }]267 }, "M", ["N", {268 o: "O",269 p: {270 q: "Q",271 r: ["S"]272 }273 }], "T", ["U", {274 v: "V",275 w: {276 x: "X",277 y: ["Z"]278 }279 }]]);280 logs.join(",");281 ["rhs get @@iterator", "rhs call @@iterator", "rhs get @@iterator()::next", "lhs before name a", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "lhs set a", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs get @@iterator()::next()::value::@@iterator", "rhs call @@iterator()::next()::value::@@iterator", "rhs get @@iterator()::next()::value::@@iterator()::next", "lhs before name b", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value", "lhs set b", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value", "lhs before name c", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::c", "lhs set c", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::d", "lhs before name e", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::d::e", "lhs set e", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::d::f", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::d::f::@@iterator", "rhs call @@iterator()::next()::value::@@iterator()::next()::value::d::f::@@iterator", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::d::f::@@iterator()::next", "lhs before name g", "rhs call @@iterator()::next()::value::@@iterator()::next()::value::d::f::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::d::f::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::d::f::@@iterator()::next()::value", "lhs set g", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "lhs before name h", "rhs get @@iterator()::next()::value::h", "lhs set h", "rhs get @@iterator()::next()::value::i", "rhs get @@iterator()::next()::value::i::@@iterator", "rhs call @@iterator()::next()::value::i::@@iterator", "rhs get @@iterator()::next()::value::i::@@iterator()::next", "lhs before name j", "rhs call @@iterator()::next()::value::i::@@iterator()::next", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::value", "lhs set j", "rhs call @@iterator()::next()::value::i::@@iterator()::next", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::value", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::value::k", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::value::k::@@iterator", "rhs call @@iterator()::next()::value::i::@@iterator()::next()::value::k::@@iterator", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::value::k::@@iterator()::next", "lhs before name l", "rhs call @@iterator()::next()::value::i::@@iterator()::next()::value::k::@@iterator()::next", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::value::k::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::i::@@iterator()::next()::value::k::@@iterator()::next()::value", "lhs set l", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "rhs get @@iterator()::next()::value", "rhs call @@iterator()::next", "rhs get @@iterator()::next()::done", "lhs before name m", "lhs set m", "rhs get @@iterator()::next()::value::@@iterator", "rhs call @@iterator()::next()::value::@@iterator", "rhs get @@iterator()::next()::value::@@iterator()::next", "lhs before name n", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value", "lhs set n", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value", "lhs before name o", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::o", "lhs set o", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::p", "lhs before name q", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::p::q", "lhs set q", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::p::r", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::p::r::@@iterator", "rhs call @@iterator()::next()::value::@@iterator()::next()::value::p::r::@@iterator", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::p::r::@@iterator()::next", "lhs before name s", "rhs call @@iterator()::next()::value::@@iterator()::next()::value::p::r::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::p::r::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::p::r::@@iterator()::next()::value", "lhs set s", "lhs before name t", "lhs set t", "rhs get @@iterator()::next()::value::@@iterator", "rhs call @@iterator()::next()::value::@@iterator", "rhs get @@iterator()::next()::value::@@iterator()::next", "lhs before name u", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value", "lhs set u", "rhs call @@iterator()::next()::value::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value", "lhs before name v", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::v", "lhs set v", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::w", "lhs before name x", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::w::x", "lhs set x", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::w::y", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::w::y::@@iterator", "rhs call @@iterator()::next()::value::@@iterator()::next()::value::w::y::@@iterator", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::w::y::@@iterator()::next", "lhs before name z", "rhs call @@iterator()::next()::value::@@iterator()::next()::value::w::y::@@iterator()::next", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::w::y::@@iterator()::next()::done", "rhs get @@iterator()::next()::value::@@iterator()::next()::value::w::y::@@iterator()::next()::value", "lhs set z", "lhs before name length", "lhs set length"].join(",");282 this.values.a;283 "A";284 this.values.b;285 "B";286 this.values.c;287 "C";288 this.values.e;289 "E";290 this.values.g;291 "G";292 this.values.h;293 "H";294 this.values.j;295 "J";296 this.values.l;297 "L";298 this.values.m;299 "M";300 this.values.n;301 "N";302 this.values.o;303 "O";304 this.values.q;305 "Q";306 this.values.s;307 "S";308 this.values.t;309 "T";310 this.values.u;311 "U";312 this.values.v;313 "V";314 this.values.x;315 "X";316 this.values.z;317 "Z";318 this.values.length;319 2;320 }321}322new C2();323if (typeof reportCompare === "function") {324 reportCompare(true, true);...
exception-sequencing-binops.js
Source:exception-sequencing-binops.js
1if (this.layoutTestController)2 layoutTestController.dumpAsText();3if (this.document) {4 log = function(msg) {document.getElementById("log").innerHTML += msg + "<br />";};5 fail = function(msg) {log("<span style='color: red'>FAIL: </span>" + msg) };6 pass = function(msg) { passCount++; log("<span style='color: green'>PASS: </span>" + msg) };7} else {8 log = print;9 fail = function(msg) {log("FAIL: " + msg) };10 pass = function(msg) { passCount++; log("PASS: " + msg); };11}12var unaryOps = ['~', '+', '-', '++', '--'];13var binaryOps;14if (!binaryOps) 15 binaryOps = ['-', '+', '*', '/', '%', '|', '&', '^', '<', '<=', '>=', '>', '==', '!=', '<<', '>>'];16var valueOfThrower = { valueOf: function() { throw "throw from valueOf"; } }17var toStringThrower = { toString: function() { throw "throw from toString"; } }18var testCount = 0;19var passCount = 0;20function id(){}21function createTest(expr) {22 // For reasons i don't quite understand these tests aren't expected to throw23 if (expr == "valueOfThrower == rhsNonZeroNum") return id;24 if (expr == "toStringThrower == rhsNonZeroNum") return id;25 if (expr == "valueOfThrower != rhsNonZeroNum") return id;26 if (expr == "toStringThrower != rhsNonZeroNum") return id;27 if (expr == "valueOfThrower == rhsToStringThrower") return id;28 if (expr == "toStringThrower == rhsToStringThrower") return id;29 if (expr == "valueOfThrower != rhsToStringThrower") return id;30 if (expr == "toStringThrower != rhsToStringThrower") return id;31 // This creates a test case that ensures that a binary operand will execute the left hand expression first,32 // and will not execute the right hand side if the left hand side throws.33 var functionPrefix = "(function(){ executedRHS = false; var result = 'PASS'; try { result = ";34 var functionPostfix = "; fail('Did not throw exception with \"' + expr + '\"') } catch (e) { " +35 " if (result != 'PASS' && executedRHS) { fail('\"'+expr+'\" threw exception, but modified assignment target and executed RHS'); " +36 " } else if (result != 'PASS') { fail('\"'+expr+'\" threw exception, but modified assignment target'); " +37 " } else if (executedRHS) { fail('\"'+expr+'\" threw exception, but executed right hand half of expression')" +38 " } else { pass('Handled \"'+ expr +'\" correctly.') } } })";39 testCount++;40 try {41 return eval(functionPrefix + expr + functionPostfix);42 } catch(e) {43 throw new String(expr);44 }45}46function createTestWithRHSExec(expr) {47 // This tests that we evaluate the right hand side of a binary expression before we48 // do any type conversion with toString and/or valueOf which may throw.49 var functionPrefix = "(function(){ executedRHS = false; var result = 'PASS'; try { result = ";50 var functionPostfix = "; fail('Did not throw exception with \"' + expr + '\"') } catch (e) { " +51 " if (result != 'PASS') { fail('\"'+expr+'\" threw exception, but modified assignment target'); " +52 " } else if (!executedRHS) { fail('\"'+expr+'\" threw exception, and failed to execute RHS when expected')" +53 " } else { pass('Handled \"'+ expr +'\" correctly.') } } })";54 testCount++;55 try {56 return eval(functionPrefix + expr + functionPostfix);57 } catch(e) {58 throw new String(expr);59 }60}61__defineGetter__('throwingProperty', function(){ throw "throwing resolve"; });62var throwingPropStr = 'throwingProperty';63var valueOfThrowerStr = 'valueOfThrower';64var toStringThrowerStr = 'toStringThrower';65var throwingObjGetter = '({get throwingProperty(){ throw "throwing property" }}).throwingProperty';66rhsNonZeroNum = { valueOf: function(){ executedRHS = true; return 1; } };67rhsZeroNum = { valueOf: function(){ executedRHS = true; return 0; } };68rhsToStringThrower = { toString: function(){ executedRHS = true; return 'string'; }};69getterThrower = { get value() { throw "throwing in getter"; }};70var getterThrowerStr = "getterThrower.value";71rhsGetterTester = { get value() { executedRHS = true; return 'string'; }};72var rhsGetterTesterStr = "rhsGetterTester.value";73for (var i = 0; i < binaryOps.length; i++) {74 var currentOp = binaryOps[i];75 var numVal = currentOp == '||' ? '0' : '1';76 createTest(numVal + " " + currentOp + " " + valueOfThrowerStr )();77 createTest(numVal + " " + currentOp + " " + toStringThrowerStr)();78 createTest(numVal + " " + currentOp + " " + throwingPropStr )();79 createTest(numVal + " " + currentOp + " " + throwingObjGetter )();80 createTest(numVal + " " + currentOp + " " + getterThrowerStr )();81 createTest("'string' " + currentOp + " " + valueOfThrowerStr )();82 createTest("'string' " + currentOp + " " + toStringThrowerStr)();83 createTest("'string' " + currentOp + " " + throwingPropStr )();84 createTest("'string' " + currentOp + " " + throwingObjGetter )();85 createTest("'string' " + currentOp + " " + getterThrowerStr )();86 87 numVal = currentOp == '||' ? 'rhsZeroNum' : 'rhsNonZeroNum';88 createTest(valueOfThrowerStr + " " + currentOp + " " + numVal)();89 createTest(toStringThrowerStr + " " + currentOp + " " + numVal)();90 createTest(throwingPropStr + " " + currentOp + " " + numVal)();91 createTest(throwingObjGetter + " " + currentOp + " " + numVal)();92 createTest(getterThrowerStr + " " + currentOp + " " + numVal)();93 createTest(valueOfThrowerStr + " " + currentOp + " rhsToStringThrower")();94 createTest(toStringThrowerStr + " " + currentOp + " rhsToStringThrower")();95 createTest(throwingPropStr + " " + currentOp + " rhsToStringThrower")();96 createTest(throwingObjGetter + " " + currentOp + " rhsToStringThrower")();97 createTest(getterThrowerStr + " " + currentOp + " rhsToStringThrower")();98 createTestWithRHSExec(valueOfThrowerStr + " " + currentOp + " " + rhsGetterTesterStr)();99 createTestWithRHSExec(toStringThrowerStr + " " + currentOp + " " + rhsGetterTesterStr)();100}...
Using AI Code Generation
1var page = require('webpage').create();2var system = require('system');3var url = system.args[1];4var num = system.args[2];5var delay = system.args[3];6var timeout = system.args[4];7var fname = system.args[5];8var wptkey = system.args[6];9var wpt = require('./wpt.js');10wpt.setKey(wptkey);
Using AI Code Generation
1var wpt = new WebPageTest('www.webpagetest.org','A.0b0f9c9a9a0e4d4b4f4f4c4e4f4d4d4c4');2var data = {runs: 1, location: 'Dulles:Chrome', connectivity: 'Cable', pollResults: 5};3var testId = '';4wpt.getTestResults('150729_7D_1Y', function(err, data) {5 if (err) return console.log(err);6 console.log('Test id: %s', data.data.testId);7 console.log('User agent: %s', data.data.userUrl);8 console.log('Test URL: %s', data.data.userUrl);9 console.log('Poll results: %s', data.data.jsonUrl);10 console.log('Summary CSV: %s', data.data.csvUrl);11 console.log('Detail CSV: %s', data.data.detailCsvUrl);12});
Using AI Code Generation
1const wpt = require('webpagetest');2const client = wpt('A.c2b7e2f8c8b0e5d5b0f1d1f8e5e5d5e5');3client.runTest(url, {4}, (err, data) => {5 if (err) {6 return console.error('Oh no! There was an error', err);7 }8 console.log('Yay! The test was successful. Here are the results');9 console.log(data);10});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!