Best JavaScript code snippet using wpt
encoding.js
Source:encoding.js
1QUnit.module('cookie-value', lifecycle);2QUnit.test('cookie-value with double quotes', function (assert) {3 assert.expect(1);4 using(assert)5 .setCookie('c', '"')6 .then(function (decodedValue) {7 assert.strictEqual(decodedValue, '"', 'should print the quote character');8 });9});10QUnit.test('cookie-value with double quotes in the left', function (assert) {11 assert.expect(1);12 using(assert)13 .setCookie('c', '"content')14 .then(function (decodedValue) {15 assert.strictEqual(decodedValue, '"content', 'should print the quote character');16 });17});18QUnit.test('cookie-value with double quotes in the right', function (assert) {19 assert.expect(1);20 using(assert)21 .setCookie('c', 'content"')22 .then(function (decodedValue) {23 assert.strictEqual(decodedValue, 'content"', 'should print the quote character');24 });25});26QUnit.test('RFC 6265 - character not allowed in the cookie-value " "', function (assert) {27 assert.expect(2);28 using(assert)29 .setCookie('c', ' ')30 .then(function (decodedValue, plainValue) {31 assert.strictEqual(decodedValue, ' ', 'should handle the whitespace character');32 assert.strictEqual(plainValue, 'c=%20', 'whitespace is not allowed, need to encode');33 });34});35QUnit.test('RFC 6265 - character not allowed in the cookie-value ","', function (assert) {36 assert.expect(2);37 using(assert)38 .setCookie('c', ',')39 .then(function (decodedValue, plainValue) {40 assert.strictEqual(decodedValue, ',', 'should handle the comma character');41 assert.strictEqual(plainValue, 'c=%2C', 'comma is not allowed, need to encode');42 });43});44QUnit.test('RFC 6265 - character not allowed in the cookie-value ";"', function (assert) {45 assert.expect(2);46 using(assert)47 .setCookie('c', ';')48 .then(function (decodedValue, plainValue) {49 assert.strictEqual(decodedValue, ';', 'should handle the semicolon character');50 assert.strictEqual(plainValue, 'c=%3B', 'semicolon is not allowed, need to encode');51 });52});53QUnit.test('RFC 6265 - character not allowed in the cookie-value "\\"', function (assert) {54 assert.expect(2);55 using(assert)56 .setCookie('c', '\\')57 .then(function (decodedValue, plainValue) {58 assert.strictEqual(decodedValue, '\\', 'should handle the backslash character');59 assert.strictEqual(plainValue, 'c=%5C', 'backslash is not allowed, need to encode');60 });61});62QUnit.test('RFC 6265 - characters not allowed in the cookie-value should be replaced globally', function (assert) {63 assert.expect(2);64 using(assert)65 .setCookie('c', ';;')66 .then(function (decodedValue, plainValue) {67 assert.strictEqual(decodedValue, ';;', 'should handle multiple not allowed characters');68 assert.strictEqual(plainValue, 'c=%3B%3B', 'should replace multiple not allowed characters');69 });70});71QUnit.test('RFC 6265 - character allowed in the cookie-value "#"', function (assert) {72 assert.expect(2);73 using(assert)74 .setCookie('c', '#')75 .then(function (decodedValue, plainValue) {76 assert.strictEqual(decodedValue, '#', 'should handle the sharp character');77 assert.strictEqual(plainValue, 'c=#', 'sharp is allowed, should not encode');78 });79});80QUnit.test('RFC 6265 - character allowed in the cookie-value "$"', function (assert) {81 assert.expect(2);82 using(assert)83 .setCookie('c', '$')84 .then(function (decodedValue, plainValue) {85 assert.strictEqual(decodedValue, '$', 'should handle the dollar sign character');86 assert.strictEqual(plainValue, 'c=$', 'dollar sign is allowed, should not encode');87 });88});89QUnit.test('RFC 6265 - character allowed in the cookie-value "%"', function (assert) {90 assert.expect(2);91 using(assert)92 .setCookie('c', '%')93 .then(function (decodedValue, plainValue) {94 assert.strictEqual(decodedValue, '%', 'should handle the percent character');95 assert.strictEqual(plainValue, 'c=%25', 'percent is allowed, but need to be escaped');96 });97});98QUnit.test('RFC 6265 - character allowed in the cookie-value "&"', function (assert) {99 assert.expect(2);100 using(assert)101 .setCookie('c', '&')102 .then(function (decodedValue, plainValue) {103 assert.strictEqual(decodedValue, '&', 'should handle the ampersand character');104 assert.strictEqual(plainValue, 'c=&', 'ampersand is allowed, should not encode');105 });106});107// github.com/carhartl/jquery-cookie/pull/62108QUnit.test('RFC 6265 - character allowed in the cookie-value "+"', function (assert) {109 assert.expect(2);110 using(assert)111 .setCookie('c', '+')112 .then(function (decodedValue, plainValue) {113 assert.strictEqual(decodedValue, '+', 'should handle the plus character');114 assert.strictEqual(plainValue, 'c=+', 'plus is allowed, should not encode');115 });116});117QUnit.test('RFC 6265 - character allowed in the cookie-value ":"', function (assert) {118 assert.expect(2);119 using(assert)120 .setCookie('c', ':')121 .then(function (decodedValue, plainValue) {122 assert.strictEqual(decodedValue, ':', 'should handle the colon character');123 assert.strictEqual(plainValue, 'c=:', 'colon is allowed, should not encode');124 });125});126QUnit.test('RFC 6265 - character allowed in the cookie-value "<"', function (assert) {127 assert.expect(2);128 using(assert)129 .setCookie('c', '<')130 .then(function (decodedValue, plainValue) {131 assert.strictEqual(decodedValue, '<', 'should handle the less-than character');132 assert.strictEqual(plainValue, 'c=<', 'less-than is allowed, should not encode');133 });134});135QUnit.test('RFC 6265 - character allowed in the cookie-value ">"', function (assert) {136 assert.expect(2);137 using(assert)138 .setCookie('c', '>')139 .then(function (decodedValue, plainValue) {140 assert.strictEqual(decodedValue, '>', 'should handle the greater-than character');141 assert.strictEqual(plainValue, 'c=>', 'greater-than is allowed, should not encode');142 });143});144QUnit.test('RFC 6265 - character allowed in the cookie-value "="', function (assert) {145 assert.expect(2);146 using(assert)147 .setCookie('c', '=')148 .then(function (decodedValue, plainValue) {149 assert.strictEqual(decodedValue, '=', 'should handle the equal sign character');150 assert.strictEqual(plainValue, 'c==', 'equal sign is allowed, should not encode');151 });152});153QUnit.test('RFC 6265 - character allowed in the cookie-value "/"', function (assert) {154 assert.expect(2);155 using(assert)156 .setCookie('c', '/')157 .then(function (decodedValue, plainValue) {158 assert.strictEqual(decodedValue, '/', 'should handle the slash character');159 assert.strictEqual(plainValue, 'c=/', 'slash is allowed, should not encode');160 });161});162QUnit.test('RFC 6265 - character allowed in the cookie-value "?"', function (assert) {163 assert.expect(2);164 using(assert)165 .setCookie('c', '?')166 .then(function (decodedValue, plainValue) {167 assert.strictEqual(decodedValue, '?', 'should handle the question mark character');168 assert.strictEqual(plainValue, 'c=?', 'question mark is allowed, should not encode');169 });170});171QUnit.test('RFC 6265 - character allowed in the cookie-value "@"', function (assert) {172 assert.expect(2);173 using(assert)174 .setCookie('c', '@')175 .then(function (decodedValue, plainValue) {176 assert.strictEqual(decodedValue, '@', 'should handle the at character');177 assert.strictEqual(plainValue, 'c=@', 'at is allowed, should not encode');178 });179});180QUnit.test('RFC 6265 - character allowed in the cookie-value "["', function (assert) {181 assert.expect(2);182 using(assert)183 .setCookie('c', '[')184 .then(function (decodedValue, plainValue) {185 assert.strictEqual(decodedValue, '[', 'should handle the opening square bracket character');186 assert.strictEqual(plainValue, 'c=[', 'opening square bracket is allowed, should not encode');187 });188});189QUnit.test('RFC 6265 - character allowed in the cookie-value "]"', function (assert) {190 assert.expect(2);191 using(assert)192 .setCookie('c', ']')193 .then(function (decodedValue, plainValue) {194 assert.strictEqual(decodedValue, ']', 'should handle the closing square bracket character');195 assert.strictEqual(plainValue, 'c=]', 'closing square bracket is allowed, should not encode');196 });197});198QUnit.test('RFC 6265 - character allowed in the cookie-value "^"', function (assert) {199 assert.expect(2);200 using(assert)201 .setCookie('c', '^')202 .then(function (decodedValue, plainValue) {203 assert.strictEqual(decodedValue, '^', 'should handle the caret character');204 assert.strictEqual(plainValue, 'c=^', 'caret is allowed, should not encode');205 });206});207QUnit.test('RFC 6265 - character allowed in the cookie-value "`"', function (assert) {208 assert.expect(2);209 using(assert)210 .setCookie('c', '`')211 .then(function (decodedValue, plainValue) {212 assert.strictEqual(decodedValue, '`', 'should handle the grave accent character');213 assert.strictEqual(plainValue, 'c=`', 'grave accent is allowed, should not encode');214 });215});216QUnit.test('RFC 6265 - character allowed in the cookie-value "{"', function (assert) {217 assert.expect(2);218 using(assert)219 .setCookie('c', '{')220 .then(function (decodedValue, plainValue) {221 assert.strictEqual(decodedValue, '{', 'should handle the opening curly bracket character');222 assert.strictEqual(plainValue, 'c={', 'opening curly bracket is allowed, should not encode');223 });224});225QUnit.test('RFC 6265 - character allowed in the cookie-value "}"', function (assert) {226 assert.expect(2);227 using(assert)228 .setCookie('c', '}')229 .then(function (decodedValue, plainValue) {230 assert.strictEqual(decodedValue, '}', 'should handle the closing curly bracket character');231 assert.strictEqual(plainValue, 'c=}', 'closing curly bracket is allowed, should not encode');232 });233});234QUnit.test('RFC 6265 - character allowed in the cookie-value "|"', function (assert) {235 assert.expect(2);236 using(assert)237 .setCookie('c', '|')238 .then(function (decodedValue, plainValue) {239 assert.strictEqual(decodedValue, '|', 'should handle the pipe character');240 assert.strictEqual(plainValue, 'c=|', 'pipe is allowed, should not encode');241 });242});243QUnit.test('RFC 6265 - characters allowed in the cookie-value should globally not be encoded', function (assert) {244 assert.expect(1);245 using(assert)246 .setCookie('c', '{{')247 .then(function (decodedValue, plainValue) {248 assert.strictEqual(plainValue, 'c={{', 'should not encode all the character occurrences');249 });250});251QUnit.test('cookie-value - 2 bytes character (ã)', function (assert) {252 assert.expect(2);253 using(assert)254 .setCookie('c', 'ã')255 .then(function (decodedValue, plainValue) {256 assert.strictEqual(decodedValue, 'ã', 'should handle the ã character');257 assert.strictEqual(plainValue, 'c=%C3%A3', 'should encode the ã character');258 });259});260QUnit.test('cookie-value - 3 bytes character (â¯)', function (assert) {261 assert.expect(2);262 using(assert)263 .setCookie('c', 'â¯')264 .then(function (decodedValue, plainValue) {265 assert.strictEqual(decodedValue, 'â¯', 'should handle the ⯠character');266 assert.strictEqual(plainValue, 'c=%E2%82%AF', 'should encode the ⯠character');267 });268});269QUnit.test('cookie-value - 4 bytes character (𩸽)', function (assert) {270 assert.expect(2);271 using(assert)272 .setCookie('c', '𩸽')273 .then(function (decodedValue, plainValue) {274 assert.strictEqual(decodedValue, '𩸽', 'should handle the 𩸽 character');275 assert.strictEqual(plainValue, 'c=%F0%A9%B8%BD', 'should encode the 𩸽 character');276 });277});278QUnit.module('cookie-name', lifecycle);279QUnit.test('RFC 6265 - character not allowed in the cookie-name "("', function (assert) {280 assert.expect(2);281 using(assert)282 .setCookie('(', 'v')283 .then(function (decodedValue, plainValue) {284 assert.strictEqual(decodedValue, 'v', 'should handle the opening parens character');285 assert.strictEqual(plainValue, '%28=v', 'opening parens is not allowed, need to encode');286 });287});288QUnit.test('RFC 6265 - character not allowed in the cookie-name ")"', function (assert) {289 assert.expect(2);290 using(assert)291 .setCookie(')', 'v')292 .then(function (decodedValue, plainValue) {293 assert.strictEqual(decodedValue, 'v', 'should handle the closing parens character');294 assert.strictEqual(plainValue, '%29=v', 'closing parens is not allowed, need to encode');295 });296});297QUnit.test('RFC 6265 - should replace parens globally', function (assert) {298 assert.expect(1);299 using(assert)300 .setCookie('(())', 'v')301 .then(function (decodedValue, plainValue) {302 assert.strictEqual(plainValue, '%28%28%29%29=v', 'encode with global replace');303 });304});305QUnit.test('RFC 6265 - character not allowed in the cookie-name "<"', function (assert) {306 assert.expect(2);307 using(assert)308 .setCookie('<', 'v')309 .then(function (decodedValue, plainValue) {310 assert.strictEqual(decodedValue, 'v', 'should handle the less-than character');311 assert.strictEqual(plainValue, '%3C=v', 'less-than is not allowed, need to encode');312 });313});314QUnit.test('RFC 6265 - character not allowed in the cookie-name ">"', function (assert) {315 assert.expect(2);316 using(assert)317 .setCookie('>', 'v')318 .then(function (decodedValue, plainValue) {319 assert.strictEqual(decodedValue, 'v', 'should handle the greater-than character');320 assert.strictEqual(plainValue, '%3E=v', 'greater-than is not allowed, need to encode');321 });322});323QUnit.test('RFC 6265 - character not allowed in the cookie-name "@"', function (assert) {324 assert.expect(2);325 using(assert)326 .setCookie('@', 'v')327 .then(function (decodedValue, plainValue) {328 assert.strictEqual(decodedValue, 'v', 'should handle the at character');329 assert.strictEqual(plainValue, '%40=v', 'at is not allowed, need to encode');330 });331});332QUnit.test('RFC 6265 - character not allowed in the cookie-name ","', function (assert) {333 assert.expect(2);334 using(assert)335 .setCookie(',', 'v')336 .then(function (decodedValue, plainValue) {337 assert.strictEqual(decodedValue, 'v', 'should handle the comma character');338 assert.strictEqual(plainValue, '%2C=v', 'comma is not allowed, need to encode');339 });340});341QUnit.test('RFC 6265 - character not allowed in the cookie-name ";"', function (assert) {342 assert.expect(2);343 using(assert)344 .setCookie(';', 'v')345 .then(function (decodedValue, plainValue) {346 assert.strictEqual(decodedValue, 'v', 'should handle the semicolon character');347 assert.strictEqual(plainValue, '%3B=v', 'semicolon is not allowed, need to encode');348 });349});350QUnit.test('RFC 6265 - character not allowed in the cookie-name ":"', function (assert) {351 assert.expect(2);352 using(assert)353 .setCookie(':', 'v')354 .then(function (decodedValue, plainValue) {355 assert.strictEqual(decodedValue, 'v', 'should handle the colon character');356 assert.strictEqual(plainValue, '%3A=v', 'colon is not allowed, need to encode');357 });358});359QUnit.test('RFC 6265 - character not allowed in the cookie-name "\\"', function (assert) {360 assert.expect(2);361 using(assert)362 .setCookie('\\', 'v')363 .then(function (decodedValue, plainValue) {364 assert.strictEqual(decodedValue, 'v', 'should handle the backslash character');365 assert.strictEqual(plainValue, '%5C=v', 'backslash is not allowed, need to encode');366 });367});368QUnit.test('RFC 6265 - character not allowed in the cookie-name "\""', function (assert) {369 assert.expect(2);370 using(assert)371 .setCookie('"', 'v')372 .then(function (decodedValue, plainValue) {373 assert.strictEqual(decodedValue, 'v', 'should handle the double quote character');374 assert.strictEqual(plainValue, '%22=v', 'double quote is not allowed, need to encode');375 });376});377QUnit.test('RFC 6265 - character not allowed in the cookie-name "/"', function (assert) {378 assert.expect(2);379 using(assert)380 .setCookie('/', 'v')381 .then(function (decodedValue, plainValue) {382 assert.strictEqual(decodedValue, 'v', 'should handle the slash character');383 assert.strictEqual(plainValue, '%2F=v', 'slash is not allowed, need to encode');384 });385});386QUnit.test('RFC 6265 - character not allowed in the cookie-name "["', function (assert) {387 assert.expect(2);388 using(assert)389 .setCookie('[', 'v')390 .then(function (decodedValue, plainValue) {391 assert.strictEqual(decodedValue, 'v', 'should handle the opening square brackets character');392 assert.strictEqual(plainValue, '%5B=v', 'opening square brackets is not allowed, need to encode');393 });394});395QUnit.test('RFC 6265 - character not allowed in the cookie-name "]"', function (assert) {396 assert.expect(2);397 using(assert)398 .setCookie(']', 'v')399 .then(function (decodedValue, plainValue) {400 assert.strictEqual(decodedValue, 'v', 'should handle the closing square brackets character');401 assert.strictEqual(plainValue, '%5D=v', 'closing square brackets is not allowed, need to encode');402 });403});404QUnit.test('RFC 6265 - character not allowed in the cookie-name "?"', function (assert) {405 assert.expect(2);406 using(assert)407 .setCookie('?', 'v')408 .then(function (decodedValue, plainValue) {409 assert.strictEqual(decodedValue, 'v', 'should handle the question mark character');410 assert.strictEqual(plainValue, '%3F=v', 'question mark is not allowed, need to encode');411 });412});413QUnit.test('RFC 6265 - character not allowed in the cookie-name "="', function (assert) {414 assert.expect(2);415 using(assert)416 .setCookie('=', 'v')417 .then(function (decodedValue, plainValue) {418 assert.strictEqual(decodedValue, 'v', 'should handle the equal sign character');419 assert.strictEqual(plainValue, '%3D=v', 'equal sign is not allowed, need to encode');420 });421});422QUnit.test('RFC 6265 - character not allowed in the cookie-name "{"', function (assert) {423 assert.expect(2);424 using(assert)425 .setCookie('{', 'v')426 .then(function (decodedValue, plainValue) {427 assert.strictEqual(decodedValue, 'v', 'should handle the opening curly brackets character');428 assert.strictEqual(plainValue, '%7B=v', 'opening curly brackets is not allowed, need to encode');429 });430});431QUnit.test('RFC 6265 - character not allowed in the cookie-name "}"', function (assert) {432 assert.expect(2);433 using(assert)434 .setCookie('}', 'v')435 .then(function (decodedValue, plainValue) {436 assert.strictEqual(decodedValue, 'v', 'should handle the closing curly brackets character');437 assert.strictEqual(plainValue, '%7D=v', 'closing curly brackets is not allowed, need to encode');438 });439});440QUnit.test('RFC 6265 - character not allowed in the cookie-name "\\t"', function (assert) {441 assert.expect(2);442 using(assert)443 .setCookie(' ', 'v')444 .then(function (decodedValue, plainValue) {445 assert.strictEqual(decodedValue, 'v', 'should handle the horizontal tab character');446 assert.strictEqual(plainValue, '%09=v', 'horizontal tab is not allowed, need to encode');447 });448});449QUnit.test('RFC 6265 - character not allowed in the cookie-name " "', function (assert) {450 assert.expect(2);451 using(assert)452 .setCookie(' ', 'v')453 .then(function (decodedValue, plainValue) {454 assert.strictEqual(decodedValue, 'v', 'should handle the whitespace character');455 assert.strictEqual(plainValue, '%20=v', 'whitespace is not allowed, need to encode');456 });457});458QUnit.test('RFC 6265 - character allowed in the cookie-name "#"', function (assert) {459 assert.expect(2);460 using(assert)461 .setCookie('#', 'v')462 .then(function (decodedValue, plainValue) {463 assert.strictEqual(decodedValue, 'v', 'should handle the sharp character');464 assert.strictEqual(plainValue, '#=v', 'sharp is allowed, should not encode');465 });466});467QUnit.test('RFC 6265 - character allowed in the cookie-name "$"', function (assert) {468 assert.expect(2);469 using(assert)470 .setCookie('$', 'v')471 .then(function (decodedValue, plainValue) {472 assert.strictEqual(decodedValue, 'v', 'should handle the dollar sign character');473 assert.strictEqual(plainValue, '$=v', 'dollar sign is allowed, should not encode');474 });475});476QUnit.test('RFC 6265 - character allowed in cookie-name "%"', function (assert) {477 assert.expect(2);478 using(assert)479 .setCookie('%', 'v')480 .then(function (decodedValue, plainValue) {481 assert.strictEqual(decodedValue, 'v', 'should handle the percent character');482 assert.strictEqual(plainValue, '%25=v', 'percent is allowed, but need to be escaped');483 });484});485QUnit.test('RFC 6265 - character allowed in the cookie-name "&"', function (assert) {486 assert.expect(2);487 using(assert)488 .setCookie('&', 'v')489 .then(function (decodedValue, plainValue) {490 assert.strictEqual(decodedValue, 'v', 'should handle the ampersand character');491 assert.strictEqual(plainValue, '&=v', 'ampersand is allowed, should not encode');492 });493});494QUnit.test('RFC 6265 - character allowed in the cookie-name "+"', function (assert) {495 assert.expect(2);496 using(assert)497 .setCookie('+', 'v')498 .then(function (decodedValue, plainValue) {499 assert.strictEqual(decodedValue, 'v', 'should handle the plus character');500 assert.strictEqual(plainValue, '+=v', 'plus is allowed, should not encode');501 });502});503QUnit.test('RFC 6265 - character allowed in the cookie-name "^"', function (assert) {504 assert.expect(2);505 using(assert)506 .setCookie('^', 'v')507 .then(function (decodedValue, plainValue) {508 assert.strictEqual(decodedValue, 'v', 'should handle the caret character');509 assert.strictEqual(plainValue, '^=v', 'caret is allowed, should not encode');510 });511});512QUnit.test('RFC 6265 - character allowed in the cookie-name "`"', function (assert) {513 assert.expect(2);514 using(assert)515 .setCookie('`', 'v')516 .then(function (decodedValue, plainValue) {517 assert.strictEqual(decodedValue, 'v', 'should handle the grave accent character');518 assert.strictEqual(plainValue, '`=v', 'grave accent is allowed, should not encode');519 });520});521QUnit.test('RFC 6265 - character allowed in the cookie-name "|"', function (assert) {522 assert.expect(2);523 using(assert)524 .setCookie('|', 'v')525 .then(function (decodedValue, plainValue) {526 assert.strictEqual(decodedValue, 'v', 'should handle the pipe character');527 assert.strictEqual(plainValue, '|=v', 'pipe is allowed, should not encode');528 });529});530QUnit.test('RFC 6265 - characters allowed in the cookie-name should globally not be encoded', function (assert) {531 assert.expect(1);532 using(assert)533 .setCookie('||', 'v')534 .then(function (decodedValue, plainValue) {535 assert.strictEqual(plainValue, '||=v', 'should not encode all character occurrences');536 });537});538QUnit.test('cookie-name - 2 bytes characters', function (assert) {539 assert.expect(2);540 using(assert)541 .setCookie('ã', 'v')542 .then(function (decodedValue, plainValue) {543 assert.strictEqual(decodedValue, 'v', 'should handle the ã character');544 assert.strictEqual(plainValue, '%C3%A3=v', 'should encode the ã character');545 });546});547QUnit.test('cookie-name - 3 bytes characters', function (assert) {548 assert.expect(2);549 using(assert)550 .setCookie('â¯', 'v')551 .then(function (decodedValue, plainValue) {552 assert.strictEqual(decodedValue, 'v', 'should handle the ⯠character');553 assert.strictEqual(plainValue, '%E2%82%AF=v', 'should encode the ⯠character');554 });555});556QUnit.test('cookie-name - 4 bytes characters', function (assert) {557 assert.expect(2);558 using(assert)559 .setCookie('𩸽', 'v')560 .then(function (decodedValue, plainValue) {561 assert.strictEqual(decodedValue, 'v', 'should_handle the 𩸽 character');562 assert.strictEqual(plainValue, '%F0%A9%B8%BD=v', 'should encode the 𩸽 character');563 });...
storageDecoder.js
Source:storageDecoder.js
1'use strict'2var tape = require('tape')3var compiler = require('solc')4var stateDecoder = require('../../src/solidity-decoder/stateDecoder')5var MockStorageResolver = require('./mockStorageResolver')6var remixLib = require('remix-lib')7var compilerInput = remixLib.helpers.compiler.compilerInput8var testMappingStorage = require('./stateTests/mapping')9tape('solidity', function (t) {10 t.test('storage decoder', function (st) {11 testIntStorage(st, function () {12 testByteStorage(st, function () {13 testStructArrayStorage(st, function () {14 testMappingStorage(st, function () {15 st.end()16 })17 })18 })19 })20 })21})22function testIntStorage (st, cb) {23 var intStorage = require('./contracts/intStorage')24 var output = compiler.compile(compilerInput(intStorage.contract))25 output = JSON.parse(output)26 var mockStorageResolver27 for (var storage of [intStorage.fullStorage, shrinkStorage(intStorage.fullStorage)]) {28 mockStorageResolver = new MockStorageResolver(storage)29 stateDecoder.solidityState(mockStorageResolver, output.sources, 'intStorage').then((decoded) => {30 st.equal(decoded['ui8'].value, '130')31 st.equal(decoded['ui16'].value, '456')32 st.equal(decoded['ui32'].value, '4356')33 st.equal(decoded['ui64'].value, '3543543543')34 st.equal(decoded['ui128'].value, '234567')35 st.equal(decoded['ui256'].value, '115792089237316195423570985008687907853269984665640564039457584007880697216513')36 st.equal(decoded['ui'].value, '123545666')37 st.equal(decoded['i8'].value, '-45')38 st.equal(decoded['i16'].value, '-1234')39 st.equal(decoded['i32'].value, '3455')40 st.equal(decoded['i64'].value, '-35566')41 st.equal(decoded['i128'].value, '-444444')42 st.equal(decoded['i256'].value, '3434343')43 st.equal(decoded['i'].value, '-32432423423')44 st.equal(decoded['ishrink'].value, '2')45 })46 }47 mockStorageResolver = new MockStorageResolver({})48 stateDecoder.solidityState(mockStorageResolver, output.sources, 'intStorage').then((decoded) => {49 st.equal(decoded['ui8'].value, '0')50 st.equal(decoded['ui16'].value, '0')51 st.equal(decoded['ui32'].value, '0')52 st.equal(decoded['ui64'].value, '0')53 st.equal(decoded['ui128'].value, '0')54 st.equal(decoded['ui256'].value, '0')55 st.equal(decoded['ui'].value, '0')56 st.equal(decoded['i8'].value, '0')57 st.equal(decoded['i16'].value, '0')58 st.equal(decoded['i32'].value, '0')59 st.equal(decoded['i64'].value, '0')60 st.equal(decoded['i128'].value, '0')61 st.equal(decoded['i256'].value, '0')62 st.equal(decoded['i'].value, '0')63 st.equal(decoded['ishrink'].value, '0')64 cb()65 })66}67function testByteStorage (st, cb) {68 var byteStorage = require('./contracts/byteStorage')69 var output = compiler.compile(compilerInput(byteStorage.contract))70 output = JSON.parse(output)71 var mockStorageResolver72 for (var storage of [byteStorage.storage, shrinkStorage(byteStorage.storage)]) {73 mockStorageResolver = new MockStorageResolver(storage)74 stateDecoder.solidityState(mockStorageResolver, output.sources, 'byteStorage').then((decoded) => {75 st.equal(decoded['b1'].value, false)76 st.equal(decoded['a1'].value, '0xFE350F199F244AC9A79038D254400B632A633225')77 st.equal(decoded['b2'].value, true)78 st.equal(decoded['dynb1'].value, '0x64796e616d69636279746573')79 st.equal(decoded['dynb1'].length, '0xc')80 st.equal(decoded['stab'].value, '0x01')81 st.equal(decoded['stab1'].value, '0x12')82 st.equal(decoded['stab2'].value, '0x1579')83 st.equal(decoded['stab3'].value, '0x359356')84 st.equal(decoded['stab4'].value, '0x23750000')85 st.equal(decoded['stab5'].value, '0x0235764500')86 st.equal(decoded['stab6'].value, '0x324435000000')87 st.equal(decoded['stab7'].value, '0x00432400000000')88 st.equal(decoded['stab8'].value, '0x3245546457650000')89 st.equal(decoded['stab9'].value, '0x034345430000000000')90 st.equal(decoded['stab10'].value, '0x04543543654657000000')91 st.equal(decoded['stab11'].value, '0x5435465400000000000000')92 st.equal(decoded['stab12'].value, '0x030000000000000000000000')93 st.equal(decoded['stab13'].value, '0x03243242345435000000000000')94 st.equal(decoded['stab14'].value, '0x3245435435435300000000000000')95 st.equal(decoded['stab15'].value, '0x032454434435000000000000000000')96 st.equal(decoded['stab16'].value, '0x32454354440000000000000000000000')97 st.equal(decoded['stab17'].value, '0x0324543432432432450000000000000000')98 st.equal(decoded['stab18'].value, '0x032453432543543500000000000000000000')99 st.equal(decoded['stab19'].value, '0x03245434354354350000000000000000000000')100 st.equal(decoded['stab20'].value, '0x032454543543AB35000000000000000000000000')101 st.equal(decoded['stab21'].value, '0x324544324234350000000000000000000000000000')102 st.equal(decoded['stab22'].value, '0x324543AEF50000000000000000000000000000000000')103 st.equal(decoded['stab23'].value, '0x3245435FFF000000000000000000000000000000000000')104 st.equal(decoded['stab24'].value, '0x3245435F0000000000000000000000000000000000000000')105 st.equal(decoded['stab25'].value, '0x3245435F000000000000000000000000000000000000000000')106 st.equal(decoded['stab26'].value, '0x3245435F00000000000000000000000000000000000000000000')107 st.equal(decoded['stab27'].value, '0x03245FFFFFFF000000000000000000000000000000000000000000')108 st.equal(decoded['stab28'].value, '0x03241235000000000000000000000000000000000000000000000000')109 st.equal(decoded['stab29'].value, '0x0325213213000000000000000000000000000000000000000000000000')110 st.equal(decoded['stab30'].value, '0x032454352324230000000000000000000000000000000000000000000000')111 st.equal(decoded['stab31'].value, '0x32454351230000000000000000000000000000000000000000000000000000')112 st.equal(decoded['stab32'].value, '0x324324423432543543AB00000000000000000000000000000000000000000000')113 st.equal(decoded['enumDec'].value, 'e240')114 st.equal(decoded['str1'].value, 'short')115 st.equal(decoded['str12'].value, 'ÑеллÑ')116 st.equal(decoded['str2'].value, 'long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long__long')117 })118 }119 mockStorageResolver = new MockStorageResolver({})120 stateDecoder.solidityState(mockStorageResolver, output.sources, 'byteStorage').then((decoded) => {121 st.equal(decoded['b1'].value, false)122 st.equal(decoded['a1'].value, '0x0000000000000000000000000000000000000000')123 st.equal(decoded['b2'].value, false)124 st.equal(decoded['dynb1'].value, '0x')125 st.equal(decoded['dynb1'].length, '0x0')126 st.equal(decoded['stab'].value, '0x00')127 st.equal(decoded['stab1'].value, '0x00')128 st.equal(decoded['stab2'].value, '0x0000')129 st.equal(decoded['stab3'].value, '0x000000')130 st.equal(decoded['stab4'].value, '0x00000000')131 st.equal(decoded['stab5'].value, '0x0000000000')132 st.equal(decoded['stab6'].value, '0x000000000000')133 st.equal(decoded['stab7'].value, '0x00000000000000')134 st.equal(decoded['stab8'].value, '0x0000000000000000')135 st.equal(decoded['stab9'].value, '0x000000000000000000')136 st.equal(decoded['stab10'].value, '0x00000000000000000000')137 st.equal(decoded['stab11'].value, '0x0000000000000000000000')138 st.equal(decoded['stab12'].value, '0x000000000000000000000000')139 st.equal(decoded['stab13'].value, '0x00000000000000000000000000')140 st.equal(decoded['stab14'].value, '0x0000000000000000000000000000')141 st.equal(decoded['stab15'].value, '0x000000000000000000000000000000')142 st.equal(decoded['stab16'].value, '0x00000000000000000000000000000000')143 st.equal(decoded['stab17'].value, '0x0000000000000000000000000000000000')144 st.equal(decoded['stab18'].value, '0x000000000000000000000000000000000000')145 st.equal(decoded['stab19'].value, '0x00000000000000000000000000000000000000')146 st.equal(decoded['stab20'].value, '0x0000000000000000000000000000000000000000')147 st.equal(decoded['stab21'].value, '0x000000000000000000000000000000000000000000')148 st.equal(decoded['stab22'].value, '0x00000000000000000000000000000000000000000000')149 st.equal(decoded['stab23'].value, '0x0000000000000000000000000000000000000000000000')150 st.equal(decoded['stab24'].value, '0x000000000000000000000000000000000000000000000000')151 st.equal(decoded['stab25'].value, '0x00000000000000000000000000000000000000000000000000')152 st.equal(decoded['stab26'].value, '0x0000000000000000000000000000000000000000000000000000')153 st.equal(decoded['stab27'].value, '0x000000000000000000000000000000000000000000000000000000')154 st.equal(decoded['stab28'].value, '0x00000000000000000000000000000000000000000000000000000000')155 st.equal(decoded['stab29'].value, '0x0000000000000000000000000000000000000000000000000000000000')156 st.equal(decoded['stab30'].value, '0x000000000000000000000000000000000000000000000000000000000000')157 st.equal(decoded['stab31'].value, '0x00000000000000000000000000000000000000000000000000000000000000')158 st.equal(decoded['stab32'].value, '0x0000000000000000000000000000000000000000000000000000000000000000')159 st.equal(decoded['enumDec'].value, 'e0')160 st.equal(decoded['str1'].length, '0x0')161 st.equal(decoded['str2'].length, '0x0')162 st.equal(decoded['str1'].value, '')163 st.equal(decoded['str12'].value, '')164 st.equal(decoded['str2'].value, '')165 cb()166 })167}168function shrinkStorage (storage) {169 var shrinkedStorage = {}170 var regex = /0x(00)*(..)/171 for (var key in storage) {172 var value = storage[key]173 shrinkedStorage[key.replace(regex, '0x$2')] = value.replace(regex, '0x$2')174 }175 return shrinkedStorage176}177function testStructArrayStorage (st, cb) {178 var structArrayStorage = require('./contracts/structArrayStorage')179 var output = compiler.compile(compilerInput(structArrayStorage.contract))180 output = JSON.parse(output)181 var mockStorageResolver = new MockStorageResolver(structArrayStorage.storage)182 stateDecoder.solidityState(mockStorageResolver, output.sources, 'structArrayStorage').then((decoded) => {183 st.equal(decoded['intStructDec'].value['i8'].value, '32')184 st.equal(decoded['intStructDec'].value['i16'].value, '-54')185 st.equal(decoded['intStructDec'].value['ui32'].value, '128')186 st.equal(decoded['intStructDec'].value['i256'].value, '-1243565465756')187 st.equal(decoded['intStructDec'].value['ui16'].value, '34556')188 st.equal(decoded['intStructDec'].value['i32'].value, '-345446546')189 st.equal(decoded['i5'].length, '0x7')190 st.equal(decoded['i5'].value[0].value, '-2134')191 st.equal(decoded['i5'].value[1].value, '345')192 st.equal(decoded['i5'].value[2].value, '-3246')193 st.equal(decoded['i5'].value[3].value, '4357')194 st.equal(decoded['i5'].value[4].value, '324')195 st.equal(decoded['i5'].value[5].value, '-2344')196 st.equal(decoded['i5'].value[6].value, '3254')197 st.equal(decoded['idyn5'].length, '0x9')198 st.equal(decoded['idyn5'].value[0].value, '-2134')199 st.equal(decoded['idyn5'].value[1].value, '345')200 st.equal(decoded['idyn5'].value[2].value, '-3246')201 st.equal(decoded['idyn5'].value[3].value, '4357')202 st.equal(decoded['idyn5'].value[4].value, '324')203 st.equal(decoded['idyn5'].value[5].value, '-2344')204 st.equal(decoded['idyn5'].value[6].value, '3254')205 st.equal(decoded['idyn5'].value[7].value, '-254')206 st.equal(decoded['idyn5'].value[8].value, '-2354')207 st.equal(decoded['dyn1'].length, '0x4')208 st.equal(decoded['dyn1'].value[0].length, '0x1')209 st.equal(decoded['dyn1'].value[0].value[0].value, '3')210 st.equal(decoded['dyn1'].value[1].length, '0x3')211 st.equal(decoded['dyn1'].value[1].value[0].value, '12')212 st.equal(decoded['dyn1'].value[1].value[1].value, '-12')213 st.equal(decoded['dyn1'].value[1].value[2].value, '-1234')214 st.equal(decoded['dyn1'].value[2].length, '0xa')215 st.equal(decoded['dyn1'].value[2].value[0].value, '1')216 st.equal(decoded['dyn1'].value[2].value[1].value, '12')217 st.equal(decoded['dyn1'].value[2].value[2].value, '1235')218 st.equal(decoded['dyn1'].value[2].value[3].value, '-12')219 st.equal(decoded['dyn1'].value[2].value[4].value, '-123456')220 st.equal(decoded['dyn1'].value[2].value[5].value, '-23435435')221 st.equal(decoded['dyn1'].value[2].value[6].value, '543543')222 st.equal(decoded['dyn1'].value[2].value[7].value, '2')223 st.equal(decoded['dyn1'].value[2].value[8].value, '-1')224 st.equal(decoded['dyn1'].value[2].value[9].value, '232432')225 st.equal(decoded['dyn1'].value[3].length, '0x2')226 st.equal(decoded['dyn1'].value[3].value[0].value, '232432')227 st.equal(decoded['dyn1'].value[3].value[0].value, '232432')228 st.equal(decoded['dyn2'].length, '0x2')229 st.equal(decoded['dyn2'].value[0].length, '0x4')230 st.equal(decoded['dyn2'].value[0].value[0].value[0].value, '23')231 st.equal(decoded['dyn2'].value[0].value[0].value[1].value, '-23')232 st.equal(decoded['dyn2'].value[0].value[0].value[2].value, '-28')233 st.equal(decoded['dyn2'].value[0].value[1].value[0].value, '23')234 st.equal(decoded['dyn2'].value[0].value[1].value[1].value, '-23')235 st.equal(decoded['dyn2'].value[0].value[1].value[2].value, '-28')236 st.equal(decoded['dyn2'].value[0].value[2].value[0].value, '23')237 st.equal(decoded['dyn2'].value[0].value[2].value[1].value, '-23')238 st.equal(decoded['dyn2'].value[0].value[2].value[2].value, '-28')239 st.equal(decoded['dyn2'].value[0].value[3].value[0].value, '23')240 st.equal(decoded['dyn2'].value[0].value[3].value[1].value, '-23')241 st.equal(decoded['dyn2'].value[0].value[3].value[2].value, '-28')242 st.equal(decoded['dyn2'].value[1].length, '0x4')243 st.equal(decoded['dyn2'].value[1].value[0].value[0].value, '23')244 st.equal(decoded['dyn2'].value[1].value[0].value[1].value, '-23')245 st.equal(decoded['dyn2'].value[1].value[0].value[2].value, '-28')246 st.equal(decoded['dyn2'].value[1].value[1].value[0].value, '23')247 st.equal(decoded['dyn2'].value[1].value[1].value[1].value, '-23')248 st.equal(decoded['dyn2'].value[1].value[1].value[2].value, '-28')249 st.equal(decoded['dyn2'].value[1].value[2].value[0].value, '23')250 st.equal(decoded['dyn2'].value[1].value[2].value[1].value, '-23')251 st.equal(decoded['dyn2'].value[1].value[2].value[2].value, '-28')252 st.equal(decoded['dyn2'].value[1].value[3].value[0].value, '23')253 st.equal(decoded['dyn2'].value[1].value[3].value[1].value, '-23')254 st.equal(decoded['dyn2'].value[1].value[3].value[2].value, '-28')255 st.equal(decoded['arrayStruct'].value[0].value[0].value.i8.value, '34')256 st.equal(decoded['arrayStruct'].value[0].value[0].value.str.value, 'test_str_short')257 st.equal(decoded['arrayStruct'].value[0].value[1].value.i8.value, '-123')258 st.equal(decoded['arrayStruct'].value[0].value[1].value.str.value, 'test_str_long test_str_lo ngtest_str_longtest_str_ longtest_str_longtest_ str_longtest_str_l ongtest_str_long')259 st.equal(decoded['arrayStruct'].value[1].value[0].value.i8.value, '50')260 st.equal(decoded['arrayStruct'].value[1].value[0].value.str.value, 'test_str_short')261 st.equal(decoded['arrayStruct'].value[2].value[0].value.i8.value, '60')262 st.equal(decoded['arrayStruct'].value[2].value[0].value.str.value, 'test_str_short')263 st.equal(decoded['arrayStruct'].value[2].value[1].value.i8.value, '84')264 st.equal(decoded['arrayStruct'].value[2].value[1].value.str.value, 'test_str_long test_str_lo ngtest_str_longtest_str_ longtest_str_longtest_ str_longtest_str_l ongtest_str_long')265 st.equal(decoded['arrayStruct'].value[2].value[2].value.i8.value, '-34')266 st.equal(decoded['arrayStruct'].value[2].value[2].value.str.value, 'test_str_short')267 cb()268 })...
tests.js
Source:tests.js
1(function(root) {2 'use strict';3 var noop = Function.prototype;4 var load = (typeof require == 'function' && !(root.define && define.amd)) ?5 require :6 (!root.document && root.java && root.load) || noop;7 var QUnit = (function() {8 return root.QUnit || (9 root.addEventListener || (root.addEventListener = noop),10 root.setTimeout || (root.setTimeout = noop),11 root.QUnit = load('../node_modules/qunitjs/qunit/qunit.js') || root.QUnit,12 addEventListener === noop && delete root.addEventListener,13 root.QUnit14 );15 }());16 var qe = load('../node_modules/qunit-extras/qunit-extras.js');17 if (qe) {18 qe.runInContext(root);19 }20 /** The `punycode` object to test */21 var punycode = root.punycode || (root.punycode = (22 punycode = load('../punycode.js') || root.punycode,23 punycode = punycode.punycode || punycode24 ));25 // Quick and dirty test to see if weâre in Node or PhantomJS26 var runExtendedTests = (function() {27 try {28 return process.argv[0] == 'node' || root.phantom;29 } catch (exception) { }30 }());31 /** Data that will be used in the tests */32 var allSymbols = runExtendedTests && require('./data.js');33 var testData = {34 'strings': [35 {36 'description': 'a single basic code point',37 'decoded': 'Bach',38 'encoded': 'Bach-'39 },40 {41 'description': 'a single non-ASCII character',42 'decoded': '\xFC',43 'encoded': 'tda'44 },45 {46 'description': 'multiple non-ASCII characters',47 'decoded': '\xFC\xEB\xE4\xF6\u2665',48 'encoded': '4can8av2009b'49 },50 {51 'description': 'mix of ASCII and non-ASCII characters',52 'decoded': 'b\xFCcher',53 'encoded': 'bcher-kva'54 },55 {56 'description': 'long string with both ASCII and non-ASCII characters',57 'decoded': 'Willst du die Bl\xFCthe des fr\xFChen, die Fr\xFCchte des sp\xE4teren Jahres',58 'encoded': 'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'59 },60 // http://tools.ietf.org/html/rfc3492#section-7.161 {62 'description': 'Arabic (Egyptian)',63 'decoded': '\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F',64 'encoded': 'egbpdaj6bu4bxfgehfvwxn'65 },66 {67 'description': 'Chinese (simplified)',68 'decoded': '\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2d\u6587',69 'encoded': 'ihqwcrb4cv8a8dqg056pqjye'70 },71 {72 'description': 'Chinese (traditional)',73 'decoded': '\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587',74 'encoded': 'ihqwctvzc91f659drss3x8bo0yb'75 },76 {77 'description': 'Czech',78 'decoded': 'Pro\u010Dprost\u011Bnemluv\xED\u010Desky',79 'encoded': 'Proprostnemluvesky-uyb24dma41a'80 },81 {82 'description': 'Hebrew',83 'decoded': '\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2\u05D1\u05E8\u05D9\u05EA',84 'encoded': '4dbcagdahymbxekheh6e0a7fei0b'85 },86 {87 'description': 'Hindi (Devanagari)',88 'decoded': '\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947\u0939\u0948\u0902',89 'encoded': 'i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd'90 },91 {92 'description': 'Japanese (kanji and hiragana)',93 'decoded': '\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B',94 'encoded': 'n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa'95 },96 {97 'description': 'Korean (Hangul syllables)',98 'decoded': '\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C',99 'encoded': '989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c'100 },101 /**102 * As there's no way to do it in JavaScript, Punycode.js doesn't support103 * mixed-case annotation (which is entirely optional as per the RFC).104 * So, while the RFC sample string encodes to:105 * `b1abfaaepdrnnbgefbaDotcwatmq2g4l`106 * Without mixed-case annotation it has to encode to:107 * `b1abfaaepdrnnbgefbadotcwatmq2g4l`108 * https://github.com/bestiejs/punycode.js/issues/3109 */110 {111 'description': 'Russian (Cyrillic)',112 'decoded': '\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A\u0438',113 'encoded': 'b1abfaaepdrnnbgefbadotcwatmq2g4l'114 },115 {116 'description': 'Spanish',117 'decoded': 'Porqu\xE9nopuedensimplementehablarenEspa\xF1ol',118 'encoded': 'PorqunopuedensimplementehablarenEspaol-fmd56a'119 },120 {121 'description': 'Vietnamese',122 'decoded': 'T\u1EA1isaoh\u1ECDkh\xF4ngth\u1EC3ch\u1EC9n\xF3iti\u1EBFngVi\u1EC7t',123 'encoded': 'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g'124 },125 {126 'decoded': '3\u5E74B\u7D44\u91D1\u516B\u5148\u751F',127 'encoded': '3B-ww4c5e180e575a65lsy2b'128 },129 {130 'decoded': '\u5B89\u5BA4\u5948\u7F8E\u6075-with-SUPER-MONKEYS',131 'encoded': '-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n'132 },133 {134 'decoded': 'Hello-Another-Way-\u305D\u308C\u305E\u308C\u306E\u5834\u6240',135 'encoded': 'Hello-Another-Way--fc4qua05auwb3674vfr0b'136 },137 {138 'decoded': '\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B2',139 'encoded': '2-u9tlzr9756bt3uc0v'140 },141 {142 'decoded': 'Maji\u3067Koi\u3059\u308B5\u79D2\u524D',143 'encoded': 'MajiKoi5-783gue6qz075azm5e'144 },145 {146 'decoded': '\u30D1\u30D5\u30A3\u30FCde\u30EB\u30F3\u30D0',147 'encoded': 'de-jg4avhby1noc0d'148 },149 {150 'decoded': '\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067',151 'encoded': 'd9juau41awczczp'152 },153 /**154 * This example is an ASCII string that breaks the existing rules for host155 * name labels. (It's not a realistic example for IDNA, because IDNA never156 * encodes pure ASCII labels.)157 */158 {159 'description': 'ASCII string that breaks the existing rules for host-name labels',160 'decoded': '-> $1.00 <-',161 'encoded': '-> $1.00 <--'162 }163 ],164 'ucs2': [165 // Every Unicode symbol is tested separately. These are just the extra166 // tests for symbol combinations:167 {168 'description': 'Consecutive astral symbols',169 'decoded': [127829, 119808, 119558, 119638],170 'encoded': '\uD83C\uDF55\uD835\uDC00\uD834\uDF06\uD834\uDF56'171 },172 {173 'description': 'U+D800 (high surrogate) followed by non-surrogates',174 'decoded': [55296, 97, 98],175 'encoded': '\uD800ab'176 },177 {178 'description': 'U+DC00 (low surrogate) followed by non-surrogates',179 'decoded': [56320, 97, 98],180 'encoded': '\uDC00ab'181 },182 {183 'description': 'High surrogate followed by another high surrogate',184 'decoded': [0xD800, 0xD800],185 'encoded': '\uD800\uD800'186 },187 {188 'description': 'Unmatched high surrogate, followed by a surrogate pair, followed by an unmatched high surrogate',189 'decoded': [0xD800, 0x1D306, 0xD800],190 'encoded': '\uD800\uD834\uDF06\uD800'191 },192 {193 'description': 'Low surrogate followed by another low surrogate',194 'decoded': [0xDC00, 0xDC00],195 'encoded': '\uDC00\uDC00'196 },197 {198 'description': 'Unmatched low surrogate, followed by a surrogate pair, followed by an unmatched low surrogate',199 'decoded': [0xDC00, 0x1D306, 0xDC00],200 'encoded': '\uDC00\uD834\uDF06\uDC00'201 }202 ],203 'domains': [204 {205 'decoded': 'ma\xF1ana.com',206 'encoded': 'xn--maana-pta.com'207 },208 { // https://github.com/bestiejs/punycode.js/issues/17209 'decoded': 'example.com.',210 'encoded': 'example.com.'211 },212 {213 'decoded': 'b\xFCcher.com',214 'encoded': 'xn--bcher-kva.com'215 },216 {217 'decoded': 'caf\xE9.com',218 'encoded': 'xn--caf-dma.com'219 },220 {221 'decoded': '\u2603-\u2318.com',222 'encoded': 'xn----dqo34k.com'223 },224 {225 'decoded': '\uD400\u2603-\u2318.com',226 'encoded': 'xn----dqo34kn65z.com'227 },228 {229 'description': 'Emoji',230 'decoded': '\uD83D\uDCA9.la',231 'encoded': 'xn--ls8h.la'232 },233 {234 'description': 'Email address',235 'decoded': '\u0434\u0436\u0443\u043C\u043B\u0430@\u0434\u0436p\u0443\u043C\u043B\u0430\u0442\u0435\u0441\u0442.b\u0440\u0444a',236 'encoded': '\u0434\u0436\u0443\u043C\u043B\u0430@xn--p-8sbkgc5ag7bhce.xn--ba-lmcq'237 }238 ],239 'separators': [240 {241 'description': 'Using U+002E as separator',242 'decoded': 'ma\xF1ana\x2Ecom',243 'encoded': 'xn--maana-pta.com'244 },245 {246 'description': 'Using U+3002 as separator',247 'decoded': 'ma\xF1ana\u3002com',248 'encoded': 'xn--maana-pta.com'249 },250 {251 'description': 'Using U+FF0E as separator',252 'decoded': 'ma\xF1ana\uFF0Ecom',253 'encoded': 'xn--maana-pta.com'254 },255 {256 'description': 'Using U+FF61 as separator',257 'decoded': 'ma\xF1ana\uFF61com',258 'encoded': 'xn--maana-pta.com'259 }260 ]261 };262 /*--------------------------------------------------------------------------*/263 // simple `Array#forEach`-like helper function264 function each(array, fn) {265 var index = array.length;266 while (index--) {267 fn(array[index], index);268 }269 }270 // `throws` is a reserved word in ES3; alias it to avoid errors271 var raises = QUnit.assert['throws'];272 /*--------------------------------------------------------------------------*/273 // Explicitly call `QUnit.module()` instead of `module()` in case we are in274 // a CLI environment.275 QUnit.module('punycode');276 test('punycode.ucs2.decode', function() {277 // Test all Unicode code points separately.278 runExtendedTests && each(allSymbols, function(string, codePoint) {279 deepEqual(punycode.ucs2.decode(string), [codePoint], 'Decoding symbol with code point ' + codePoint);280 });281 each(testData.ucs2, function(object) {282 deepEqual(punycode.ucs2.decode(object.encoded), object.decoded, object.description);283 });284 raises(285 function() {286 punycode.decode('\x81-');287 },288 RangeError,289 'RangeError: Illegal input >= 0x80 (not a basic code point)'290 );291 raises(292 function() {293 punycode.decode('\x81');294 },295 RangeError,296 'RangeError: Overflow: input needs wider integers to process'297 );298 });299 test('punycode.ucs2.encode', function() {300 // test all Unicode code points separately301 runExtendedTests && each(allSymbols, function(string, codePoint) {302 deepEqual(punycode.ucs2.encode([codePoint]), string, 'Encoding code point ' + codePoint);303 });304 each(testData.ucs2, function(object) {305 equal(punycode.ucs2.encode(object.decoded), object.encoded, object.description);306 });307 var codePoints = [0x61, 0x62, 0x63];308 var result = punycode.ucs2.encode(codePoints);309 equal(result, 'abc');310 deepEqual(codePoints, [0x61, 0x62, 0x63], 'Do not mutate argument array');311 });312 test('punycode.decode', function() {313 each(testData.strings, function(object) {314 equal(punycode.decode(object.encoded), object.decoded, object.description);315 });316 equal(punycode.decode('ZZZ'), '\u7BA5', 'Uppercase Z');317 });318 test('punycode.encode', function() {319 each(testData.strings, function(object) {320 equal(punycode.encode(object.decoded), object.encoded, object.description);321 });322 });323 test('punycode.toUnicode', function() {324 each(testData.domains, function(object) {325 equal(punycode.toUnicode(object.encoded), object.decoded, object.description);326 });327 /**328 * Domain names (or other strings) that don't start with `xn--` may not be329 * converted.330 */331 each(testData.strings, function(object) {332 var message = 'Domain names (or other strings) that don\'t start with `xn--` may not be converted';333 equal(punycode.toUnicode(object.encoded), object.encoded, message);334 equal(punycode.toUnicode(object.decoded), object.decoded, message);335 });336 });337 test('punycode.toASCII', function() {338 each(testData.domains, function(object) {339 equal(punycode.toASCII(object.decoded), object.encoded, object.description);340 });341 /**342 * Domain names (or other strings) that are already in ASCII may not be343 * converted.344 */345 each(testData.strings, function(object) {346 equal(punycode.toASCII(object.encoded), object.encoded, 'Domain names (or other strings) that are already in ASCII may not be converted');347 });348 /**349 * IDNA2003 separators must be supported for backwards compatibility.350 */351 each(testData.separators, function(object) {352 var message = 'IDNA2003 separators must be supported for backwards compatibility';353 equal(punycode.toASCII(object.decoded), object.encoded, message);354 });355 });356 /*--------------------------------------------------------------------------*/357 // configure QUnit and call `QUnit.start()` for358 // Narwhal, Node.js, PhantomJS, Rhino, and RingoJS359 if (!root.document || root.phantom) {360 QUnit.config.noglobals = true;361 QUnit.start();362 }...
struct_unittests.js
Source:struct_unittests.js
1// Copyright 2014 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4define([5 "gin/test/expect",6 "mojo/public/interfaces/bindings/tests/rect.mojom",7 "mojo/public/interfaces/bindings/tests/test_structs.mojom",8 "mojo/public/js/codec",9 "mojo/public/js/validator",10], function(expect,11 rect,12 testStructs,13 codec,14 validator) {15 function testConstructors() {16 var r = new rect.Rect();17 expect(r).toEqual(new rect.Rect({x:0, y:0, width:0, height:0}));18 expect(r).toEqual(new rect.Rect({foo:100, bar:200}));19 r.x = 10;20 r.y = 20;21 r.width = 30;22 r.height = 40;23 var rp = new testStructs.RectPair({first: r, second: r});24 expect(rp.first).toEqual(r);25 expect(rp.second).toEqual(r);26 expect(new testStructs.RectPair({second: r}).first).toBeNull();27 var nr = new testStructs.NamedRegion();28 expect(nr.name).toBeNull();29 expect(nr.rects).toBeNull();30 expect(nr).toEqual(new testStructs.NamedRegion({}));31 nr.name = "foo";32 nr.rects = [r, r, r];33 expect(nr).toEqual(new testStructs.NamedRegion({34 name: "foo",35 rects: [r, r, r],36 }));37 var e = new testStructs.EmptyStruct();38 expect(e).toEqual(new testStructs.EmptyStruct({foo:123}));39 }40 function testNoDefaultFieldValues() {41 var s = new testStructs.NoDefaultFieldValues();42 expect(s.f0).toEqual(false);43 // f1 - f10, number type fields44 for (var i = 1; i <= 10; i++)45 expect(s["f" + i]).toEqual(0);46 // f11,12 strings, f13-22 handles, f23-f26 arrays, f27,28 structs47 for (var i = 11; i <= 28; i++)48 expect(s["f" + i]).toBeNull();49 }50 function testDefaultFieldValues() {51 var s = new testStructs.DefaultFieldValues();52 expect(s.f0).toEqual(true);53 // f1 - f12, number type fields54 for (var i = 1; i <= 12; i++)55 expect(s["f" + i]).toEqual(100);56 // f13,14 "foo"57 for (var i = 13; i <= 14; i++)58 expect(s["f" + i]).toEqual("foo");59 // f15,16 a default instance of Rect60 var r = new rect.Rect();61 expect(s.f15).toEqual(r);62 expect(s.f16).toEqual(r);63 }64 function testScopedConstants() {65 expect(testStructs.ScopedConstants.TEN).toEqual(10);66 expect(testStructs.ScopedConstants.ALSO_TEN).toEqual(10);67 expect(testStructs.ScopedConstants.TEN_TOO).toEqual(10);68 expect(testStructs.ScopedConstants.EType.E0).toEqual(0);69 expect(testStructs.ScopedConstants.EType.E1).toEqual(1);70 expect(testStructs.ScopedConstants.EType.E2).toEqual(10);71 expect(testStructs.ScopedConstants.EType.E3).toEqual(10);72 expect(testStructs.ScopedConstants.EType.E4).toEqual(11);73 var s = new testStructs.ScopedConstants();74 expect(s.f0).toEqual(0);75 expect(s.f1).toEqual(1);76 expect(s.f2).toEqual(10);77 expect(s.f3).toEqual(10);78 expect(s.f4).toEqual(11);79 expect(s.f5).toEqual(10);80 expect(s.f6).toEqual(10);81 }82 function structEncodeDecode(struct) {83 var structClass = struct.constructor;84 var builder = new codec.MessageBuilder(1234, structClass.encodedSize);85 builder.encodeStruct(structClass, struct);86 var message = builder.finish();87 var messageValidator = new validator.Validator(message);88 var err = structClass.validate(messageValidator, codec.kMessageHeaderSize);89 expect(err).toEqual(validator.validationError.NONE);90 var reader = new codec.MessageReader(message);91 return reader.decodeStruct(structClass);92 }93 function testMapKeyTypes() {94 var mapFieldsStruct = new testStructs.MapKeyTypes({95 f0: new Map([[true, false], [false, true]]), // map<bool, bool>96 f1: new Map([[0, 0], [1, 127], [-1, -128]]), // map<int8, int8>97 f2: new Map([[0, 0], [1, 127], [2, 255]]), // map<uint8, uint8>98 f3: new Map([[0, 0], [1, 32767], [2, -32768]]), // map<int16, int16>99 f4: new Map([[0, 0], [1, 32768], [2, 0xFFFF]]), // map<uint16, uint16>100 f5: new Map([[0, 0], [1, 32767], [2, -32768]]), // map<int32, int32>101 f6: new Map([[0, 0], [1, 32768], [2, 0xFFFF]]), // map<uint32, uint32>102 f7: new Map([[0, 0], [1, 32767], [2, -32768]]), // map<int64, int64>103 f8: new Map([[0, 0], [1, 32768], [2, 0xFFFF]]), // map<uint64, uint64>104 f9: new Map([[1000.5, -50000], [100.5, 5000]]), // map<float, float>105 f10: new Map([[-100.5, -50000], [0, 50000000]]), // map<double, double>106 f11: new Map([["one", "two"], ["free", "four"]]), // map<string, string>107 });108 var decodedStruct = structEncodeDecode(mapFieldsStruct);109 expect(decodedStruct.f0).toEqual(mapFieldsStruct.f0);110 expect(decodedStruct.f1).toEqual(mapFieldsStruct.f1);111 expect(decodedStruct.f2).toEqual(mapFieldsStruct.f2);112 expect(decodedStruct.f3).toEqual(mapFieldsStruct.f3);113 expect(decodedStruct.f4).toEqual(mapFieldsStruct.f4);114 expect(decodedStruct.f5).toEqual(mapFieldsStruct.f5);115 expect(decodedStruct.f6).toEqual(mapFieldsStruct.f6);116 expect(decodedStruct.f7).toEqual(mapFieldsStruct.f7);117 expect(decodedStruct.f8).toEqual(mapFieldsStruct.f8);118 expect(decodedStruct.f9).toEqual(mapFieldsStruct.f9);119 expect(decodedStruct.f10).toEqual(mapFieldsStruct.f10);120 expect(decodedStruct.f11).toEqual(mapFieldsStruct.f11);121 }122 function testMapValueTypes() {123 var mapFieldsStruct = new testStructs.MapValueTypes({124 // map<string, array<string>>125 f0: new Map([["a", ["b", "c"]], ["d", ["e"]]]),126 // map<string, array<string>?>127 f1: new Map([["a", null], ["b", ["c", "d"]]]),128 // map<string, array<string?>>129 f2: new Map([["a", [null]], ["b", [null, "d"]]]),130 // map<string, array<string,2>>131 f3: new Map([["a", ["1", "2"]], ["b", ["1", "2"]]]),132 // map<string, array<array<string, 2>?>>133 f4: new Map([["a", [["1", "2"]]], ["b", [null]]]),134 // map<string, array<array<string, 2>, 1>>135 f5: new Map([["a", [["1", "2"]]]]),136 // map<string, Rect?>137 f6: new Map([["a", null]]),138 // map<string, map<string, string>>139 f7: new Map([["a", new Map([["b", "c"]])]]),140 // map<string, array<map<string, string>>>141 f8: new Map([["a", [new Map([["b", "c"]])]]]),142 // map<string, handle>143 f9: new Map([["a", 1234]]),144 // map<string, array<handle>>145 f10: new Map([["a", [1234, 5678]]]),146 // map<string, map<string, handle>>147 f11: new Map([["a", new Map([["b", 1234]])]]),148 });149 var decodedStruct = structEncodeDecode(mapFieldsStruct);150 expect(decodedStruct.f0).toEqual(mapFieldsStruct.f0);151 expect(decodedStruct.f1).toEqual(mapFieldsStruct.f1);152 expect(decodedStruct.f2).toEqual(mapFieldsStruct.f2);153 expect(decodedStruct.f3).toEqual(mapFieldsStruct.f3);154 expect(decodedStruct.f4).toEqual(mapFieldsStruct.f4);155 expect(decodedStruct.f5).toEqual(mapFieldsStruct.f5);156 expect(decodedStruct.f6).toEqual(mapFieldsStruct.f6);157 expect(decodedStruct.f7).toEqual(mapFieldsStruct.f7);158 expect(decodedStruct.f8).toEqual(mapFieldsStruct.f8);159 expect(decodedStruct.f9).toEqual(mapFieldsStruct.f9);160 expect(decodedStruct.f10).toEqual(mapFieldsStruct.f10);161 expect(decodedStruct.f11).toEqual(mapFieldsStruct.f11);162 }163 function testFloatNumberValues() {164 var decodedStruct = structEncodeDecode(new testStructs.FloatNumberValues);165 expect(decodedStruct.f0).toEqual(testStructs.FloatNumberValues.V0);166 expect(decodedStruct.f1).toEqual(testStructs.FloatNumberValues.V1);167 expect(decodedStruct.f2).toEqual(testStructs.FloatNumberValues.V2);168 expect(decodedStruct.f3).toEqual(testStructs.FloatNumberValues.V3);169 expect(decodedStruct.f4).toEqual(testStructs.FloatNumberValues.V4);170 expect(decodedStruct.f5).toEqual(testStructs.FloatNumberValues.V5);171 expect(decodedStruct.f6).toEqual(testStructs.FloatNumberValues.V6);172 expect(decodedStruct.f7).toEqual(testStructs.FloatNumberValues.V7);173 expect(decodedStruct.f8).toEqual(testStructs.FloatNumberValues.V8);174 expect(decodedStruct.f9).toEqual(testStructs.FloatNumberValues.V9);175 }176 function testIntegerNumberValues() {177 var decodedStruct = structEncodeDecode(new testStructs.IntegerNumberValues);178 expect(decodedStruct.f0).toEqual(testStructs.IntegerNumberValues.V0);179 expect(decodedStruct.f1).toEqual(testStructs.IntegerNumberValues.V1);180 expect(decodedStruct.f2).toEqual(testStructs.IntegerNumberValues.V2);181 expect(decodedStruct.f3).toEqual(testStructs.IntegerNumberValues.V3);182 expect(decodedStruct.f4).toEqual(testStructs.IntegerNumberValues.V4);183 expect(decodedStruct.f5).toEqual(testStructs.IntegerNumberValues.V5);184 expect(decodedStruct.f6).toEqual(testStructs.IntegerNumberValues.V6);185 expect(decodedStruct.f7).toEqual(testStructs.IntegerNumberValues.V7);186 expect(decodedStruct.f8).toEqual(testStructs.IntegerNumberValues.V8);187 expect(decodedStruct.f9).toEqual(testStructs.IntegerNumberValues.V9);188 expect(decodedStruct.f10).toEqual(testStructs.IntegerNumberValues.V10);189 expect(decodedStruct.f11).toEqual(testStructs.IntegerNumberValues.V11);190 expect(decodedStruct.f12).toEqual(testStructs.IntegerNumberValues.V12);191 expect(decodedStruct.f13).toEqual(testStructs.IntegerNumberValues.V13);192 expect(decodedStruct.f14).toEqual(testStructs.IntegerNumberValues.V14);193 expect(decodedStruct.f15).toEqual(testStructs.IntegerNumberValues.V15);194 expect(decodedStruct.f16).toEqual(testStructs.IntegerNumberValues.V16);195 expect(decodedStruct.f17).toEqual(testStructs.IntegerNumberValues.V17);196 expect(decodedStruct.f18).toEqual(testStructs.IntegerNumberValues.V18);197 expect(decodedStruct.f19).toEqual(testStructs.IntegerNumberValues.V19);198 }199 function testUnsignedNumberValues() {200 var decodedStruct =201 structEncodeDecode(new testStructs.UnsignedNumberValues);202 expect(decodedStruct.f0).toEqual(testStructs.UnsignedNumberValues.V0);203 expect(decodedStruct.f1).toEqual(testStructs.UnsignedNumberValues.V1);204 expect(decodedStruct.f2).toEqual(testStructs.UnsignedNumberValues.V2);205 expect(decodedStruct.f3).toEqual(testStructs.UnsignedNumberValues.V3);206 expect(decodedStruct.f4).toEqual(testStructs.UnsignedNumberValues.V4);207 expect(decodedStruct.f5).toEqual(testStructs.UnsignedNumberValues.V5);208 expect(decodedStruct.f6).toEqual(testStructs.UnsignedNumberValues.V6);209 expect(decodedStruct.f7).toEqual(testStructs.UnsignedNumberValues.V7);210 expect(decodedStruct.f8).toEqual(testStructs.UnsignedNumberValues.V8);211 expect(decodedStruct.f9).toEqual(testStructs.UnsignedNumberValues.V9);212 expect(decodedStruct.f10).toEqual(testStructs.UnsignedNumberValues.V10);213 expect(decodedStruct.f11).toEqual(testStructs.UnsignedNumberValues.V11);214 }215 function testBitArrayValues() {216 var bitArraysStruct = new testStructs.BitArrayValues({217 // array<bool, 1> f0;218 f0: [true],219 // array<bool, 7> f1;220 f1: [true, false, true, false, true, false, true],221 // array<bool, 9> f2;222 f2: [true, false, true, false, true, false, true, false, true],223 // array<bool> f3;224 f3: [true, false, true, false, true, false, true, false],225 // array<array<bool>> f4;226 f4: [[true], [false], [true, false], [true, false, true, false]],227 // array<array<bool>?> f5;228 f5: [[true], null, null, [true, false, true, false]],229 // array<array<bool, 2>?> f6;230 f6: [[true, false], [true, false], [true, false]],231 });232 var decodedStruct = structEncodeDecode(bitArraysStruct);233 expect(decodedStruct.f0).toEqual(bitArraysStruct.f0);234 expect(decodedStruct.f1).toEqual(bitArraysStruct.f1);235 expect(decodedStruct.f2).toEqual(bitArraysStruct.f2);236 expect(decodedStruct.f3).toEqual(bitArraysStruct.f3);237 expect(decodedStruct.f4).toEqual(bitArraysStruct.f4);238 expect(decodedStruct.f5).toEqual(bitArraysStruct.f5);239 expect(decodedStruct.f6).toEqual(bitArraysStruct.f6);240 }241 testConstructors();242 testNoDefaultFieldValues();243 testDefaultFieldValues();244 testScopedConstants();245 testMapKeyTypes();246 testMapValueTypes();247 testFloatNumberValues();248 testIntegerNumberValues();249 testUnsignedNumberValues();250 testBitArrayValues();251 this.result = "PASS";...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.1b2c3d4e5f6g7h8i9j0');3var options = {4};5wpt.runTest(url, options, function(err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});12{ statusCode: 400,13 data: '{"statusCode":400,"statusText":"Bad Request","data":{"error":{"message":"Invalid Test Options","id":"invalidTestOptions"}}}' }
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Barack Obama');3page.get(function(err, info) {4 console.log(info);5});6var wptools = require('wptools');7var page = wptools.page('Barack Obama');8page.get(function(err, info) {9 console.log(info);10});11var wptools = require('wptools');12var page = wptools.page('Barack Obama');13page.get(function(err, info) {14 console.log(info);15});16var wptools = require('wptools');17var page = wptools.page('Barack Obama');18page.get(function(err, info) {19 console.log(info);20});21var wptools = require('wptools');22var page = wptools.page('Barack Obama');23page.get(function(err, info) {24 console.log(info);25});26var wptools = require('wptools');27var page = wptools.page('Barack Obama');28page.get(function(err, info) {29 console.log(info);30});31var wptools = require('wptools');32var page = wptools.page('Barack Obama');33page.get(function(err, info) {34 console.log(info);35});36var wptools = require('wptools');37var page = wptools.page('Barack Obama');38page.get(function(err, info) {39 console.log(info);40});41var wptools = require('wptools');42var page = wptools.page('Barack Obama');43page.get(function(err, info) {44 console.log(info);45});46var wptools = require('wptools');
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp) {4 console.log(resp);5});6var wptools = require('wptools');7var page = wptools.page('Albert Einstein');8page.get(function(err, resp) {9 console.log(resp);10});11var wptools = require('wptools');12var page = wptools.page('Albert Einstein');13page.get(function(err, resp) {14 console.log(resp);15});16var wptools = require('wptools');17var page = wptools.page('Albert Einstein');18page.get(function(err, resp) {19 console.log(resp);20});21var wptools = require('wptools');22var page = wptools.page('Albert Einstein');23page.get(function(err, resp) {24 console.log(resp);25});26var wptools = require('wptools');27var page = wptools.page('Albert Einstein');28page.get(function(err, resp) {29 console.log(resp);30});31var wptools = require('wptools');32var page = wptools.page('Albert Einstein');33page.get(function(err, resp) {34 console.log(resp);35});36var wptools = require('wptools');37var page = wptools.page('Albert Einstein');38page.get(function(err, resp) {39 console.log(resp);40});41var wptools = require('wptools');42var page = wptools.page('Albert Einstein');43page.get(function(err, resp) {44 console.log(resp);45});46var wptools = require('wptools');47var page = wptools.page('Albert
Using AI Code Generation
1var test = require('./test1.js');2var test2 = require('./test2.js');3var test3 = require('./test3.js');4var test4 = require('./test4.js');5var test5 = require('./test5.js');6var test6 = require('./test6.js');7var test7 = require('./test7.js');8var test8 = require('./test8.js');9var test9 = require('./test9.js');10var test10 = require('./test10.js');11var test11 = require('./test11.js');12var test12 = require('./test12.js');13var test13 = require('./test13.js');14var test14 = require('./test14.js');15var test15 = require('./test15.js');16var test16 = require('./test16.js');17var test17 = require('./test17.js');18var test18 = require('./test18.js');19var test19 = require('./test19.js');20var test20 = require('./test20.js');21var test21 = require('./test21.js');22var test22 = require('./test22.js');23var test23 = require('./test23.js');24var test24 = require('./test24.js');25var test25 = require('./test25.js');26var test26 = require('./test26.js');27var test27 = require('./test27.js');28var test28 = require('./test28.js');29var test29 = require('./test29.js');30var test30 = require('./test30.js');31var test31 = require('./test31.js');32var test32 = require('./test32.js');33var test33 = require('./test33.js');34var test34 = require('./test34.js');35var test35 = require('./test35.js');36var test36 = require('./test36.js');37var test37 = require('./test37.js');38var test38 = require('./test38.js');39var test39 = require('./test39.js');40var test40 = require('./test40.js');41var test41 = require('./test41.js');42var test42 = require('./test42.js');43var test43 = require('./test43.js');44var test44 = require('./test44.js');45var test45 = require('./test45.js');46var test46 = require('./test46.js');47var test47 = require('./test47.js');48var test48 = require('./test48.js');49var test49 = require('./test49.js');50var test50 = require('./
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.5e8b2c2b2a2c1a8a0b7c0a0d1c1e8b8');3var wpt = new WebPageTest('www.webpagetest.org', 'A.5e8b2c2b2a2c1a8a0b7c0a0d1c1e8b8', { decoded: true });4var wpt = require('webpagetest');5var wpt = new WebPageTest('www.webpagetest.org', 'A.5e8b2c2b2a2c1a8a0b7c0a0d1c1e8b8');6var wpt = new WebPageTest('www.webpagetest.org', 'A.5e8b2c2b2a2c1a8a0b7c0a0d1c1e8b8', {
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!!