How to use parseVariable method in Playwright Internal

Best JavaScript code snippet using playwright-internal

BuildParser.js

Source:BuildParser.js Github

copy

Full Screen

...148 parseNodeForVariables(nodeData) {149 let parsedLhs, parsedRhs;150 switch (nodeData.type) {151 case 'assignment':152 parsedLhs = this.parseVariable(nodeData.variableSelected);153 parsedRhs = this.parseVariable(nodeData.assignedVal);154 if (!parsedLhs.type || !parsedRhs.type) {155 return true;156 }157 if ('mapName' in parsedLhs) {158 if (parsedLhs.keyType !== 'var' && parsedRhs.type !== 'var') {159 let lhsType =160 parsedLhs.keyType === 'address payable'161 ? 'address'162 : parsedLhs.keyType;163 this.variables[parsedLhs.mapName] = {164 type: 'mapping',165 from: lhsType,166 to: parsedRhs.type167 };168 if ('innerKeyType' in parsedLhs) {169 this.variables[parsedLhs.mapName]['inner'] =170 parsedLhs.innerKeyType;171 }172 return true;173 }174 return false;175 }176 if (177 !parsedLhs.name.includes('.') &&178 (parsedLhs.type === 'var' ||179 !(180 parsedLhs.name in this.variables ||181 parsedLhs.name in this.functionParams182 ))183 ) {184 if (nodeData.isMemory) {185 this.memoryVars[parsedLhs.name] = parsedRhs.type;186 this.memoryVarsDeclared[parsedLhs.name] = false;187 } else {188 this.variables[parsedLhs.name] = parsedRhs.type;189 }190 return true;191 }192 return false;193 case 'event':194 if (this.bitsMode) {195 this.bitsModeParseParams(196 nodeData.params,197 this.eventList,198 nodeData.variableSelected199 );200 }201 return true;202 case 'entity':203 parsedLhs = this.parseVariable(nodeData.assignVar);204 if (this.bitsMode) {205 this.bitsModeParseParams(206 nodeData.params,207 this.structList,208 nodeData.variableSelected209 );210 }211 if (nodeData.isMemory) {212 this.memoryVars[parsedLhs.name] = nodeData.variableSelected;213 } else {214 this.variables[parsedLhs.name] = nodeData.variableSelected;215 }216 return true;217 case 'transfer':218 parsedLhs = this.parseVariable(nodeData.variableSelected);219 parsedRhs = this.parseVariable(nodeData.value);220 if (!this.bitsMode && parsedLhs.type === 'var') {221 this.variables[parsedLhs.name] = 'uint';222 }223 if (parsedRhs.type === 'var') {224 this.variables[parsedRhs.name] = 'address payable';225 }226 return true;227 }228 return true;229 }230 bitsModeParseParams(params, infoList, varSelected) {231 for (let i = 0; i < params.length; i++) {232 let param = params[i];233 let info = infoList[varSelected][i];234 let parsedParam = this.parseVariable(param);235 if (236 parsedParam.type !== 'string' &&237 parsedParam.type !== 'uint' &&238 parsedParam.type !== 'int' &&239 parsedParam.type !== 'bool' &&240 !parsedParam.type.includes('address')241 ) {242 this.variables[parsedParam.name] = bitsModeGetType(info);243 }244 }245 }246 bitsModeGetType(info) {247 return `${info.type === 'string' && info.bits ? 'bytes' : info.type}${248 info['bits']249 }`;250 }251 parseNode(nodeData, memoryVarsDeclared = this.memoryVarsDeclared) {252 switch (nodeData.type) {253 case 'assignment':254 this.isView = false;255 return this.parseAssignmentNode(nodeData, memoryVarsDeclared);256 case 'event':257 this.isView = false;258 return this.parseEventNode(nodeData);259 case 'entity':260 this.isView = false;261 return this.parseEntityNode(nodeData);262 case 'transfer':263 this.isView = false;264 return this.parseTransferNode(nodeData);265 case 'return':266 let returnVar = this.parseVariable(nodeData.variableSelected);267 this.returnVar = returnVar.type;268 return `return ${returnVar.name};`;269 case 'conditional':270 return this.parseCompareNode(nodeData);271 }272 return '';273 }274 parseAssignmentNode(data, memoryVarsDeclared) {275 let parsedLhs = this.parseVariable(data.variableSelected);276 let parsedRhs = this.parseVariable(data.assignedVal);277 if (!parsedLhs.type || !parsedRhs.type) {278 return `${parsedLhs.name} ${data.assignment} ${parsedRhs.name};`;279 }280 if ('mapName' in parsedLhs) {281 let lhsType =282 parsedLhs.keyType === 'address payable' ? 'address' : parsedLhs.keyType;283 this.variables[parsedLhs.mapName] = {284 type: 'mapping',285 from: lhsType,286 to: parsedRhs.type287 };288 if ('innerKeyType' in parsedLhs) {289 this.variables[parsedLhs.mapName]['inner'] = parsedLhs.innerKeyType;290 }291 } else if (292 !parsedLhs.name.includes('.') &&293 (parsedLhs.type === 'var' ||294 !(295 parsedLhs.name in this.variables ||296 parsedLhs.name in this.functionParams297 ))298 ) {299 if (data.isMemory) {300 this.memoryVars[parsedLhs.name] = parsedRhs.type;301 } else {302 this.variables[parsedLhs.name] = parsedRhs.type;303 }304 } else if (parsedLhs.type !== parsedRhs.type) {305 console.log(306 `invalid assignment at node ${data.variableSelected} ${307 data.assignment308 } ${data.assignedVal}`309 );310 }311 if (312 data.isMemory &&313 !parsedLhs.name.includes('.') &&314 !('mapName' in parsedLhs) &&315 !memoryVarsDeclared[parsedLhs.name]316 ) {317 memoryVarsDeclared[parsedLhs.name] = true;318 return `${parsedRhs.type}${319 this.typeCheckUseMemoryKeyword(parsedRhs.type) ? ' ' : ' storage '320 }${parsedLhs.name} ${data.assignment} ${parsedRhs.name};`;321 }322 return `${parsedLhs.name} ${data.assignment} ${parsedRhs.name};`;323 }324 typeCheckUseMemoryKeyword(type) {325 return (326 ['bool', 'address', 'address payable'].includes(type) ||327 type.includes('bytes') ||328 type.includes('int')329 );330 }331 parseEventNode(data) {332 let params = data.params333 .map(param => this.parseVariable(param).name)334 .join(', ');335 return `emit ${data.variableSelected}(${params});`;336 }337 parseEntityNode(data) {338 let parsedLhs = this.parseVariable(data.assignVar);339 let params = data.params340 .map(param => this.parseVariable(param).name)341 .join(', ');342 if (data.isMemory) {343 this.memoryVars[parsedLhs.name] = data.variableSelected;344 } else {345 this.variables[parsedLhs.name] = data.variableSelected;346 }347 return `${data.isMemory ? `${data.variableSelected} storage ` : ''}${348 parsedLhs.name349 } = ${data.variableSelected}(${params});`;350 }351 parseTransferNode(data) {352 let parsedLhs = this.parseVariable(data.value);353 let parsedRhs = this.parseVariable(data.variableSelected);354 if (parsedLhs.type !== 'uint') {355 console.log(`value should be an integer at transfer node`);356 }357 if (parsedRhs.type !== 'address payable') {358 console.log(359 `transfer target should be a payable address at transfer node`360 );361 }362 return `${parsedRhs.name}.transfer(${parsedLhs.name});`;363 }364 parseCompareNode(data) {365 let parsedLhs = this.parseVariable(data.var1);366 let parsedRhs = this.parseVariable(data.var2);367 if (parsedLhs.type !== parsedRhs.type) {368 let mismatch = this.checkIntUintMismatch(369 parsedLhs,370 parsedRhs,371 `uint(${parsedLhs.name}) ${data.comp} ${parsedRhs.name}`,372 `${parsedLhs.name} ${data.comp} uint(${parsedRhs.name})`373 );374 if (mismatch) {375 return mismatch;376 }377 }378 if (379 parsedLhs.type === 'string' &&380 parsedRhs.type === 'string' &&381 comp === '=='382 ) {383 return `keccak256(${parsedLhs.name}) == keccak256(${parsedRhs.name})`;384 }385 return `${parsedLhs.name} ${data.comp} ${parsedRhs.name}`;386 }387 parseVariable(variable) {388 let variables = {389 ...this.varList,390 ...this.variables,391 ...this.functionParams,392 ...this.memoryVars393 };394 if (395 (variable[0] === '"' && variable[variable.length - 1] === '"') ||396 (variable[0] === "'" && variable[variable.length - 1] === "'")397 ) {398 return { name: variable, type: 'string' };399 }400 if (!isNaN(variable)) {401 if (parseInt(variable) < 0) {402 return { name: variable.trim(), type: 'int' };403 }404 return { name: variable.trim(), type: 'uint' };405 }406 let varName = variable407 .toLowerCase()408 .trim()409 .replace(/\s/g, '_');410 return (411 this.parseOperator(variable) ||412 this.parseStruct(variable) ||413 this.parseMap(variable, variables) ||414 this.parseKeyword(varName) ||415 this.lookupVariableName(varName, variables)416 );417 }418 parseOperator(variable) {419 for (let operator of ['*', '/', '+', '-']) {420 if (variable.indexOf(operator) > 0) {421 let lhs, rhs;422 [lhs, rhs] = variable.split(operator);423 let parsedLhs = this.parseVariable(lhs);424 let parsedRhs = this.parseVariable(rhs);425 if (parsedLhs.type !== parsedRhs.type) {426 // one of them is a uint427 let mismatch = this.checkIntUintMismatch(428 parsedLhs,429 parsedRhs,430 {431 name: `uint(${parsedLhs.name}) ${operator} ${parsedRhs.name}`,432 type: 'uint'433 },434 {435 name: `${parsedLhs.name} ${operator} uint(${parsedRhs.name})`,436 type: 'uint'437 }438 );439 if (mismatch) {440 return mismatch;441 }442 if (parsedLhs.type === 'map' || parsedRhs.type === 'map') {443 return {444 name: `${parsedLhs.name} ${operator} ${parsedRhs.name}`,445 type: parsedLhs.type === 'map' ? parsedRhs.type : parsedLhs.type446 };447 }448 return {449 name: `${parsedLhs.name} ${operator} ${parsedRhs.name}`,450 type: 'var'451 };452 }453 if (parsedLhs === 'string' && operator !== '+') {454 let varName = `${parsedLhs.name}_${parsedRhs.name}`;455 if (!(varName in variables)) {456 return { name: varName, type: 'var' };457 }458 return { name: varName, type: variables[varName] };459 }460 return {461 name: `${parsedLhs.name} ${operator} ${parsedRhs.name}`,462 type: parsedLhs.type463 };464 }465 }466 return null;467 }468 parseStruct(variable) {469 if (/('s )/.test(variable)) {470 let struct, attr;471 [struct, attr] = variable.split("'s ");472 let parsedStruct = this.parseVariable(struct);473 let parsedAttr = this.parseVariable(attr);474 for (let attribute of this.structList[parsedStruct.type]) {475 if (476 attribute.name === parsedAttr.name ||477 attribute.displayName === parsedAttr.name478 ) {479 return {480 name: `${parsedStruct.name}.${parsedAttr.name}`,481 type: this.bitsMode482 ? this.bitsModeGetType(attribute)483 : attribute.type484 };485 }486 }487 return {488 name: `${parsedStruct.name}.${parsedAttr.name}`,489 type: null490 };491 }492 return null;493 }494 parseMap(variable, variables) {495 if (/( for | of )/.test(variable)) {496 let map, key, innerKey;497 if (variable.indexOf(' of ') > 0) {498 [map, key, innerKey] = variable.split(' of ');499 } else {500 [map, key, innerKey] = variable.split(' for ');501 }502 if (innerKey) {503 let parsedMap = this.parseVariable(map);504 let parsedKey = this.parseVariable(key);505 let parsedInnerKey = this.parseVariable(innerKey);506 let type = variables[parsedMap.name]507 ? variables[parsedMap.name]['to']508 : 'map';509 return {510 name: `${parsedMap.name}[${parsedKey.name}][${parsedInnerKey.name}]`,511 mapName: parsedMap.name,512 keyType: parsedKey.type,513 innerKeyType: parsedInnerKey.type,514 type: type515 };516 }517 let parsedMap = this.parseVariable(map);518 let parsedKey = this.parseVariable(key);519 let type = variables[parsedMap.name]520 ? variables[parsedMap.name]['to']521 : 'map';522 return {523 name: `${parsedMap.name}[${parsedKey.name}]`,524 mapName: parsedMap.name,525 keyType: parsedKey.type,526 type: type527 };528 }529 return null;530 }531 parseKeyword(varName) {532 if (varName.slice(0, 2) === '0x') {...

Full Screen

Full Screen

NodeParser.js

Source:NodeParser.js Github

copy

Full Screen

...67 return true;68 }69 }70 parseAssignmentNodeForVariables(nodeData, variables) {71 const parsedLhs = parseVariable(72 nodeData.variableSelected,73 variables,74 this.structList,75 this.bitsMode76 );77 const parsedRhs = parseVariable(78 nodeData.assignedVal,79 variables,80 this.structList,81 this.bitsMode82 );83 if ('mapName' in parsedLhs) {84 if (parsedLhs.keyType !== 'var' && parsedRhs.type !== 'var') {85 this.updateVariablesForMap(parsedLhs, parsedRhs, variables);86 return true;87 }88 return false;89 }90 if (91 !parsedLhs.name.includes('.') &&92 (parsedLhs.type === 'var' ||93 !(94 parsedLhs.name in this.variables ||95 parsedLhs.name in this.functionParams96 ))97 ) {98 if (nodeData.isMemory) {99 this.memoryVars[parsedLhs.name] = parsedRhs.type;100 this.memoryVarsDeclared[parsedLhs.name] = false;101 } else {102 this.variables[parsedLhs.name] = parsedRhs.type;103 }104 return true;105 }106 return false;107 }108 parseEntityNodeForVariables(nodeData, variables) {109 const parsedLhs = parseVariable(110 nodeData.assignVar,111 variables,112 this.structList,113 this.bitsMode114 );115 if (nodeData.isMemory) {116 this.memoryVars[parsedLhs.name] = nodeData.variableSelected;117 } else {118 this.variables[parsedLhs.name] = nodeData.variableSelected;119 }120 return true;121 }122 parseTransferNodeForVariables(nodeData, variables) {123 const parsedLhs = parseVariable(124 nodeData.variableSelected,125 variables,126 this.structList,127 this.bitsMode128 );129 const parsedRhs = parseVariable(130 nodeData.value,131 variables,132 this.structList,133 this.bitsMode134 );135 if (!this.bitsMode && parsedLhs.type === 'var') {136 this.variables[parsedLhs.name] = 'uint';137 }138 if (parsedRhs.type === 'var') {139 this.variables[parsedRhs.name] = 'address payable';140 }141 return true;142 }143 parseNode(nodeData, indentation = '') {144 const variables = this.getAllVariables();145 switch (nodeData.type) {146 case 'event':147 this.isView = false;148 return indentation + this.parseEventNode(nodeData, variables);149 case 'entity':150 this.isView = false;151 return indentation + this.parseEntityNode(nodeData, variables);152 case 'transfer':153 this.isView = false;154 return indentation + this.parseTransferNode(nodeData, variables);155 case 'return': {156 const returnVar = parseVariable(157 nodeData.variableSelected,158 variables,159 this.structList,160 this.bitsMode161 );162 this.returnVar = returnVar.type;163 return `${indentation}return ${returnVar.name};`;164 }165 case 'conditional':166 return this.parseCompareNode(nodeData, variables);167 case 'assignment':168 default:169 this.isView = false;170 return indentation + this.parseAssignmentNode(nodeData, variables);171 }172 }173 parseAssignmentNode(data, variables) {174 const parsedLhs = parseVariable(175 data.variableSelected,176 variables,177 this.structList,178 this.bitsMode179 );180 const parsedRhs = parseVariable(181 data.assignedVal,182 variables,183 this.structList,184 this.bitsMode185 );186 if ('mapName' in parsedLhs) {187 this.updateVariablesForMap(parsedLhs, parsedRhs, variables);188 } else if (189 parsedLhs.type !== 'var' &&190 parsedRhs.type !== 'var' &&191 !isSameBaseType(parsedLhs.type, parsedRhs.type, this.bitsMode)192 ) {193 this.updateBuildError(194 `Invalid assignment at node ${data.variableSelected} ${data.assignment} ${data.assignedVal}`195 );196 } else if (197 !parsedLhs.name.includes('.') &&198 (parsedLhs.type === 'var' ||199 !(200 parsedLhs.name in this.variables ||201 parsedLhs.name in this.functionParams202 ))203 ) {204 if (data.isMemory) {205 this.memoryVars[parsedLhs.name] = parsedRhs.type;206 } else {207 this.variables[parsedLhs.name] = parsedRhs.type;208 }209 }210 if (211 data.isMemory &&212 !parsedLhs.name.includes('.') &&213 !('mapName' in parsedLhs) &&214 !this.memoryVarsDeclared[parsedLhs.name]215 ) {216 this.memoryVarsDeclared[parsedLhs.name] = true;217 return `${parsedRhs.type}${218 !isPrimitiveType(parsedRhs.type) ? ' memory ' : ' '219 }${parsedLhs.name} ${data.assignment} ${parsedRhs.name};`;220 }221 return `${parsedLhs.name} ${data.assignment} ${parsedRhs.name};`;222 }223 parseEventNode(data, variables) {224 const params = data.params225 .map(226 param =>227 parseVariable(param, variables, this.structList, this.bitsMode).name228 )229 .join(', ');230 return `emit ${data.variableSelected}(${params});`;231 }232 parseEntityNode(data, variables) {233 const parsedLhs = parseVariable(234 data.assignVar,235 variables,236 this.structList,237 this.bitsMode238 );239 const params = data.params240 .map(241 param =>242 parseVariable(param, variables, this.structList, this.bitsMode).name243 )244 .join(', ');245 if (data.isMemory) {246 this.memoryVars[parsedLhs.name] = data.variableSelected;247 } else {248 this.variables[parsedLhs.name] = data.variableSelected;249 }250 return `${data.isMemory ? `${data.variableSelected} memory ` : ''}${251 parsedLhs.name252 } = ${data.variableSelected}(${params});`;253 }254 parseTransferNode(data, variables) {255 const parsedLhs = parseVariable(256 data.value,257 variables,258 this.structList,259 this.bitsMode260 );261 const parsedRhs = parseVariable(262 data.variableSelected,263 variables,264 this.structList,265 this.bitsMode266 );267 if (parsedLhs.type !== 'uint') {268 this.updateBuildError(`Value should be an integer at transfer node`);269 }270 if (parsedRhs.type !== 'address payable') {271 this.updateBuildError(272 `Transfer target should be a payable address at transfer node`273 );274 }275 return `${parsedRhs.name}.transfer(${parsedLhs.name});`;276 }277 parseCompareNode(data, variables) {278 const parsedLhs = parseVariable(279 data.var1,280 variables,281 this.structList,282 this.bitsMode283 );284 const parsedRhs = parseVariable(285 data.var2,286 variables,287 this.structList,288 this.bitsMode289 );290 if (parsedLhs.type !== parsedRhs.type) {291 const mismatch = checkIntUintMismatch(292 parsedLhs,293 parsedRhs,294 `${parsedLhs.name} ${data.comp} int(${parsedRhs.name})`,295 `int(${parsedLhs.name}) ${data.comp} ${parsedRhs.name}`296 );297 if (mismatch) {298 return mismatch;...

Full Screen

Full Screen

display-env.js

Source:display-env.js Github

copy

Full Screen

...6 }7};8module.exports = function (options) {9 console.log("Displaying environment variables:");10 console.log("PORT: " + parseVariable(process.env.PORT));11 console.log("MONGO_URL: " + parseVariable(process.env.MONGO_URL));12 console.log("ROOT_URL: " + parseVariable(process.env.ROOT_URL));13 console.log("OPLOG_URL: " + parseVariable(process.env.OPLOG_URL));14 console.log("MONGO_OPLOG_URL: " + parseVariable(process.env.MONGO_OPLOG_URL));15 console.log("METEOR_ENV: " + parseVariable(process.env.METEOR_ENV));16 console.log("NODE_ENV: " + parseVariable(process.env.NODE_ENV));17 console.log("NODE_OPTIONS: " + parseVariable(process.env.NODE_OPTIONS));18 console.log("DISABLE_WEBSOCKETS: " + parseVariable(process.env.DISABLE_WEBSOCKETS));19 console.log("MAIL_URL: " + parseVariable(process.env.MAIL_URL));20 console.log("DDP_DEFAULT_CONNECTION_URL: " + parseVariable(process.env.DDP_DEFAULT_CONNECTION_URL));21 console.log("HTTP_PROXY: " + parseVariable(process.env.HTTP_PROXY));22 console.log("HTTPS_PROXY: " + parseVariable(process.env.HTTPS_PROXY));23 console.log("METEOR_OFFLINE_CATALOG: " + parseVariable(process.env.METEOR_OFFLINE_CATALOG));24 console.log("METEOR_PROFILE: " + parseVariable(process.env.METEOR_PROFILE));25 console.log("METEOR_DEBUG_BUILD: " + parseVariable(process.env.METEOR_DEBUG_BUILD));26 console.log("TINYTEST_FILTER: " + parseVariable(process.env.TINYTEST_FILTER));27 console.log("MOBILE_ROOT_URL: " + parseVariable(process.env.MOBILE_ROOT_URL));28 console.log("NODE_DEBUG: " + parseVariable(process.env.NODE_DEBUG));29 console.log("BIND_IP: " + parseVariable(process.env.BIND_IP));30 console.log("PACKAGE_DIRS: " + parseVariable(process.env.PACKAGE_DIRS));31 console.log("DEBUG: " + parseVariable(process.env.DEBUG));32 console.log("");33 if (options.all) {34 console.log("METEOR_PRINT_CONSTRAINT_SOLVER_INPUT: " + parseVariable(process.env.METEOR_PRINT_CONSTRAINT_SOLVER_INPUT));35 console.log("METEOR_CATALOG_COMPRESS_RPCS: " + parseVariable(process.env.METEOR_CATALOG_COMPRESS_RPCS));36 console.log("METEOR_MINIFY_LEGACY: " + parseVariable(process.env.METEOR_MINIFY_LEGACY));37 console.log("METEOR_DEBUG_SQL: " + parseVariable(process.env.METEOR_DEBUG_SQL));38 console.log("METEOR_WAREHOUSE_DIR: " + parseVariable(process.env.METEOR_WAREHOUSE_DIR));39 console.log("AUTOUPDATE_VERSION: " + parseVariable(process.env.AUTOUPDATE_VERSION));40 console.log("USE_GLOBAL_ADK: " + parseVariable(process.env.USE_GLOBAL_ADK));41 console.log("METEOR_AVD: " + parseVariable(process.env.METEOR_AVD));42 console.log("DEFAULT_AVD_NAME: " + parseVariable(process.env.DEFAULT_AVD_NAME));43 console.log("METEOR_BUILD_FARM_URL: " + parseVariable(process.env.METEOR_BUILD_FARM_URL));44 console.log("METEOR_PACKAGE_SERVER_URL: " + parseVariable(process.env.METEOR_PACKAGE_SERVER_URL));45 console.log("METEOR_PACKAGE_STATS_SERVER_URL: " + parseVariable(process.env.METEOR_PACKAGE_STATS_SERVER_URL));46 console.log("DEPLOY_HOSTNAME: " + parseVariable(process.env.DEPLOY_HOSTNAME));47 console.log("METEOR_SESSION_FILE: " + parseVariable(process.env.METEOR_SESSION_FILE));48 console.log("METEOR_PROGRESS_DEBUG: " + parseVariable(process.env.METEOR_PROGRESS_DEBUG));49 console.log("METEOR_PRETTY_OUTPUT: " + parseVariable(process.env.METEOR_PRETTY_OUTPUT));50 console.log("APP_ID: " + parseVariable(process.env.APP_ID));51 console.log("AUTOUPDATE_VERSION: " + parseVariable(process.env.AUTOUPDATE_VERSION));52 console.log("CONSTRAINT_SOLVER_BENCHMARK: " + parseVariable(process.env.CONSTRAINT_SOLVER_BENCHMARK));53 console.log("DDP_DEFAULT_CONNECTION_URL: " + parseVariable(process.env.DDP_DEFAULT_CONNECTION_URL));54 console.log("SERVER_WEBSOCKET_COMPRESSION: " + parseVariable(process.env.SERVER_WEBSOCKET_COMPRESSION));55 console.log("USE_JSESSIONID: " + parseVariable(process.env.USE_JSESSIONID));56 console.log("METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS: " + parseVariable(process.env.METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS));57 console.log("WRITE_RUNNER_JS: " + parseVariable(process.env.WRITE_RUNNER_JS));58 console.log("TINYTEST_FILTER: " + parseVariable(process.env.TINYTEST_FILTER));59 console.log("METEOR_PARENT_PID: " + parseVariable(process.env.METEOR_PARENT_PID));60 console.log("METEOR_TOOL_PATH: " + parseVariable(process.env.METEOR_TOOL_PATH));61 console.log("RUN_ONCE_OUTCOME: " + parseVariable(process.env.RUN_ONCE_OUTCOME));62 console.log("TREE_HASH_DEBUG: " + parseVariable(process.env.TREE_HASH_DEBUG));63 console.log("METEOR_DEBUG_SPRINGBOARD: " + parseVariable(process.env.METEOR_DEBUG_SPRINGBOARD));64 console.log("METEOR_TEST_FAIL_RELEASE_DOWNLOAD: " + parseVariable(process.env.METEOR_TEST_FAIL_RELEASE_DOWNLOAD));65 console.log("METEOR_CATALOG_COMPRESS_RPCS: " + parseVariable(process.env.METEOR_CATALOG_COMPRESS_RPCS));66 console.log("METEOR_TEST_LATEST_RELEASE: " + parseVariable(process.env.METEOR_TEST_LATEST_RELEASE));67 console.log("METEOR_WATCH_POLLING_INTERVAL_MS: " + parseVariable(process.env.METEOR_WATCH_POLLING_INTERVAL_MS));68 console.log("EMACS: " + parseVariable(process.env.EMACS));69 console.log("METEOR_PACKAGE_STATS_TEST_OUTPUT: " + parseVariable(process.env.METEOR_PACKAGE_STATS_TEST_OUTPUT));70 console.log("METEOR_TEST_TMP: " + parseVariable(process.env.METEOR_TEST_TMP));71 }...

Full Screen

Full Screen

VariableParser.spec.js

Source:VariableParser.spec.js Github

copy

Full Screen

1import parseVariable from '../../app/components/build/parsers/VariableParser';2describe('VariableParser parseVariable function', () => {3 it('should return a string for single quotes with whitespace', () => {4 expect(parseVariable(' "testStr" ', {}, {})).toEqual({5 name: '"testStr"',6 type: 'string'7 });8 });9 it('should return a string for double quotes without whitespace', () => {10 expect(parseVariable("'testStr'", {}, {})).toEqual({11 name: "'testStr'",12 type: 'string'13 });14 });15 it('should return a uint for positive number', () => {16 expect(parseVariable('1', {}, {})).toEqual({ name: '1', type: 'uint' });17 });18 it('should return a uint for zero', () => {19 expect(parseVariable('0', {}, {})).toEqual({ name: '0', type: 'uint' });20 });21 it('should return an int for negative number', () => {22 expect(parseVariable('-1', {}, {})).toEqual({ name: '-1', type: 'int' });23 });24 it('should return the correct expression for uint * int', () => {25 expect(parseVariable('-1 * 1', {}, {})).toEqual({26 name: '-1 * int(1)',27 type: 'int'28 });29 });30 it('should return the correct expression for int * uint', () => {31 expect(parseVariable('1 + -1', {}, {})).toEqual({32 name: 'int(1) + -1',33 type: 'int'34 });35 });36 it('should return the correct expression for string + string', () => {37 expect(parseVariable('"a" + "b"', {}, {})).toEqual({38 name: '"a" + "b"',39 type: 'string'40 });41 });42 it('should return correct int type for map on lhs with positive number', () => {43 expect(parseVariable('test map of test str + 5', {}, {})).toEqual({44 name: 'test_map[test_str] + 5',45 type: 'uint'46 });47 });48 it('should return correct uint type for map on rhs with negative number', () => {49 expect(parseVariable('-5 * test map for test str', {}, {})).toEqual({50 name: '-5 * test_map[test_str]',51 type: 'int'52 });53 });54 it('operations with unknown vars return unknown var type', () => {55 expect(parseVariable('a * b', {}, {})).toEqual({56 name: 'a * b',57 type: 'var'58 });59 expect(parseVariable('1 + "a"', {}, {})).toEqual({60 name: '1 + "a"',61 type: 'var'62 });63 });64 it('parseStruct should work with bitsMode off', () => {65 expect(66 parseVariable(67 "a's b",68 { a: 'A' },69 { A: [{ name: 'b', type: 'string', bits: 8 }] },70 false71 )72 ).toEqual({73 name: 'a.b',74 type: 'string'75 });76 });77 it('parseStruct should work with bitsMode on for name', () => {78 expect(79 parseVariable(80 "a's b",81 { a: 'A' },82 { A: [{ name: 'b', type: 'string', bits: 8 }] },83 true84 )85 ).toEqual({86 name: 'a.b',87 type: 'bytes8'88 });89 });90 it('parseStruct should work with bitsMode on for displayName', () => {91 expect(92 parseVariable(93 "a's b",94 { a: 'A' },95 { A: [{ displayName: 'b', type: 'string', bits: 8 }] },96 true97 )98 ).toEqual({99 name: 'a.b',100 type: 'bytes8'101 });102 });103 it('parseStruct should work with ints and bitsMode on', () => {104 expect(105 parseVariable(106 "a's b",107 { a: 'A' },108 { A: [{ name: 'b', type: 'int', bits: 8 }] },109 true110 )111 ).toEqual({112 name: 'a.b',113 type: 'int8'114 });115 });116 it('parseStruct should return null type when attribute is not in struct', () => {117 expect(118 parseVariable(119 "a's c",120 { a: 'A' },121 { A: [{ name: 'b', type: 'int', bits: 8 }] },122 true123 )124 ).toEqual({125 name: 'a.c',126 type: null127 });128 });129 it('parseStruct should throw when type is not in structList', () => {130 expect(() =>131 parseVariable(132 "a's c",133 {},134 { A: [{ name: 'b', type: 'int', bits: 8 }] },135 true136 )137 ).toThrow();138 });139 it('parseMap should work without innerKey', () => {140 expect(141 parseVariable(142 'a for b',143 { a: { from: 'string', to: 'int' }, b: 'string' },144 {}145 )146 ).toEqual({147 name: 'a[b]',148 mapName: 'a',149 keyType: 'string',150 type: 'int'151 });152 });153 it('parseMap should work with innerKey', () => {154 expect(155 parseVariable(156 'a of b of c',157 { a: { from: 'string', to: 'int' }, b: 'string', c: 'bool' },158 {}159 )160 ).toEqual({161 name: 'a[b][c]',162 mapName: 'a',163 keyType: 'string',164 innerKeyType: 'bool',165 type: 'int'166 });167 });168 it('parseKeyword should work for address', () => {169 expect(parseVariable('0x000001', {}, {})).toEqual({170 name: '0x000001',171 type: 'address payable'172 });173 });174 it('parseKeyword should work for msg sender', () => {175 expect(parseVariable('msg sender', {}, {})).toEqual({176 name: 'msg.sender',177 type: 'address payable'178 });179 });180 it('parseKeyword should work for msg value', () => {181 expect(parseVariable('msg value', {}, {})).toEqual({182 name: 'msg.value',183 type: 'uint'184 });185 });186 it('parseKeyword should work for current balance', () => {187 expect(parseVariable('current balance', {}, {})).toEqual({188 name: 'address(this).balance',189 type: 'uint'190 });191 });192 it('parseKeyword should work for current time', () => {193 expect(parseVariable('current time', {}, {})).toEqual({194 name: 'now',195 type: 'uint'196 });197 });198 it('parseKeyword should work for invalid address', () => {199 expect(parseVariable('invalid address', {}, {})).toEqual({200 name: 'address(uint160(0))',201 type: 'address payable'202 });203 });204 it('parseKeyword should work for true', () => {205 expect(parseVariable('yes', {}, {})).toEqual({206 name: 'true',207 type: 'bool'208 });209 });210 it('parseKeyword should work for false', () => {211 expect(parseVariable('no', {}, {})).toEqual({212 name: 'false',213 type: 'bool'214 });215 });216 it('lookupVariableName should work when variable is in variables', () => {217 expect(parseVariable('the var', { the_var: 'int' }, {})).toEqual({218 name: 'the_var',219 type: 'int'220 });221 });222 it('lookupVariableName should not work when variable is not in variables', () => {223 expect(parseVariable('the var', { not_the_var: 'int' }, {})).toEqual({224 name: 'the_var',225 type: 'var'226 });227 });...

Full Screen

Full Screen

PatronInformation.js

Source:PatronInformation.js Github

copy

Full Screen

...33 data.fineItemsCount = this.stringToInt(this.message.substring(49, 53));34 data.recallItemsCount = this.stringToInt(this.message.substring(53, 47));35 data.unavailableHoldsCount = this.stringToInt(this.message.substring(57, 61));36 data.institutionId = this.parseVariableWithoutDelimeter('AO', this.message.substring(61));37 data.patronIdentifier = this.parseVariable('AA', this.message.substring(61));38 data.personalName = this.parseVariable('AE', this.message.substring(61));39 if (this.exists('BZ', this.message.substring(61))) {40 const temp = this.parseVariable('BZ', this.message.substring(61));41 data.holdItemsLimit = this.stringToInt(temp);42 }43 if (this.exists('CA', this.message.substring(61))) {44 const temp = this.parseVariable('CA', this.message.substring(61));45 data.overdueItemsLimit = this.stringToInt(temp);46 }47 if (this.exists('CB', this.message.substring(61))) {48 const temp = this.parseVariable('CB', this.message.substring(61));49 data.chargedItemsLimit = this.stringToInt(temp);50 }51 if (this.existsAndNotEmpty('BL', this.message.substring(61))) {52 const temp = this.parseVariable('BL', this.message.substring(61));53 data.validPatron = this.charToBool(temp.charAt(0));54 data.validPatronUsed = true;55 }56 if (this.existsAndNotEmpty('CQ', this.message.substring(61))) {57 const temp = this.parseVariable('CQ', this.message.substring(61));58 data.validPatronPassword = this.charToBool(temp.charAt(0));59 data.validPatronPasswordUsed = true;60 }61 if (this.existsAndNotEmpty('BH', this.message.substring(61))) {62 const temp = this.parseVariable('BH', this.message.substring(61));63 data.currencyType = CurrencyType.parse(temp);64 }65 data.feeAmount = this.parseVariable('BV', this.message.substring(61));66 data.feeLimit = this.parseVariable('CC', this.message.substring(61));67 Object.keys(ItemType).forEach((key) => {68 const itemType = ItemType[key];69 const temp = this.parseVariableMulti(itemType, this.message.substring(61));70 if (temp && temp.length > 0) {71 data.items = temp;72 data.itemType = key;73 data.itemTypeId = itemType;74 }75 });76 data.homeAddress = this.parseVariable('BD', this.message.substring(61));77 data.email = this.parseVariable('BE', this.message.substring(61));78 data.phone = this.parseVariable('BF', this.message.substring(61));79 data.screenMessage = this.parseVariableMulti('AF', this.message.substring(61));80 data.printLine = this.parseVariableMulti('AG', this.message.substring(61));81 if (this.parseSequence(this.message) !== '') {82 data.sequence = parseInt(this.parseSequence(this.message), 10);83 }84 data.checksum = this.parseChecksum(this.message);85 return data;86 }87}...

Full Screen

Full Screen

Checkout.js

Source:Checkout.js Github

copy

Full Screen

...23 data.desensitize = this.charToBool(this.message.charAt(5));24 }25 data.transactionDate = this.parseDateTime(this.message.substring(6, 24));26 data.institutionId = this.parseVariableWithoutDelimeter('AO', this.message.substring(24));27 data.patronIdentifier = this.parseVariable('AA', this.message.substring(24));28 data.itemIdentifier = this.parseVariable('AB', this.message.substring(24));29 data.titleIdentifier = this.parseVariable('AJ', this.message.substring(24));30 data.dueDate = this.parseVariable('AH', this.message.substring(24));31 if (this.existsAndNotEmpty('CK', this.message.substring(24))) {32 data.mediaType = MediaType.parse(this.parseVariable('CK', this.message.substring(24)));33 }34 data.itemProperties = this.parseVariable('CH', this.message.substring(24));35 data.transactionId = this.parseVariable('BK', this.message.substring(24));36 data.feeAmount = this.parseVariable('BV', this.message.substring(24));37 data.screenMessage = this.parseVariableMulti('AF', this.message.substring(24));38 data.printLine = this.parseVariableMulti('AG', this.message.substring(24));39 if (this.parseSequence(this.message) !== '') {40 data.sequence = parseInt(this.parseSequence(this.message), 10);41 }42 data.checksum = this.parseChecksum(this.message);43 return data;44 }45}...

Full Screen

Full Screen

environment.test.js

Source:environment.test.js Github

copy

Full Screen

1import { expect } from "chai";2import environment from "../../app/helpers/environment";3describe(".parseVariable()", () => {4 it("should return undefined when variable is undefined", () => {5 expect(environment.parseVariable()).to.be.undefined;6 });7 it("should return undefined when variable is null", () => {8 expect(environment.parseVariable(null)).to.be.undefined;9 });10 it("should return undefined when variable is empty string", () => {11 expect(environment.parseVariable("")).to.be.undefined;12 });13 it("should return parsed object", () => {14 expect(environment.parseVariable("{\"someProps\":true}"))15 .to.deep.equal({ someProps: true });16 });17 it("should return parsed array", () => {18 expect(environment.parseVariable("[1,2,3]"))19 .to.deep.equal([1, 2, 3]);20 });21 it("should return parsed number", () => {22 expect(environment.parseVariable("852"))23 .to.deep.equal(852);24 });...

Full Screen

Full Screen

contentparser.js

Source:contentparser.js Github

copy

Full Screen

...5 var regex = /\[(\$[a-zA-Z][\w|.|]*)]/g;6 var match;7 while (match = regex.exec(str)) {8 var lMatch = match[1];9 str = str.replace(lMatch, parseVariable(lMatch, settings));10 }11 // Then evaluate others i.e. foo.bar[0]12 regex = /#{(\$[a-zA-Z][\w|.|\[|\]]*)}/g;13 while (match = regex.exec(str)) {14 var lMatch = match[1];15 str = str.replace(match[0], parseVariable(lMatch, settings));16 }17 return str;18}19function parseVariable(str, settings) {20 // remove dollarsign; Variablename: $var21 str = trimmer.trimVariableName(str);22 try {23 str = str.replace(str, eval('(settings.'+str+')'));24 } catch (ex) {}25 return str;26}27module.exports = {28 "parseString": parseString,29 "parseVariable": parseVariable...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('My test', async ({ page }) => {3 const title = await page.innerText('.navbar__inner .navbar__title');4 expect(title).toBe('Playwright');5});6 ✓ My test (1s)7 1 passed (2s)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseVariable } = require('@playwright/test/lib/utils/variableSubstitution');2console.log(variable);3const { parseVariable } = require('@playwright/test/lib/utils/variableSubstitution');4console.log(variable);5const { parseVariable } = require('@playwright/test/lib/utils/variableSubstitution');6console.log(variable);7const { parseVariable } = require('@playwright/test/lib/utils/variableSubstitution');8console.log(variable);9const { test } = require('@playwright/test');10test.use({

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseVariable } = require('playwright/test');2const url = parseVariable('${URL}');3const { test } = require('playwright-test');4test('my test', async ({ page }) => {5 const title = page.locator('.navbar__title');6 await expect(title).toHaveText('Playwright');7});

Full Screen

Playwright tutorial

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.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful