Best JavaScript code snippet using playwright-internal
es6IsConcatSpreadable.js
Source:es6IsConcatSpreadable.js
...8 console.log(a[i], b[i], msg);9 }10}11function compareConcats(a, b) {12 var c = a.concat(b);13 b[Symbol.isConcatSpreadable] = false;14 var d = a.concat(b);15 console.log(b, d[a.length]);16 for (var i = 0; i < a.length; i++) {17 console.log(a[i], c[i]);18 console.log(a[i], d[i]);19 }20 for (var i = 0; i < b.length; i++) {21 console.log(b[i], c[a.length + i]);22 console.log(b[i], d[a.length][i]);23 }24 console.log(a.length + 1, d.length);25 excludeLengthCheck = false;26 delete b[Symbol.isConcatSpreadable];27}28function test1() {29 var a = [1, 2, 3];30 var b = [4, 5, 6];31 compareConcats(a, b);32}33test1();34function t2() {35 var a = [1.1, 2.2, 3.3];36 var b = [4.4, 5.5, 6.6];37 compareConcats(a, b);38}39t2();40function t3() {41 var a = ["a", "b", "c"];42 var b = ["d", "e", "f"];43 compareConcats(a, b);44}45t3();46function t4() {47 var a = [1.1, "b", 3];48 var b = [4, 5.5, "f"];49 compareConcats(a, b);50}51t4();52function t5() {53 var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];54 var b = [1, 2, 3].concat(4, 5, {55 [Symbol.isConcatSpreadable]: true,56 0: 6,57 1: 7,58 2: 8,59 "length": 360 }, 9, 10);61 areEqual(a, b); // Test to confirm we Spread to nothing when length is not set62 var a = [1, 2, 3, 4, 5, 9, 10];63 var b = [1, 2, 3].concat(4, 5, {64 [Symbol.isConcatSpreadable]: true,65 0: 6,66 1: 7,67 2: 868 }, 9, 10);69 areEqual(a, b);70}71t5();72function t6() {73 var a = [1.1, 2.1, 3.1];74 var b = 4.1;75 compareConcats(a, b);76 var a = [1, 2, 3];77 var b = 4;78 compareConcats(a, b);79 var a = [1, 2, 3];80 var b = "b";81 compareConcats(a, b);82 var a = [1, 2, 3];83 var b = true;84 compareConcats(a, b);85}86t6();87function t7() {88 var a = [1, 2, 3];89 var b = [4.4, 5.5, 6.6];90 var c = [Object, {}, undefined, Math.sin];91 for (var i = 0; i < c.length; i++) {92 a['constructor'] = c[i];93 compareConcats(a, b);94 }95 var o = [];96 o.constructor = function () {97 var a = new Array(100);98 a[0] = 10;99 return a;100 };101 areEqual([1, 2, 3], o.concat([1, 2, 3]));102}103t7();104function t8() {105 function test(x, y, z) {106 var a = [x],107 b = [y, z];108 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable] undefined');109 b[Symbol.isConcatSpreadable] = null;110 areEqual([x, [y, z]], a.concat(b), '[@@isConcatSpreadable]==null');111 b[Symbol.isConcatSpreadable] = false;112 areEqual([x, [y, z]], a.concat(b), '[@@isConcatSpreadable]==false');113 b[Symbol.isConcatSpreadable] = '';114 areEqual([x, [y, z]], a.concat(b), '[@@isConcatSpreadable]==\'\'');115 b[Symbol.isConcatSpreadable] = 0;116 areEqual([x, [y, z]], a.concat(b), '[@@isConcatSpreadable]==0');117 b[Symbol.isConcatSpreadable] = +0.0;118 areEqual([x, [y, z]], a.concat(b), '[@@isConcatSpreadable]==+0.0');119 b[Symbol.isConcatSpreadable] = -0.0;120 areEqual([x, [y, z]], a.concat(b), '[@@isConcatSpreadable]==-0.0');121 b[Symbol.isConcatSpreadable] = NaN;122 areEqual([x, [y, z]], a.concat(b), '[@@isConcatSpreadable]==NaN');123 b[Symbol.isConcatSpreadable] = undefined;124 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==undefined');125 b[Symbol.isConcatSpreadable] = true;126 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==true');127 b[Symbol.isConcatSpreadable] = 'abc';128 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]=\'abc\'');129 b[Symbol.isConcatSpreadable] = 0.1;130 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==0.1');131 b[Symbol.isConcatSpreadable] = -0.1;132 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==-0.1');133 b[Symbol.isConcatSpreadable] = Symbol();134 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==Symbol()');135 b[Symbol.isConcatSpreadable] = {};136 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]=={}');137 delete b[Symbol.isConcatSpreadable];138 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable] deleted');139 }140 test(1, 2, 3);141 test(1.1, 2.2, 3.3);142 test("a", "b", "c");143 test(1.1, "b", 3);144 test(4, 5.5, "f");145 test(undefined, NaN, function () {146 ;147 });148}149t8();150function t9() {151 function test(x, y, z) {152 var a = [x],153 b = {154 '0': y,155 '1': z,156 'length': 2157 };158 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable] undefined');159 b[Symbol.isConcatSpreadable] = null;160 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable]==null');161 b[Symbol.isConcatSpreadable] = false;162 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable]==false');163 b[Symbol.isConcatSpreadable] = '';164 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable]==\'\'');165 b[Symbol.isConcatSpreadable] = 0;166 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable]==0');167 b[Symbol.isConcatSpreadable] = +0.0;168 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable]==+0.0');169 b[Symbol.isConcatSpreadable] = -0.0;170 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable]==-0.0');171 b[Symbol.isConcatSpreadable] = NaN;172 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable]==NaN');173 b[Symbol.isConcatSpreadable] = undefined;174 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable]==undefined');175 b[Symbol.isConcatSpreadable] = true;176 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==true');177 b[Symbol.isConcatSpreadable] = 'abc';178 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==\'abc\'');179 b[Symbol.isConcatSpreadable] = 0.1;180 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==0.1');181 b[Symbol.isConcatSpreadable] = -0.1;182 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==-0.1');183 b[Symbol.isConcatSpreadable] = Symbol();184 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]==Symbol()');185 b[Symbol.isConcatSpreadable] = {};186 areEqual([x, y, z], a.concat(b), '[@@isConcatSpreadable]=={}');187 delete b[Symbol.isConcatSpreadable];188 areEqual([x, b], a.concat(b), '[@@isConcatSpreadable] deleted');189 }190 test(1, 2, 3);191 test(1.1, 2.2, 3.3);192 test("a", "b", "c");193 test(1.1, "b", 3);194 test(4, 5.5, "f");195 test(undefined, NaN, function () {196 ;197 });198}199t9();200function t10() {201 function test(x, y, z) {202 var a = [x],203 b = [y, z],204 c = [y, z];205 areEqual([x, y, z], a.concat(b), 'b[@@isConcatSpreadable] undefined');206 areEqual([x, y, z], a.concat(c), 'c[@@isConcatSpreadable] undefined');207 b[Symbol.isConcatSpreadable] = false;208 areEqual([x, [y, z]], a.concat(b), 'b[@@isConcatSpreadable]==false');209 areEqual([x, y, z], a.concat(c), 'c[@@isConcatSpreadable] undefined');210 c[Symbol.isConcatSpreadable] = false;211 areEqual([x, [y, z]], a.concat(b), 'b[@@isConcatSpreadable]==false');212 areEqual([x, [y, z]], a.concat(c), 'c[@@isConcatSpreadable]==false');213 b[Symbol.isConcatSpreadable] = true;214 areEqual([x, y, z], a.concat(b), 'b[@@isConcatSpreadable]==true');215 areEqual([x, [y, z]], a.concat(c), 'c[@@isConcatSpreadable]==false');216 c[Symbol.isConcatSpreadable] = true;217 areEqual([x, y, z], a.concat(b), 'b[@@isConcatSpreadable]==true');218 areEqual([x, y, z], a.concat(c), 'c[@@isConcatSpreadable]==true');219 c[Symbol.isConcatSpreadable] = false;220 areEqual([x, y, z], a.concat(b), 'b[@@isConcatSpreadable]==true');221 areEqual([x, [y, z]], a.concat(c), 'c[@@isConcatSpreadable]==false');222 b[Symbol.isConcatSpreadable] = false;223 areEqual([x, [y, z]], a.concat(b), 'b[@@isConcatSpreadable]==false');224 areEqual([x, [y, z]], a.concat(c), 'c[@@isConcatSpreadable]==false');225 b[Symbol.isConcatSpreadable] = undefined;226 areEqual([x, y, z], a.concat(b), 'b[@@isConcatSpreadable]==undefined');227 areEqual([x, [y, z]], a.concat(c), 'c[@@isConcatSpreadable]==false');228 delete b[Symbol.isConcatSpreadable];229 areEqual([x, y, z], a.concat(b), 'b[@@isConcatSpreadable] deleted');230 areEqual([x, [y, z]], a.concat(c), 'c[@@isConcatSpreadable]==false');231 delete c[Symbol.isConcatSpreadable];232 areEqual([x, y, z], a.concat(b), 'b[@@isConcatSpreadable] deleted');233 areEqual([x, y, z], a.concat(c), 'c[@@isConcatSpreadable] deleted');234 }235 test(1, 2, 3);236 test(1.1, 2.2, 3.3);237 test("a", "b", "c");238 test(1.1, "b", 3);239 test(4, 5.5, "f");240 test(undefined, NaN, function () {241 ;242 });243}244t10();245function t11() {246 function test(a, b, c) {247 var args = function () {248 return arguments;249 }(a, b, c);250 args[Symbol.isConcatSpreadable] = true;251 areEqual([a, b, c, a, b, c], [].concat(args, args), '[' + a + ', ' + b + ', ' + c + ', ' + a + ', ' + b + ', ' + c + ']');252 Object.defineProperty(args, "length", {253 value: 6254 });255 areEqual([a, b, c, undefined, undefined, undefined], [].concat(args), '[' + a + ', ' + b + ', ' + c + ', undefined, undefined, undefined]');256 }257 test(1, 2, 3);258 test(1.1, 2.2, 3.3);259 test("a", "b", "c");260 test(1.1, "b", 3);261 test(4, 5.5, "f");262 test(undefined, NaN, function () {263 ;264 });265}266t11();267function t12() {268 class MyObj extends Object {}269 var a = new MyObj();270 a.length = 5;271 a[0] = 'a';272 a[2] = 'b';273 a[4] = 'c';274 var b = {275 length: 3,276 "0": "a",277 "1": "b",278 "2": "c"279 };280 class MyArray extends Array {}281 var c = new MyArray("a", "b", "c");282 var d = ['e', 'f', 'g'];283 a[Symbol.isConcatSpreadable] = true;284 d[Symbol.isConcatSpreadable] = false;285 areEqual(['a', undefined, 'b', undefined, 'c', b, 'a', 'b', 'c', ['e', 'f', 'g']], Array.prototype.concat.call(a, b, c, d));286}287t12();288function t13() {289 var obj = {290 "length": {291 valueOf: null,292 toString: null293 }294 };295 obj[Symbol.isConcatSpreadable] = true;296 try {297 Array.prototype.concat.call(obj);298 } catch (e) {299 ;300 }301 obj = {302 "length": {303 toString: function () {304 throw new Error('User-defined error in toString');305 },306 valueOf: null307 }308 };309 obj[Symbol.isConcatSpreadable] = true;310 try {311 Array.prototype.concat.call(obj);312 } catch (e) {313 ;314 }315 obj = {316 "length": {317 toString: function () {318 return 'string';319 },320 valueOf: null321 }322 };323 obj[Symbol.isConcatSpreadable] = true;324 areEqual([], [].concat(obj), ' toString() returns string');325 obj = {326 "length": {327 valueOf: function () {328 throw new Error('User-defined error in valueOf');329 },330 toString: null331 }332 };333 obj[Symbol.isConcatSpreadable] = true;334 try {335 Array.prototype.concat.call(obj);336 } catch (e) {337 ;338 }339 obj = {340 "length": {341 valueOf: function () {342 return 'string';343 },344 toString: null345 }346 };347 obj[Symbol.isConcatSpreadable] = true;348 areEqual([], [].concat(obj), 'toString() returns string');349 obj = {350 "length": -4294967294,351 "0": "a",352 "2": "b",353 "4": "c"354 };355 obj[Symbol.isConcatSpreadable] = true;356 areEqual([], [].concat(obj), 'ToLength clamps negative to zero');357 obj.length = -0.0;358 areEqual([], [].concat(obj), 'ToLength clamps negative to zero');359 obj.length = "-4294967294";360 areEqual([], [].concat(obj), 'ToLength clamps negative to zero');361 obj.length = "-0.0";362 areEqual([], [].concat(obj), 'ToLength clamps negative to zero');363}364t13();365function t14() {366 var obj = {};367 Object.defineProperty(obj, Symbol.isConcatSpreadable, {368 get: function () {369 throw Error('User-defined error in @@isConcatSpreadable getter');370 }371 });372 try {373 [].concat(obj);374 } catch (e) {375 ;376 }377 try {378 Array.prototype.concat.call(obj);379 } catch (e) {380 ;381 }382}383t14();384function t15() {385 function test(arr) {386 var func = function (x, y, z) {387 ;388 };389 areEqual([func], [].concat(func), 'Function object');390 func[Symbol.isConcatSpreadable] = true;391 areEqual([undefined, undefined, undefined], [].concat(func), 'func[Symbol.isConcatSpreadable] == true');392 func[Symbol.isConcatSpreadable] = false;393 areEqual([func], [].concat(func), 'func[Symbol.isConcatSpreadable] == false');394 func[Symbol.isConcatSpreadable] = true;395 areEqual([undefined, undefined, undefined], [].concat(func), 'func[Symbol.isConcatSpreadable] == true');396 func[0] = arr[0];397 func[1] = arr[1];398 func[2] = arr[2];399 areEqual(arr, [].concat(func), 'func[0..2] assigned');400 delete func[0];401 delete func[1];402 delete func[2];403 areEqual([undefined, undefined, undefined], [].concat(func), 'func[0..2] deleted');404 delete func[Symbol.isConcatSpreadable];405 areEqual([func], [].concat(func), 'func[Symbol.isConcatSpreadable] deleted');406 Function.prototype[Symbol.isConcatSpreadable] = true;407 areEqual([undefined, undefined, undefined], [].concat(func), 'Function.prototype[Symbol.isConcatSpreadable] == true');408 Function.prototype[Symbol.isConcatSpreadable] = false;409 areEqual([func], [].concat(func), 'Function.prototype[Symbol.isConcatSpreadable] == false');410 Function.prototype[0] = arr[0];411 Function.prototype[1] = arr[1];412 Function.prototype[2] = arr[2];413 areEqual([func], [].concat(func), 'Function.prototype[0..2] assigned');414 Function.prototype[Symbol.isConcatSpreadable] = true;415 areEqual(arr, [].concat(func), 'Function.prototype[Symbol.isConcatSpreadable] == true');416 delete Function.prototype[0];417 delete Function.prototype[1];418 delete Function.prototype[2];419 areEqual([undefined, undefined, undefined], [].concat(func), 'Function.prototype[0..2] deleted');420 delete Function.prototype[Symbol.isConcatSpreadable];421 areEqual([func], [].concat(func), 'Function.prototype[Symbol.isConcatSpreadable] deleted');422 }423 test([1, 2, 3]);424 test([1.1, 2.2, 3.3]);425 test(["a", "b", "c"]);426 test([2, NaN, function () {427 ;428 }]);429}430t15();431function t16() {432 function test(Type, initVal, arr) {433 var obj = new Type(initVal);434 areEqual([obj], [].concat(obj), Type.name + ' obj');435 obj[Symbol.isConcatSpreadable] = true;436 areEqual([], [].concat(obj), Type.name + ' obj[Symbol.isConcatSpreadable] == true');437 obj.length = arr.length;438 areEqual(new Array(arr.length), [].concat(obj), Type.name + ' obj[length] assigned');439 for (var i = 0; i < arr.length; i++) {440 obj[i] = arr[i];441 }442 areEqual(arr, [].concat(obj), Type.name + ' obj[0..length] assigned');443 obj[Symbol.isConcatSpreadable] = false;444 areEqual([obj], [].concat(obj), Type.name + ' obj[Symbol.isConcatSpreadable] == false');445 obj[Symbol.isConcatSpreadable] = true;446 areEqual(arr, [].concat(obj), Type.name + ' obj[Symbol.isConcatSpreadable] == true');447 for (var i = 0; i < arr.length; i++) {448 delete obj[i];449 }450 areEqual(new Array(arr.length), [].concat(obj), Type.name + ' obj[0..length] deleted');451 delete obj.length;452 areEqual([], [].concat(obj), Type.name + ' obj[length] deleted');453 delete obj[Symbol.isConcatSpreadable];454 areEqual([obj], [].concat(obj), Type.name + ' obj[Symbol.isConcatSpreadable] deleted');455 Type.prototype[Symbol.isConcatSpreadable] = true;456 areEqual([], [].concat(obj), Type.name + '.prototype[Symbol.isConcatSpreadable] == true');457 Type.prototype.length = arr.length;458 areEqual(new Array(arr.length), [].concat(obj), Type.name + '.prototype[length] assigned');459 for (var i = 0; i < arr.length; i++) {460 Type.prototype[i] = arr[i];461 }462 areEqual(arr, [].concat(obj), Type.name + '.prototype[0..length] assigned');463 Type.prototype[Symbol.isConcatSpreadable] = false;464 areEqual([obj], [].concat(obj), Type.name + '.prototype[Symbol.isConcatSpreadable] == false');465 Type.prototype[Symbol.isConcatSpreadable] = true;466 areEqual(arr, [].concat(obj), Type.name + '.prototype[Symbol.isConcatSpreadable] == true');467 for (var i = 0; i < arr.length; i++) {468 delete Type.prototype[i];469 }470 areEqual(new Array(arr.length), [].concat(obj), Type.name + '.prototype[0..length] deleted');471 delete Type.prototype.length;472 areEqual([], [].concat(obj), Type.name + '.prototype[length] deleted');473 delete Type.prototype[Symbol.isConcatSpreadable];474 areEqual([obj], [].concat(obj), Type.name + '.prototype[Symbol.isConcatSpreadable] deleted');475 }476 test(Number, 0, [1, 2, 3]);477 test(Number, -0.1, [1.1, 2.2, 3.3]);478 test(Number, NaN, ["a", "b", "c"]);479 test(Number, 321, [1, "ab", 2.2, 2, NaN, 3, function () {480 ;481 }]);482 test(Boolean, true, [1, 2, 3]);483 test(Boolean, false, [1.1, 2.2, 3.3]);484 test(Boolean, true, ["a", "b", "c"]);485 test(Boolean, false, [1, "ab", 2.2, 2, NaN, 3, function () {486 ;487 }]);488 test(RegExp, /^/, [1, 2, 3]);489 test(RegExp, /abc/, [1.1, 2.2, 3.3]);490 test(RegExp, /(\d+)/, ["a", "b", "c"]);491 test(RegExp, /^\s*\S+\s*$/, [1, "ab", 2.2, 2, NaN, 3, function () {492 ;493 }]);494}495t16();496function t17() {497 function test() {498 var s = new String("abc");499 areEqual([s], [].concat(s), "string");500 s[Symbol.isConcatSpreadable] = true;501 areEqual(['a', 'b', 'c'], [].concat(s), "string s[Symbol.isConcatSpreadable] == true");502 s[Symbol.isConcatSpreadable] = false;503 areEqual([s], [].concat(s), "string s[Symbol.isConcatSpreadable] == false");504 s[Symbol.isConcatSpreadable] = true;505 areEqual(['a', 'b', 'c'], [].concat(s), "string s[Symbol.isConcatSpreadable] == true");506 delete s[Symbol.isConcatSpreadable];507 areEqual([s], [].concat(s), "string s[Symbol.isConcatSpreadable] deleted");508 String.prototype[Symbol.isConcatSpreadable] = true;509 areEqual(['a', 'b', 'c'], [].concat(s), "string.prototype[Symbol.isConcatSpreadable] == true");510 String.prototype[Symbol.isConcatSpreadable] = false;511 areEqual([s], [].concat(s), "string.prototype[Symbol.isConcatSpreadable] == false");512 String.prototype[Symbol.isConcatSpreadable] = true;513 areEqual(['a', 'b', 'c'], [].concat(s), "string.prototype[Symbol.isConcatSpreadable] == true");514 delete String.prototype[Symbol.isConcatSpreadable];515 areEqual([s], [].concat(s), "string.prototype[Symbol.isConcatSpreadable] deleted");516 }517 test();518}519t17();520function t18() {521 // proxy revoked522 var obj = {};523 var pobj = Proxy.revocable(obj, {524 get: function (target, prop) {525 if (prop === Symbol.isConcatSpreadable) {526 pobj.revoke();527 }528 return obj[prop];529 }530 });531 try {532 [].concat(pobj.proxy);533 } catch (e) {534 ;535 }536}537t18();538function t19() {539 function test(arr, idx, elem) {540 var expected = arr.slice(0);541 expected[idx] = elem;542 Object.defineProperty(arr, Symbol.isConcatSpreadable, {543 get: function () {544 arr[idx] = elem;545 return true;546 }547 });548 areEqual(expected, [].concat(arr), 'expecting [' + expected + ']');549 }550 test([1, 2, 3], 1, 'abc');551 test([1.1, 2.2, 3.3], 0, {});552}553t19();554function t20() {555 function test(arr, expected) {556 Object.defineProperty(arr, Symbol.isConcatSpreadable, {557 get: function () {558 arr = [];559 return true;560 }561 });562 areEqual(expected, Array.prototype.concat.call(arr, arr), 'expecting [' + expected + ']');563 areEqual([], Array.prototype.concat.call(arr, arr), 'expecting []');564 }565 test([1, 2, 3], [1, 2, 3, 1, 2, 3]);566 test([1.1, 2.2, 3.3], [1.1, 2.2, 3.3, 1.1, 2.2, 3.3]);567 test(["a", "b", "c"], ["a", "b", "c", "a", "b", "c"]);568 test([1.1, "b", 3], [1.1, "b", 3, 1.1, "b", 3]);569 test([4, 5.5, "f"], [4, 5.5, "f", 4, 5.5, "f"]);570 var func = function () {571 ;572 };573 test([undefined, NaN, func], [undefined, NaN, func, undefined, NaN, func]);574}575t20();576function t21() {577 function test(arr, idx, elem) {578 var expected = arr.slice(0);579 expected[idx] = elem;580 Object.defineProperty(arr, Symbol.isConcatSpreadable, {581 get: function () {582 Object.defineProperty(arr, idx, {583 'get': function () {584 return elem;585 }586 });587 return true;588 }589 });590 areEqual(expected, Array.prototype.concat.call(arr), 'expecting [' + arr + ']');591 }592 test([1, 2, 3], 1, 'abc');593 test([1.1, 2.2, 3.3], 0, {});594}595t21();596function t22() {597 function test(a) {598 var b = {599 "0": 1,600 "1": 2,601 "length": 2602 };603 Object.defineProperty(b, Symbol.isConcatSpreadable, {604 get: function () {605 b.length = 9007199254740989;606 return true;607 }608 });609 try {610 a.concat(b);611 } catch (e) {612 ;613 }614 }615 test([1, 2, 3]);616 test([1.1, 2.2, 3.3]);617 test(["a", "b", "c"]);618 test([1.1, "b", 3]);619 test([4, 5.5, "f"]);620 test([undefined, NaN, function () {621 ;622 }]);623}624t22();625function t23() {626 var obj1 = [21];627 var arr2 = [1];628 var arr2ICSCalled = 0;629 Object.defineProperty(arr2, Symbol.isConcatSpreadable, {630 get: function () {631 arr2ICSCalled++;632 dst[2] = {};633 return false;634 }635 });636 var dst = [1, 2, 3];637 var FakeConstructor = function () {638 return dst;639 };640 FakeConstructor[Symbol.species] = FakeConstructor;641 var arr = [2, 4];642 arr.constructor = FakeConstructor;643 var out = arr.concat(arr2, obj1);644 areEqual(1, arr2ICSCalled, 'isConcatSpreadable for arr2 should be called once');645 areEqual([2, 4, [1], 21], out);646}647t23();648function t24() {649 var obj1 = [21, 22];650 var arr2 = [1, 2, 3];651 var first = true;652 var arr2ICSCalled = 0;653 Object.defineProperty(arr2, Symbol.isConcatSpreadable, {654 get: function () {655 arr2ICSCalled++;656 if (first) {657 // Changin the array to ES5 array.658 Object.defineProperty(dst, "2", {659 get: function () {660 return 1;661 }662 });663 first = false;664 }665 return true;666 }667 });668 var dst = [1, 2, 3];669 var FakeConstructor = function () {670 return dst;671 };672 FakeConstructor[Symbol.species] = FakeConstructor;673 var arr = [2, 4];674 arr.constructor = FakeConstructor;675 var out = arr.concat(arr2, obj1);676 areEqual(1, arr2ICSCalled, 'isConcatSpreadable for arr2 should be called once');677 areEqual([2, 4, 1, 2, 3, 21, 22], out, 'arr2 should be part of the spread');678}...
pokeImg.js
Source:pokeImg.js
1const url = 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/';2const sprites = {3 bulbasaur: {4 default: url.concat('1.png'),5 },6 charmander: {7 default: url.concat('4.png'),8 },9 squirtle: {10 default: url.concat('7.png'),11 },12 caterpie: {13 default: url.concat('10.png'),14 },15 weedle: {16 default: url.concat('13.png'),17 },18 pidgey: {19 default: url.concat('16.png'),20 },21 rattata: {22 default: url.concat('19.png'),23 },24 spearow: {25 default: url.concat('21.png'),26 },27 ekans: {28 default: url.concat('23.png'),29 },30 sandshrew: {31 default: url.concat('27.png'),32 },33 'nidoran-f': {34 default: url.concat('29.png'),35 },36 'nidoran-m': {37 default: url.concat('32.png'),38 },39 vulpix: {40 default: url.concat('37.png'),41 },42 zubat: {43 default: url.concat('41.png'),44 },45 oddish: {46 default: url.concat('43.png'),47 },48 paras: {49 default: url.concat('46.png'),50 },51 venonat: {52 default: url.concat('48.png'),53 },54 diglett: {55 default: url.concat('50.png'),56 },57 meowth: {58 default: url.concat('52.png'),59 },60 psyduck: {61 default: url.concat('54.png'),62 },63 mankey: {64 default: url.concat('56.png'),65 },66 growlithe: {67 default: url.concat('58.png'),68 },69 poliwag: {70 default: url.concat('60.png'),71 },72 abra: {73 default: url.concat('63.png'),74 },75 machop: {76 default: url.concat('66.png'),77 },78 bellsprout: {79 default: url.concat('69.png'),80 },81 tentacool: {82 default: url.concat('72.png'),83 },84 geodude: {85 default: url.concat('74.png'),86 },87 ponyta: {88 default: url.concat('77.png'),89 },90 slowpoke: {91 default: url.concat('79.png'),92 },93 magnemite: {94 default: url.concat('81.png'),95 },96 farfetchd: {97 default: url.concat('83.png'),98 },99 venusaur: {100 default: url.concat('3.png'),101 },102 charmeleon: {103 default: url.concat('5.png'),104 },105 charizard: {106 default: url.concat('6.png'),107 },108 blastoise: {109 default: url.concat('9.png'),110 },111 metapod: {112 default: url.concat('11.png'),113 },114 butterfree: {115 default: url.concat('12.png'),116 },117 kakuna: {118 default: url.concat('14.png'),119 },120 beedrill: {121 default: url.concat('15.png'),122 },123 pidgeotto: {124 default: url.concat('17.png'),125 },126 pidgeot: {127 default: url.concat('18.png'),128 },129 raticate: {130 default: url.concat('20.png'),131 },132 fearow: {133 default: url.concat('22.png'),134 },135 arbok: {136 default: url.concat('24.png'),137 },138 pikachu: {139 default: url.concat('25.png'),140 },141 raichu: {142 default: url.concat('26.png'),143 },144 sandslash: {145 default: url.concat('28.png'),146 },147 nidorina: {148 default: url.concat('30.png'),149 },150 nidoqueen: {151 default: url.concat('31.png'),152 },153 nidorino: {154 default: url.concat('33.png'),155 },156 nidoking: {157 default: url.concat('34.png'),158 },159 clefairy: {160 default: url.concat('35.png'),161 },162 clefable: {163 default: url.concat('36.png'),164 },165 ninetales: {166 default: url.concat('38.png'),167 },168 jigglypuff: {169 default: url.concat('39.png'),170 },171 wigglytuff: {172 default: url.concat('40.png'),173 },174 golbat: {175 default: url.concat('42.png'),176 },177 gloom: {178 default: url.concat('44.png'),179 },180 parasect: {181 default: url.concat('47.png'),182 },183 venomoth: {184 default: url.concat('49.png'),185 },186 dugtrio: {187 default: url.concat('51.png'),188 },189 persian: {190 default: url.concat('53.png'),191 },192 golduck: {193 default: url.concat('55.png'),194 },195 primeape: {196 default: url.concat('57.png'),197 },198 arcanine: {199 default: url.concat('59.png'),200 },201 poliwhirl: {202 default: url.concat('61.png'),203 },204 poliwrath: {205 default: url.concat('62.png'),206 },207 kadabra: {208 default: url.concat('64.png'),209 },210 alakazam: {211 default: url.concat('65.png'),212 },213 machoke: {214 default: url.concat('67.png'),215 },216 machamp: {217 default: url.concat('68.png'),218 },219 weepinbell: {220 default: url.concat('70.png'),221 },222 victreebel: {223 default: url.concat('71.png'),224 },225 tentacruel: {226 default: url.concat('73.png'),227 },228 graveler: {229 default: url.concat('75.png'),230 },231 golem: {232 default: url.concat('76.png'),233 },234 rapidash: {235 default: url.concat('78.png'),236 },237 slowbro: {238 default: url.concat('80.png'),239 },240 magneton: {241 default: url.concat('82.png'),242 },243 doduo: {244 default: url.concat('84.png'),245 },246 seel: {247 default: url.concat('86.png'),248 },249 grimer: {250 default: url.concat('88.png'),251 },252 shellder: {253 default: url.concat('90.png'),254 },255 gastly: {256 default: url.concat('92.png'),257 },258 onix: {259 default: url.concat('95.png'),260 },261 drowzee: {262 default: url.concat('96.png'),263 },264 krabby: {265 default: url.concat('98.png'),266 },267 voltorb: {268 default: url.concat('100.png'),269 },270 exeggcute: {271 default: url.concat('102.png'),272 },273 cubone: {274 default: url.concat('104.png'),275 },276 lickitung: {277 default: url.concat('108.png'),278 },279 koffing: {280 default: url.concat('109.png'),281 },282 rhyhorn: {283 default: url.concat('111.png'),284 },285 tangela: {286 default: url.concat('114.png'),287 },288 kangaskhan: {289 default: url.concat('115.png'),290 },291 horsea: {292 default: url.concat('116.png'),293 },294 goldeen: {295 default: url.concat('118.png'),296 },297 staryu: {298 default: url.concat('120.png'),299 },300 scyther: {301 default: url.concat('123.png'),302 },303 pinsir: {304 default: url.concat('127.png'),305 },306 tauros: {307 default: url.concat('128.png'),308 },309 magikarp: {310 default: url.concat('129.png'),311 },312 lapras: {313 default: url.concat('131.png'),314 },315 ditto: {316 default: url.concat('132.png'),317 },318 eevee: {319 default: url.concat('133.png'),320 },321 porygon: {322 default: url.concat('137.png'),323 },324 omanyte: {325 default: url.concat('138.png'),326 },327 kabuto: {328 default: url.concat('140.png'),329 },330 aerodactyl: {331 default: url.concat('142.png'),332 },333 articuno: {334 default: url.concat('144.png'),335 },336 zapdos: {337 default: url.concat('145.png'),338 },339 moltres: {340 default: url.concat('146.png'),341 },342 dratini: {343 default: url.concat('147.png'),344 },345 mewtwo: {346 default: url.concat('150.png'),347 },348 mew: {349 default: url.concat('151.png'),350 },351 dewgong: {352 default: url.concat('87.png'),353 },354 muk: {355 default: url.concat('89.png'),356 },357 haunter: {358 default: url.concat('93.png'),359 },360 gengar: {361 default: url.concat('94.png'),362 },363 hypno: {364 default: url.concat('97.png'),365 },366 marowak: {367 default: url.concat('105.png'),368 },369 hitmonlee: {370 default: url.concat('106.png'),371 },372 hitmonchan: {373 default: url.concat('107.png'),374 },375 weezing: {376 default: url.concat('110.png'),377 },378 rhydon: {379 default: url.concat('112.png'),380 },381 chansey: {382 default: url.concat('113.png'),383 },384 seadra: {385 default: url.concat('117.png'),386 },387 seaking: {388 default: url.concat('119.png'),389 },390 starmie: {391 default: url.concat('121.png'),392 },393 'mr-mime': {394 default: url.concat('122.png'),395 },396 jynx: {397 default: url.concat('124.png'),398 },399 electabuzz: {400 default: url.concat('125.png'),401 },402 magmar: {403 default: url.concat('126.png'),404 },405 gyarados: {406 default: url.concat('130.png'),407 },408 vaporeon: {409 default: url.concat('134.png'),410 },411 jolteon: {412 default: url.concat('135.png'),413 },414 flareon: {415 default: url.concat('136.png'),416 },417 omastar: {418 default: url.concat('139.png'),419 },420 kabutops: {421 default: url.concat('141.png'),422 },423 snorlax: {424 default: url.concat('143.png'),425 },426 dragonair: {427 default: url.concat('148.png'),428 },429 dragonite: {430 default: url.concat('149.png'),431 },432 ivysaur: {433 default: url.concat('2.png'),434 },435 wartortle: {436 default: url.concat('8.png'),437 },438 vileplume: {439 default: url.concat('45.png'),440 },441 dodrio: {442 default: url.concat('85.png'),443 },444 cloyster: {445 default: url.concat('91.png'),446 },447 kingler: {448 default: url.concat('99.png'),449 },450 electrode: {451 default: url.concat('101.png'),452 },453 exeggutor: {454 default: url.concat('103.png'),455 },456};457export default function getPokemonImage(name, type = 'default') {458 return sprites[name.toLowerCase()][type];...
camlinternalFormatBasics.js
Source:camlinternalFormatBasics.js
1'use strict';2goog.module("bs-platform.camlinternalFormatBasics");3var Block = goog.require("bs-platform.block");4function erase_rel(param) {5 if (typeof param === "number") {6 return /* End_of_fmtty */0;7 } else {8 switch (param.tag | 0) {9 case 0 : 10 return /* Char_ty */Block.__(0, [erase_rel(param[0])]);11 case 1 : 12 return /* String_ty */Block.__(1, [erase_rel(param[0])]);13 case 2 : 14 return /* Int_ty */Block.__(2, [erase_rel(param[0])]);15 case 3 : 16 return /* Int32_ty */Block.__(3, [erase_rel(param[0])]);17 case 4 : 18 return /* Nativeint_ty */Block.__(4, [erase_rel(param[0])]);19 case 5 : 20 return /* Int64_ty */Block.__(5, [erase_rel(param[0])]);21 case 6 : 22 return /* Float_ty */Block.__(6, [erase_rel(param[0])]);23 case 7 : 24 return /* Bool_ty */Block.__(7, [erase_rel(param[0])]);25 case 8 : 26 return /* Format_arg_ty */Block.__(8, [27 param[0],28 erase_rel(param[1])29 ]);30 case 9 : 31 var ty1 = param[0];32 return /* Format_subst_ty */Block.__(9, [33 ty1,34 ty1,35 erase_rel(param[2])36 ]);37 case 10 : 38 return /* Alpha_ty */Block.__(10, [erase_rel(param[0])]);39 case 11 : 40 return /* Theta_ty */Block.__(11, [erase_rel(param[0])]);41 case 12 : 42 return /* Any_ty */Block.__(12, [erase_rel(param[0])]);43 case 13 : 44 return /* Reader_ty */Block.__(13, [erase_rel(param[0])]);45 case 14 : 46 return /* Ignored_reader_ty */Block.__(14, [erase_rel(param[0])]);47 48 }49 }50}51function concat_fmtty(fmtty1, fmtty2) {52 if (typeof fmtty1 === "number") {53 return fmtty2;54 } else {55 switch (fmtty1.tag | 0) {56 case 0 : 57 return /* Char_ty */Block.__(0, [concat_fmtty(fmtty1[0], fmtty2)]);58 case 1 : 59 return /* String_ty */Block.__(1, [concat_fmtty(fmtty1[0], fmtty2)]);60 case 2 : 61 return /* Int_ty */Block.__(2, [concat_fmtty(fmtty1[0], fmtty2)]);62 case 3 : 63 return /* Int32_ty */Block.__(3, [concat_fmtty(fmtty1[0], fmtty2)]);64 case 4 : 65 return /* Nativeint_ty */Block.__(4, [concat_fmtty(fmtty1[0], fmtty2)]);66 case 5 : 67 return /* Int64_ty */Block.__(5, [concat_fmtty(fmtty1[0], fmtty2)]);68 case 6 : 69 return /* Float_ty */Block.__(6, [concat_fmtty(fmtty1[0], fmtty2)]);70 case 7 : 71 return /* Bool_ty */Block.__(7, [concat_fmtty(fmtty1[0], fmtty2)]);72 case 8 : 73 return /* Format_arg_ty */Block.__(8, [74 fmtty1[0],75 concat_fmtty(fmtty1[1], fmtty2)76 ]);77 case 9 : 78 return /* Format_subst_ty */Block.__(9, [79 fmtty1[0],80 fmtty1[1],81 concat_fmtty(fmtty1[2], fmtty2)82 ]);83 case 10 : 84 return /* Alpha_ty */Block.__(10, [concat_fmtty(fmtty1[0], fmtty2)]);85 case 11 : 86 return /* Theta_ty */Block.__(11, [concat_fmtty(fmtty1[0], fmtty2)]);87 case 12 : 88 return /* Any_ty */Block.__(12, [concat_fmtty(fmtty1[0], fmtty2)]);89 case 13 : 90 return /* Reader_ty */Block.__(13, [concat_fmtty(fmtty1[0], fmtty2)]);91 case 14 : 92 return /* Ignored_reader_ty */Block.__(14, [concat_fmtty(fmtty1[0], fmtty2)]);93 94 }95 }96}97function concat_fmt(fmt1, fmt2) {98 if (typeof fmt1 === "number") {99 return fmt2;100 } else {101 switch (fmt1.tag | 0) {102 case 0 : 103 return /* Char */Block.__(0, [concat_fmt(fmt1[0], fmt2)]);104 case 1 : 105 return /* Caml_char */Block.__(1, [concat_fmt(fmt1[0], fmt2)]);106 case 2 : 107 return /* String */Block.__(2, [108 fmt1[0],109 concat_fmt(fmt1[1], fmt2)110 ]);111 case 3 : 112 return /* Caml_string */Block.__(3, [113 fmt1[0],114 concat_fmt(fmt1[1], fmt2)115 ]);116 case 4 : 117 return /* Int */Block.__(4, [118 fmt1[0],119 fmt1[1],120 fmt1[2],121 concat_fmt(fmt1[3], fmt2)122 ]);123 case 5 : 124 return /* Int32 */Block.__(5, [125 fmt1[0],126 fmt1[1],127 fmt1[2],128 concat_fmt(fmt1[3], fmt2)129 ]);130 case 6 : 131 return /* Nativeint */Block.__(6, [132 fmt1[0],133 fmt1[1],134 fmt1[2],135 concat_fmt(fmt1[3], fmt2)136 ]);137 case 7 : 138 return /* Int64 */Block.__(7, [139 fmt1[0],140 fmt1[1],141 fmt1[2],142 concat_fmt(fmt1[3], fmt2)143 ]);144 case 8 : 145 return /* Float */Block.__(8, [146 fmt1[0],147 fmt1[1],148 fmt1[2],149 concat_fmt(fmt1[3], fmt2)150 ]);151 case 9 : 152 return /* Bool */Block.__(9, [concat_fmt(fmt1[0], fmt2)]);153 case 10 : 154 return /* Flush */Block.__(10, [concat_fmt(fmt1[0], fmt2)]);155 case 11 : 156 return /* String_literal */Block.__(11, [157 fmt1[0],158 concat_fmt(fmt1[1], fmt2)159 ]);160 case 12 : 161 return /* Char_literal */Block.__(12, [162 fmt1[0],163 concat_fmt(fmt1[1], fmt2)164 ]);165 case 13 : 166 return /* Format_arg */Block.__(13, [167 fmt1[0],168 fmt1[1],169 concat_fmt(fmt1[2], fmt2)170 ]);171 case 14 : 172 return /* Format_subst */Block.__(14, [173 fmt1[0],174 fmt1[1],175 concat_fmt(fmt1[2], fmt2)176 ]);177 case 15 : 178 return /* Alpha */Block.__(15, [concat_fmt(fmt1[0], fmt2)]);179 case 16 : 180 return /* Theta */Block.__(16, [concat_fmt(fmt1[0], fmt2)]);181 case 17 : 182 return /* Formatting_lit */Block.__(17, [183 fmt1[0],184 concat_fmt(fmt1[1], fmt2)185 ]);186 case 18 : 187 return /* Formatting_gen */Block.__(18, [188 fmt1[0],189 concat_fmt(fmt1[1], fmt2)190 ]);191 case 19 : 192 return /* Reader */Block.__(19, [concat_fmt(fmt1[0], fmt2)]);193 case 20 : 194 return /* Scan_char_set */Block.__(20, [195 fmt1[0],196 fmt1[1],197 concat_fmt(fmt1[2], fmt2)198 ]);199 case 21 : 200 return /* Scan_get_counter */Block.__(21, [201 fmt1[0],202 concat_fmt(fmt1[1], fmt2)203 ]);204 case 22 : 205 return /* Scan_next_char */Block.__(22, [concat_fmt(fmt1[0], fmt2)]);206 case 23 : 207 return /* Ignored_param */Block.__(23, [208 fmt1[0],209 concat_fmt(fmt1[1], fmt2)210 ]);211 case 24 : 212 return /* Custom */Block.__(24, [213 fmt1[0],214 fmt1[1],215 concat_fmt(fmt1[2], fmt2)216 ]);217 218 }219 }220}221exports.concat_fmtty = concat_fmtty;222exports.erase_rel = erase_rel;223exports.concat_fmt = concat_fmt;...
concat.js
Source:concat.js
...34 var count = 0;35 var testcases = new Array();36 var aString = new String("test string");37 var bString = new String(" another ");38 testcases[count++] = new TestCase( SECTION, "aString.concat(' more')", "test string more", aString.concat(' more').toString());39 testcases[count++] = new TestCase( SECTION, "aString.concat(bString)", "test string another ", aString.concat(bString).toString());40 testcases[count++] = new TestCase( SECTION, "aString ", "test string", aString.toString());41 testcases[count++] = new TestCase( SECTION, "bString ", " another ", bString.toString());42 testcases[count++] = new TestCase( SECTION, "aString.concat(345) ", "test string345", aString.concat(345).toString());43 testcases[count++] = new TestCase( SECTION, "aString.concat(true) ", "test stringtrue", aString.concat(true).toString());44 testcases[count++] = new TestCase( SECTION, "aString.concat(null) ", "test stringnull", aString.concat(null).toString());45 /*46 http://bugs.webkit.org/show_bug.cgi?id=11545#c347 According to ECMA 15.5.4.6, the argument of concat should send to ToString and48 convert into a string value (not String object). So these arguments will be49 convert into '' and '1,2,3' under ECMA-262v3, not the js1.2 expected '[]' and50 '[1,2,3]'51 */52 //testcases[count++] = new TestCase( SECTION, "aString.concat([]) ", "test string[]", aString.concat([]).toString());53 //testcases[count++] = new TestCase( SECTION, "aString.concat([1,2,3])", "test string[1, 2, 3]", aString.concat([1,2,3]).toString());54 testcases[count++] = new TestCase( SECTION, "'abcde'.concat(' more')", "abcde more", 'abcde'.concat(' more').toString());55 testcases[count++] = new TestCase( SECTION, "'abcde'.concat(bString)", "abcde another ", 'abcde'.concat(bString).toString());56 testcases[count++] = new TestCase( SECTION, "'abcde' ", "abcde", 'abcde');57 testcases[count++] = new TestCase( SECTION, "'abcde'.concat(345) ", "abcde345", 'abcde'.concat(345).toString());58 testcases[count++] = new TestCase( SECTION, "'abcde'.concat(true) ", "abcdetrue", 'abcde'.concat(true).toString());59 testcases[count++] = new TestCase( SECTION, "'abcde'.concat(null) ", "abcdenull", 'abcde'.concat(null).toString());60 /*61 http://bugs.webkit.org/show_bug.cgi?id=11545#c362 According to ECMA 15.5.4.6, the argument of concat should send to ToString and63 convert into a string value (not String object). So these arguments will be64 convert into '' and '1,2,3' under ECMA-262v3, not the js1.2 expected '[]' and65 '[1,2,3]'66 */67 //testcases[count++] = new TestCase( SECTION, "'abcde'.concat([]) ", "abcde[]", 'abcde'.concat([]).toString());68 //testcases[count++] = new TestCase( SECTION, "'abcde'.concat([1,2,3])", "abcde[1, 2, 3]", 'abcde'.concat([1,2,3]).toString());69 //what should this do:70 testcases[count++] = new TestCase( SECTION, "'abcde'.concat() ", "abcde", 'abcde'.concat().toString());71 function test()72 {73 for ( tc=0; tc < testcases.length; tc++ ) {74 testcases[tc].passed = writeTestCaseResult(75 testcases[tc].expect,76 testcases[tc].actual,77 testcases[tc].description +" = "+78 testcases[tc].actual );79 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";80 }81 stopTest();82 return ( testcases );83 }84 test();
JDK-8061391.js
Source:JDK-8061391.js
...41 print(oa);42 print(aa);43 44 for (var i = 0; i < aa.length; i++) {45 print(aa[i].concat(aa[i][0]));46 for (var j = 0; j < aa.length ; j++) {47 print(aa[i].concat(aa[j]));48 }49 }50}51function concats_inline() {52 print("separate callsites");53 print(ia);54 print(la);55 print(da);56 print(oa);57 print(aa);58 59 print(aa[0].concat(aa[0]));60 print(aa[0].concat(aa[1]));61 print(aa[0].concat(aa[2]));62 print(aa[0].concat(aa[3]));63 print(aa[0].concat(aa[0][0])); 64 print(aa[1].concat(aa[0]));65 print(aa[1].concat(aa[1]));66 print(aa[1].concat(aa[2]));67 print(aa[1].concat(aa[3]));68 print(aa[1].concat(aa[1][0])); 69 print(aa[2].concat(aa[0]));70 print(aa[2].concat(aa[1]));71 print(aa[2].concat(aa[2]));72 print(aa[2].concat(aa[3]));73 print(aa[2].concat(aa[2][0])); 74 print(aa[3].concat(aa[0]));75 print(aa[3].concat(aa[1]));76 print(aa[3].concat(aa[2]));77 print(aa[3].concat(aa[3]));78 print(aa[3].concat(aa[3][0])); 79}80concats();81concats_inline();82print();83var oldia = ia.slice(0); //clone ia84print("oldia = " + oldia);85ia[10] = "sparse";86print("oldia = " + oldia);87print();88print("Redoing with sparse arrays");89concats();90concats_inline();91ia = oldia;92print("Restored ia = " + ia);93function concat_expand() {94 print("concat type expansion");95 print(ia.concat(la));96 print(ia.concat(da));97 print(ia.concat(oa));98 print(la.concat(ia));99 print(la.concat(da));100 print(la.concat(oa));101 print(da.concat(ia));102 print(da.concat(la));103 print(da.concat(oa));104}105print();106concat_expand();107print();108function concat_varargs() {109 print("concat varargs");110 print(ia.concat(la)); //fast111 print(ia.concat(la, da, oa)); //slow112 var slow = ia.concat(1, maxJavaInt * 2, 4711.17, function() { print("hello, world") }); //slow113 print(slow);114 return slow;115}116var slow = concat_varargs();117print();118print("sanity checks");119slow.map(120 function(elem) {121 if (elem instanceof Function) {122 elem();123 } else {124 print((typeof elem) + " = " + elem);125 }126 });127print(ia.concat({key: "value"}));...
concat.suite.js
Source:concat.suite.js
...14const tenThousandItemsAlt = lists(10000);15const hundredThousandItemsAlt = lists(100000);16const suite = new Benchmark.Suite();17suite18 .add("listOld.concat ten items", () => listOld.concat(tenItems, tenItemsAlt))19 .add("listOld.concat hundred items", () =>20 listOld.concat(hundredItems, hundredItemsAlt)21 )22 .add("listOld.concat thousand items", () =>23 listOld.concat(thousandItems, thousandItemsAlt)24 )25 .add("listOld.concat ten thousand items", () =>26 listOld.concat(tenThousandItems, tenThousandItemsAlt)27 )28 .add("listOld.concat hundred thousand items", () =>29 listOld.concat(hundredThousandItems, hundredThousandItemsAlt)30 )31 .add("L.concat ten items", () => L.concat(tenItems, tenItemsAlt))32 .add("L.concat hundred items", () => L.concat(hundredItems, hundredItemsAlt))33 .add("L.concat thousand items", () =>34 L.concat(thousandItems, thousandItemsAlt)35 )36 .add("L.concat ten thousand items", () =>37 L.concat(tenThousandItems, tenThousandItemsAlt)38 )39 .add("L.concat hundred thousand items", () =>40 L.concat(hundredThousandItems, hundredThousandItemsAlt)41 )42 .add("listOld.concat same ten items", () =>43 listOld.concat(tenItems, tenItems)44 )45 .add("listOld.concat same hundred items", () =>46 listOld.concat(hundredItems, hundredItems)47 )48 .add("listOld.concat same thousand items", () =>49 listOld.concat(thousandItems, thousandItems)50 )51 .add("listOld.concat same ten thousand items", () =>52 listOld.concat(tenThousandItems, tenThousandItems)53 )54 .add("listOld.concat same hundred thousand items", () =>55 listOld.concat(hundredThousandItems, hundredThousandItems)56 )57 .add("L.concat same ten items", () => L.concat(tenItems, tenItems))58 .add("L.concat same hundred items", () =>59 L.concat(hundredItems, hundredItems)60 )61 .add("L.concat same thousand items", () =>62 L.concat(thousandItems, thousandItems)63 )64 .add("L.concat same ten thousand items", () =>65 L.concat(tenThousandItems, tenThousandItems)66 )67 .add("L.concat same hundred thousand items", () =>68 L.concat(hundredThousandItems, hundredThousandItems)69 )70 .on("cycle", ev => console.log(String(ev.target)))71 .on("error", e => console.error(e.target.error))...
S15.4.4.4_A2_T1.js
Source:S15.4.4.4_A2_T1.js
...11var x = {};12x.concat = Array.prototype.concat;13var y = new Object();14var z = new Array(1,2);15var arr = x.concat(y,z, -1, true, "NaN");16//CHECK#017arr.getClass = Object.prototype.toString;18if (arr.getClass() !== "[object " + "Array" + "]") {19 $ERROR('#0: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr is Array object. Actual: ' + (arr.getClass()));20}21//CHECK#122if (arr[0] !== x) {23 $ERROR('#1: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[0] === x. Actual: ' + (arr[0]));24}25//CHECK#226if (arr[1] !== y) {27 $ERROR('#2: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[1] === y. Actual: ' + (arr[1]));28}29//CHECK#330if (arr[2] !== 1) {31 $ERROR('#3: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[2] === 1. Actual: ' + (arr[2]));32}33//CHECK#434if (arr[3] !== 2) {35 $ERROR('#4: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[3] === 2. Actual: ' + (arr[3]));36}37//CHECK#538if (arr[4] !== -1) {39 $ERROR('#5: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[4] === -1. Actual: ' + (arr[4]));40}41//CHECK#642if (arr[5] !== true) {43 $ERROR('#6: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[5] === true. Actual: ' + (arr[5]));44}45//CHECK#746if (arr[6] !== "NaN") {47 $ERROR('#7: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr[6] === "NaN". Actual: ' + (arr[6]));48}49//CHECK#850if (arr.length !== 7) {51 $ERROR('#8: var x = {}; x.concat = Array.prototype.concat; var y = new Object(); var z = new Array(1,2); var arr = x.concat(y,z, -1, true, "NaN"); arr.length === 7. Actual: ' + (arr.length));52}...
rest.js
Source:rest.js
...3 */4const httpDomain = process.env.VUE_APP_BASEURL5const wsDomain = process.env.VUE_APP_WSURL6export default {7 sugarJMeterFunctions: httpDomain.concat("/sugar-jmeter/functions"),8 sugarJMeterExecuteFunction: httpDomain.concat("/sugar-jmeter/execute-function"),9 sugarJMeterExecuteTestPlan: httpDomain.concat("/sugar-jmeter/execute-test-plan-start"),10 sugarJMeterExecuteTestPlanStop: httpDomain.concat("/sugar-jmeter/execute-test-plan-stop"),11 sugarJMeterSampleEventWS: wsDomain.concat("/sample-event-websocket"),12 sugarJMXSave: httpDomain.concat("/sugar-test-plan/save"),13 sugarJMXQuery: httpDomain.concat("/sugar-test-plan/query"),14 sugarJMXUpdate: httpDomain.concat("/sugar-test-plan/update"),15 sugarJMXDelete: httpDomain.concat("/sugar-test-plan/delete"),16 sugarJMXExecute: httpDomain.concat("/sugar-test-plan/execute"),17 sugarJMXFetch: httpDomain.concat("/sugar-test-plan/fetch-test-plans"),18 sugarAccountSingUp: httpDomain.concat("/sugar-account/signUp"),19 sugarAccountSignIn: httpDomain.concat("/sugar-account/signIn"),20 sugarAccountList: httpDomain.concat("/sugar-account/all"),21 sugarProjectList: httpDomain.concat("/sugar-project/query"),22 sugarProjectSave: httpDomain.concat("/sugar-project/save"),23 sugarProjectUpdate: httpDomain.concat("/sugar-project/update"),24 sugarProjectDelete: httpDomain.concat("/sugar-project/delete"),25 sugarProjectFetch: httpDomain.concat("/sugar-project/fetch"),26 sugarReportList: httpDomain.concat("/sugar-report/query"),27 sugarReportDelete: httpDomain.concat("/sugar-report/delete"),28 sugarReportFetch: httpDomain.concat("/sugar-report/fetchReport"),29 sugarFileUpload: httpDomain.concat("/sugar-file/upload"),30 sugarFileQuery: httpDomain.concat("/sugar-file/query"),31 sugarFileDelete: httpDomain.concat("/sugar-file/delete"),32 sugarFileUpdate: httpDomain.concat("/sugar-file/update"),33 sugarTaskSave: httpDomain.concat("/sugar-task/save"),34 sugarTaskQuery: httpDomain.concat("/sugar-task/query"),35 sugarTaskFetch: httpDomain.concat("/sugar-task/fetch"),36 sugarTaskUpdate: httpDomain.concat("/sugar-task/update"),37 sugarTaskDelete: httpDomain.concat("/sugar-task/delete"),38 sugarTaskEnable: httpDomain.concat("/sugar-task/enable"),39 sugarTaskDisable: httpDomain.concat("/sugar-task/disable"),40 sugarTestPlanFileUpload: httpDomain.concat("/sugar-test-file/upload"),...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const element = await page.$('text=Get started');7 await element.click();8 await page.screenshot({ path: 'example.png' });9 await browser.close();10})();11![Example screenshot](./example.png)
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.fill('input[title="Search"]', 'Playwright');7 await page.click('text=Google Search');8 await page.waitForSelector('text=Playwright - Google Search');9 await page.click('text=Playwright - Google Search');10 await page.waitForSelector('text=Playwright');11 await page.click('text=Playwright');12 await page.waitForSelector('text=Playwright: End-to-end testing for modern web apps');13 await page.click('text=Playwright: End-to-end testing for modern web apps');14 const [page1] = await Promise.all([15 context.waitForEvent('page'),16 page.click('text=Get started'),17 ]);18 await page1.waitForSelector('text=Playwright');19 await page1.click('text=Playwright');20 await page1.waitForSelector('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');21 await page1.click('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');22 await page1.waitForSelector('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');23 await page1.click('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');24 await page1.waitForSelector('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');25 await page1.click('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');26 await page1.waitForSelector('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');27 await page1.click('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');28 await page1.waitForSelector('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');29 await page1.click('text=Playwright is a Node library to automate Chromium, Firefox and WebKit with a single API');
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: `example.png` });6 await browser.close();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 const page = await browser.newPage();12 await page.screenshot({ path: `example.png` });13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const page = await browser.newPage();19 await page.screenshot({ path: `example.png` });20 await browser.close();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch();25 const page = await browser.newPage();26 await page.screenshot({ path: `example.png` });27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const page = await browser.newPage();33 await page.screenshot({ path: `example.png` });34 await browser.close();35})();36const { chromium } = require('playwright');37(async () => {38 const browser = await chromium.launch();39 const page = await browser.newPage();40 await page.screenshot({ path: `example.png` });41 await browser.close();42})();43const { chromium } = require('playwright');44(async () => {45 const browser = await chromium.launch();
Using AI Code Generation
1const { chromium } = require('playwright');2const { concat } = require('playwright/lib/utils/stackTrace');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();10const { chromium } = require('playwright');11const { concat } = require('playwright/lib/utils/stackTrace');12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 await page.screenshot({ path: `example.png` });17 await browser.close();18})();19const { chromium } = require('playwright');20const { concat } = require('playwright/lib/utils/stackTrace');21(async () => {22 const browser = await chromium.launch();23 const context = await browser.newContext();24 const page = await context.newPage();25 await page.screenshot({ path: `example.png` });26 await browser.close();27})();28const { chromium } = require('playwright');29const { concat } = require('playwright/lib/utils/stackTrace');30(async () => {31 const browser = await chromium.launch();32 const context = await browser.newContext();33 const page = await context.newPage();34 await page.screenshot({ path: `example.png` });35 await browser.close();36})();37const { chromium } = require('playwright');38const { concat } = require('playwright/lib/utils/stackTrace');39(async () => {40 const browser = await chromium.launch();41 const context = await browser.newContext();42 const page = await context.newPage();43 await page.screenshot({ path: `example.png` });44 await browser.close();45})();
Using AI Code Generation
1const { test, expect } = require('@playwright/test');2test('My test', async ({ page }) => {3 const title = page.locator('text=Get started');4 await expect(title).toHaveText('Get started');5});6const { test, expect } = require('@playwright/test');7test('My test', async ({ page }) => {8 const title = page.locator('text=Get started');9 await title.waitForElementState('attached');10 await expect(title).toHaveText('Get started');11});12const { test, expect } = require('@playwright/test');13test('My test', async ({ page }) => {14 const title = page.locator('text=Get started');15 await title.waitForSelector();16 await expect(title).toHaveText('Get started');17});
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const internalPage = page._delegate;6 const result = await internalPage.concat('Hello', 'World');7 console.log(result);8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const page = await browser.newPage();14 const result = await page.concat('Hello', 'World');15 console.log(result);16 await browser.close();17})();18const { chromium } = require('playwright');19(async () => {20 const browser = await chromium.launch();21 const page = await browser.newPage();22 const elementHandle = await page.$('text=Get started');23 const result = await elementHandle.concat('Hello', 'World');24 console.log(result);25 await browser.close();26})();27const { chromium } = require('playwright');28(async () => {29 const browser = await chromium.launch();30 const page = await browser.newPage();31 const jsHandle = await page.evaluateHandle(() => {32 return {33 };34 });35 const result = await jsHandle.concat('Hello', 'World');36 console.log(result);37 await browser.close();38})();39const { chromium } = require('playwright');40(async () => {41 const browser = await chromium.launch();42 const page = await browser.newPage();43 const jsHandle = await page.evaluateHandle(() => {44 return {45 };46 });47 const result = await jsHandle.concat('Hello', 'World');48 console.log(result);49 await browser.close();50})();51const { chromium } = require('playwright');52(async () => {53 const browser = await chromium.launch();54 const page = await browser.newPage();55 const frame = page.mainFrame();56 const result = await frame.concat('Hello', 'World');57 console.log(result);
Using AI Code Generation
1const { concat } = require('@playwright/test');2const { test } = require('@playwright/test');3test('basic test', async ({ page }) => {4 const title = page.locator('text=Get started');5 await title.click();6 await page.screenshot({ path: concat('screenshots/', 'example.png') });7});8const { test } = require('@playwright/test');9test('basic test', async ({ page }) => {10 const title = page.locator('text=Get started');11 await title.click();12 await page.screenshot({ path: concat('screenshots/', 'example.png') });13});14const { test, expect } = require('@playwright/test');15test('basic test', async ({ page }) => {16 const title = page.locator('text=Get started');17 await title.click();18});19const { test, expect } = require('@playwright/test');20test('basic test', async ({ page }) => {21 const title = page.locator('text=Get started');22 await title.click();23});
Using AI Code Generation
1const { concat } = require('playwright/lib/utils/utils');2const { concat } = require('playwright/lib/utils/utils');3console.log(concat('Hello','World'));4const { concat } = require('playwright/lib/utils/utils');5console.log(concat('Hello','World'));6const { click, goto, text, textBox, write, closeBrowser } = require('playwright-helpers');7(async () => {8 await click('Login');9 await write('
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!