How to use isAsync method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

extract_functions.test.ts

Source:extract_functions.test.ts Github

copy

Full Screen

1import { AST_NODE_TYPES } from '@typescript-eslint/typescript-estree'2import { AstParser } from '~src/AstParser'3import { extractFunctions } from '~src/extracts/extract_functions'4import { InlineInput } from '~src/input/InlineInput'5describe('extractFunctions', () => {6 test('smoke test', () => {7 const [{ program, source }] = AstParser.ANALYZER.parseSync(8 'function twoFer(name="you") { return `One for ${you}, one for me.` }'9 )10 const [twoFer] = extractFunctions(program)11 expect(twoFer).not.toBeUndefined()12 expect(twoFer.name).toBe('twoFer')13 expect(twoFer.body).not.toBeUndefined()14 expect(twoFer.body.range).toStrictEqual([15 source.indexOf('{'),16 source.lastIndexOf('}') + 1,17 ])18 expect(twoFer.params).toHaveLength(1)19 expect(twoFer.params[0].type).toBe(AST_NODE_TYPES.AssignmentPattern)20 expect(twoFer.node.range).toStrictEqual([0, source.length])21 })22 describe('function declarations', () => {23 const functions = {24 supported: [25 [26 `function declaration() { return 42 }`,27 'declaration',28 { isGenerator: false, isAsync: false },29 ],30 [31 `function* declaration() { yield 42 }`,32 'declaration',33 { isGenerator: true, isAsync: false },34 ],35 [36 `async function declaration() { }`,37 'declaration',38 { isGenerator: false, isAsync: true },39 ],40 [41 `async function* declaration() { }`,42 'declaration',43 { isGenerator: true, isAsync: true },44 ],45 ] as const,46 unsupported: [],47 }48 describe('finds a function declaration', () => {49 functions.supported.forEach(([source, name, metadata]) => {50 test(`such as "${source}"`, async () => {51 const input = new InlineInput([source])52 const [{ program }] = await AstParser.ANALYZER.parse(input)53 const [foundFunction, ...others] = extractFunctions(program)54 expect(others).toHaveLength(0)55 expect(foundFunction).not.toBeUndefined()56 expect(foundFunction.name).toBe(name)57 expect(foundFunction.type).toBe('declaration')58 const keys = Object.keys(metadata) as (keyof typeof metadata)[]59 keys.forEach((key) => {60 const expected = metadata[key]61 expect(foundFunction.metadata[key]).toBe(expected)62 })63 })64 })65 })66 })67 describe('variable declaration with (arrow) function expression', () => {68 const functions = {69 supported: [70 [71 `const named = function () { return 42 }`,72 'named',73 { isGenerator: false, isAsync: false },74 'const',75 ],76 [77 `const named = function* () { return 42 }`,78 'named',79 { isGenerator: true, isAsync: false },80 'const',81 ],82 [83 `const named = async function() { }`,84 'named',85 { isGenerator: false, isAsync: true },86 'const',87 ],88 [89 `const named = async function*() { }`,90 'named',91 { isGenerator: true, isAsync: true },92 'const',93 ],94 [95 `let named = function () { return 42 }`,96 'named',97 { isGenerator: false, isAsync: false },98 'let',99 ],100 [101 `let named = function* () { return 42 }`,102 'named',103 { isGenerator: true, isAsync: false },104 'let',105 ],106 [107 `let named = async function() { }`,108 'named',109 { isGenerator: false, isAsync: true },110 'let',111 ],112 [113 `let named = async function*() { }`,114 'named',115 { isGenerator: true, isAsync: true },116 'let',117 ],118 [119 `var named = function () { return 42 }`,120 'named',121 { isGenerator: false, isAsync: false },122 'var',123 ],124 [125 `var named = function* () { return 42 }`,126 'named',127 { isGenerator: true, isAsync: false },128 'var',129 ],130 [131 `var named = async function() { }`,132 'named',133 { isGenerator: false, isAsync: true },134 'var',135 ],136 [137 `var named = async function*() { }`,138 'named',139 { isGenerator: true, isAsync: true },140 'var',141 ],142 [143 `const named = () => { return 42 }`,144 'named',145 { isGenerator: false, isAsync: false },146 'const',147 ],148 [149 `const named = () => 42`,150 'named',151 { isGenerator: false, isAsync: false },152 'const',153 ],154 [155 `const named = async () => { }`,156 'named',157 { isGenerator: false, isAsync: true },158 'const',159 ],160 [161 `const named = async () => 42`,162 'named',163 { isGenerator: false, isAsync: true },164 'const',165 ],166 [167 `let named = () => { }`,168 'named',169 { isGenerator: false, isAsync: false },170 'let',171 ],172 [173 `var named = async () => { }`,174 'named',175 { isGenerator: false, isAsync: true },176 'var',177 ],178 ] as const,179 unsupported: [],180 }181 describe('finds a variable declaration with a(n) (arrow) function expression', () => {182 functions.supported.forEach(([source, name, metadata, kind]) => {183 test(`of kind ${kind}, such as "${source}"`, async () => {184 const input = new InlineInput([source])185 const [{ program }] = await AstParser.ANALYZER.parse(input)186 const [foundFunction, ...others] = extractFunctions(program)187 expect(others).toHaveLength(0)188 expect(foundFunction).not.toBeUndefined()189 expect(foundFunction.name).toBe(name)190 expect(foundFunction.type).toBe('expression')191 expect(foundFunction.metadata.variable).not.toBeUndefined()192 expect(foundFunction.metadata.variable?.kind).toBe(kind)193 const keys = Object.keys(metadata) as (keyof typeof metadata)[]194 keys.forEach((key) => {195 const expected = metadata[key]196 expect(foundFunction.metadata[key]).toBe(expected)197 })198 })199 })200 })201 })202 describe('classes with functions', () => {203 const functions = {204 properties: [205 [206 `class Klazz { property = () => { return 42 }; }`,207 'property',208 { isAsync: false, isGenerator: false, isStatic: false },209 ],210 [211 `class Klazz { property = async () => {}; }`,212 'property',213 { isAsync: true, isGenerator: false, isStatic: false },214 ],215 [216 `class Klazz { property = function () { return 42 }; }`,217 'property',218 { isAsync: false, isGenerator: false, isStatic: false },219 ],220 [221 `class Klazz { property = function* () { yield 42 }; }`,222 'property',223 { isAsync: false, isGenerator: true, isStatic: false },224 ],225 [226 `class Klazz { property = async function () { }; }`,227 'property',228 { isAsync: true, isGenerator: false, isStatic: false },229 ],230 [231 `class Klazz { property = async function* () { }; }`,232 'property',233 { isAsync: true, isGenerator: true, isStatic: false },234 ],235 [236 `class Klazz { static property = () => { return 42 }; }`,237 'property',238 { isAsync: false, isGenerator: false, isStatic: true },239 ],240 [241 `class Klazz { static property = async () => {}; }`,242 'property',243 { isAsync: true, isGenerator: false, isStatic: true },244 ],245 [246 `class Klazz { static property = function () { return 42 }; }`,247 'property',248 { isAsync: false, isGenerator: false, isStatic: true },249 ],250 [251 `class Klazz { static property = function* () { yield 42 }; }`,252 'property',253 { isAsync: false, isGenerator: true, isStatic: true },254 ],255 [256 `class Klazz { static property = async function () { }; }`,257 'property',258 { isAsync: true, isGenerator: false, isStatic: true },259 ],260 [261 `class Klazz { static property = async function* () { }; }`,262 'property',263 { isAsync: true, isGenerator: true, isStatic: true },264 ],265 [266 `class Klazz { [name] = () => {}; }`,267 undefined,268 { isAsync: false, isGenerator: false, isStatic: false },269 ],270 [271 `class Klazz { [name] = async () => {}; }`,272 undefined,273 { isAsync: true, isGenerator: false, isStatic: false },274 ],275 [276 `class Klazz { [name] = function () { return 42 }; }`,277 undefined,278 { isAsync: false, isGenerator: false, isStatic: false },279 ],280 [281 `class Klazz { [name] = function* () { yield 42 }; }`,282 undefined,283 { isAsync: false, isGenerator: true, isStatic: false },284 ],285 [286 `class Klazz { [name] = async function () { }; }`,287 undefined,288 { isAsync: true, isGenerator: false, isStatic: false },289 ],290 [291 `class Klazz { [name] = async function* () { }; }`,292 undefined,293 { isAsync: true, isGenerator: true, isStatic: false },294 ],295 [296 `class Klazz { static [name] = () => { return 42 }; }`,297 undefined,298 { isAsync: false, isGenerator: false, isStatic: true },299 ],300 [301 `class Klazz { static [name] = async () => {}; }`,302 undefined,303 { isAsync: true, isGenerator: false, isStatic: true },304 ],305 [306 `class Klazz { static [name] = function () { return 42 }; }`,307 undefined,308 { isAsync: false, isGenerator: false, isStatic: true },309 ],310 [311 `class Klazz { static [name] = function* () { yield 42 }; }`,312 undefined,313 { isAsync: false, isGenerator: true, isStatic: true },314 ],315 [316 `class Klazz { static [name] = async function () { }; }`,317 undefined,318 { isAsync: true, isGenerator: false, isStatic: true },319 ],320 [321 `class Klazz { static [name] = async function* () { }; }`,322 undefined,323 { isAsync: true, isGenerator: true, isStatic: true },324 ],325 ] as const,326 methods: [327 [328 `class Klazz { constructor() { } }`,329 'constructor',330 { isAsync: false, isGenerator: false, isStatic: false },331 'constructor',332 ],333 [334 `class Klazz { get property() { return 42 } }`,335 'property',336 { isAsync: false, isGenerator: false, isStatic: false },337 'getter',338 ],339 [340 `class Klazz { set property(value) { } }`,341 'property',342 { isAsync: false, isGenerator: false, isStatic: false },343 'setter',344 ],345 [346 `class Klazz { shorthand() { return 42 } }`,347 'shorthand',348 { isAsync: false, isGenerator: false, isStatic: false },349 'method',350 ],351 [352 `class Klazz { *shorthand() { return 42 } }`,353 'shorthand',354 { isAsync: false, isGenerator: true, isStatic: false },355 'method',356 ],357 [358 `class Klazz { async shorthand() { } }`,359 'shorthand',360 { isAsync: true, isGenerator: false, isStatic: false },361 'method',362 ],363 [364 `class Klazz { async *shorthand() { } }`,365 'shorthand',366 { isAsync: true, isGenerator: true, isStatic: false },367 'method',368 ],369 [370 `class Klazz { [name]() { return 42 } }`,371 undefined,372 { isAsync: false, isGenerator: false, isStatic: false },373 'method',374 ],375 [376 `class Klazz { *[name]() { yield 42 } }`,377 undefined,378 { isAsync: false, isGenerator: true, isStatic: false },379 'method',380 ],381 [382 `class Klazz { async [name]() { } }`,383 undefined,384 { isAsync: true, isGenerator: false, isStatic: false },385 'method',386 ],387 [388 `class Klazz { async *[name]() { } }`,389 undefined,390 { isAsync: true, isGenerator: true, isStatic: false },391 'method',392 ],393 [394 `class Klazz { static shorthand() { return 42 } }`,395 'shorthand',396 { isAsync: false, isGenerator: false, isStatic: true },397 'method',398 ],399 [400 `class Klazz { static *shorthand() { yield 42 } }`,401 'shorthand',402 { isAsync: false, isGenerator: true, isStatic: true },403 'method',404 ],405 [406 `class Klazz { static async shorthand() {} }`,407 'shorthand',408 { isAsync: true, isGenerator: false, isStatic: true },409 'method',410 ],411 [412 `class Klazz { static async *shorthand() {} }`,413 'shorthand',414 { isAsync: true, isGenerator: true, isStatic: true },415 'method',416 ],417 [418 `class Klazz { static [name]() { return 42 } }`,419 undefined,420 { isAsync: false, isGenerator: false, isStatic: true },421 'method',422 ],423 [424 `class Klazz { static *[name]() { yield 42 } }`,425 undefined,426 { isAsync: false, isGenerator: true, isStatic: true },427 'method',428 ],429 [430 `class Klazz { static async [name]() { } }`,431 undefined,432 { isAsync: true, isGenerator: false, isStatic: true },433 'method',434 ],435 [436 `class Klazz { static async *[name]() { } }`,437 undefined,438 { isAsync: true, isGenerator: true, isStatic: true },439 'method',440 ],441 ] as const,442 proto: [443 [444 `Klazz.prototype.fn = () => { }`,445 'fn',446 { isAsync: false, isGenerator: false },447 ],448 [449 `Klazz.prototype.fn = async () => { }`,450 'fn',451 { isAsync: true, isGenerator: false },452 ],453 [454 `Klazz.prototype.fn = function () { }`,455 'fn',456 { isAsync: false, isGenerator: false },457 ],458 [459 `Klazz.prototype.fn = function* () { }`,460 'fn',461 { isAsync: false, isGenerator: true },462 ],463 [464 `Klazz.prototype.fn = async function () { }`,465 'fn',466 { isAsync: true, isGenerator: false },467 ],468 [469 `Klazz.prototype.fn = async function* () { }`,470 'fn',471 { isAsync: true, isGenerator: true },472 ],473 ] as const,474 }475 describe('class properties', () => {476 describe(`finds a class-property`, () => {477 functions.properties.forEach(([source, name, metadata]) => {478 test(`such as "${source}"`, async () => {479 const input = new InlineInput([source])480 const [{ program }] = await AstParser.ANALYZER.parse(input)481 const [foundFunction, ...others] = extractFunctions(program)482 expect(others).toHaveLength(0)483 expect(foundFunction).not.toBeUndefined()484 expect(foundFunction.name).toBe(name)485 expect(foundFunction.type).toBe('class-property')486 expect(foundFunction.metadata.klazz).toBe('Klazz')487 const keys = Object.keys(metadata) as (keyof typeof metadata)[]488 keys.forEach((key) => {489 const expected = metadata[key]490 expect(foundFunction.metadata[key]).toBe(expected)491 })492 })493 })494 })495 })496 describe('class method definitions', () => {497 describe(`finds a method`, () => {498 functions.methods.forEach(([source, name, metadata, kind]) => {499 test(`a ${kind}, such as "${source}"`, async () => {500 const input = new InlineInput([source])501 const [{ program }] = await AstParser.ANALYZER.parse(input)502 const [foundFunction, ...others] = extractFunctions(program)503 expect(others).toHaveLength(0)504 expect(foundFunction).not.toBeUndefined()505 expect(foundFunction.name).toBe(name)506 expect(foundFunction.type).toBe(kind)507 expect(foundFunction.metadata.klazz).toBe('Klazz')508 const keys = Object.keys(metadata) as (keyof typeof metadata)[]509 keys.forEach((key) => {510 const expected = metadata[key]511 expect(foundFunction.metadata[key]).toBe(expected)512 })513 })514 })515 })516 })517 describe('class prototype assignments', () => {518 describe('finds a prototype-assignment', () => {519 functions.proto.forEach(([source, name, metadata]) => {520 test(`such as "${source}"`, async () => {521 const input = new InlineInput([source])522 const [{ program }] = await AstParser.ANALYZER.parse(input)523 const [foundFunction, ...others] = extractFunctions(program)524 expect(others).toHaveLength(0)525 expect(foundFunction).not.toBeUndefined()526 expect(foundFunction.name).toBe(name)527 expect(foundFunction.type).toBe('prototype-assignment')528 expect(foundFunction.metadata.klazz).toBe('Klazz')529 const keys = Object.keys(metadata) as (keyof typeof metadata)[]530 keys.forEach((key) => {531 const expected = metadata[key]532 expect(foundFunction.metadata[key]).toBe(expected)533 })534 })535 })536 })537 })538 })539 describe('object property', () => {540 const functions = {541 supported: [542 [`const collection = { shorthand() { return 42 } }`, 'shorthand'],543 [`const collection = { *shorthand() { yield 42 } }`, 'shorthand'],544 [`const collection = { async shorthand() { } }`, 'shorthand'],545 [`const collection = { async *shorthand() { } }`, 'shorthand'],546 [`const collection = { [computed]() { return 42 } }`, undefined],547 [`const collection = { *[computed]() { yield 42 } }`, undefined],548 [`const collection = { async [computed]() { } }`, undefined],549 [`const collection = { async *[computed]() { } }`, undefined],550 [`const collection = { property: () => { return 42 } }`, 'property'],551 [`const collection = { property: async () => {} }`, 'property'],552 [553 `const collection = { property: function () { return 42 } }`,554 'property',555 ],556 [557 `const collection = { property: function* () { yield 42 } }`,558 'property',559 ],560 [`const collection = { property: async function () {} }`, 'property'],561 [`const collection = { property: async function* () {} }`, 'property'],562 [`const collection = { [computed]: () => { return 42 } }`, undefined],563 [`const collection = { [computed]: async () => {} }`, undefined],564 [565 `const collection = { [computed]: function () { return 42 } }`,566 undefined,567 ],568 [569 `const collection = { [computed]: function* () { yield 42 } }`,570 undefined,571 ],572 [`const collection = { [computed]: async function () {} }`, undefined],573 [574 `const collection = { [computed]: async function* () {} }`,575 undefined,576 ],577 ] as const,578 }579 describe('finds a function as an object property', () => {580 functions.supported.forEach(([source, name]) => {581 test(`such as "${source}"`, async () => {582 const input = new InlineInput([source])583 const [{ program }] = await AstParser.ANALYZER.parse(input)584 const [foundFunction, ...others] = extractFunctions(program)585 expect(others).toHaveLength(0)586 expect(foundFunction).not.toBeUndefined()587 expect(foundFunction.name).toBe(name)588 expect(foundFunction.type).toBe('property')589 })590 })591 })592 })593 describe('export default object', () => {594 const functions = {595 supported: [596 [`export default { name: () => {} }`, 'name'],597 [`export default { name: async () => {} }`, 'name'],598 [`export default { name: function () {} }`, 'name'],599 [`export default { name: function* () {} }`, 'name'],600 [`export default { name: async function () {} }`, 'name'],601 [`export default { name: async function* () {} }`, 'name'],602 [`export default { [computed]: () => {} }`, undefined],603 [`export default { [computed]: async () => {} }`, undefined],604 [`export default { [computed]: function () {} }`, undefined],605 [`export default { [computed]: function* () {} }`, undefined],606 [`export default { [computed]: async function () {} }`, undefined],607 [`export default { [computed]: async function* () {} }`, undefined],608 [`export default { name() {} }`, 'name'],609 [`export default { *name() {} }`, 'name'],610 [`export default { async name() {} }`, 'name'],611 [`export default { async *name() {} }`, 'name'],612 [`export default { [computed]() {} }`, undefined],613 [`export default { *[computed]() {} }`, undefined],614 [`export default { async [computed]() {} }`, undefined],615 [`export default { async *[computed]() {} }`, undefined],616 ] as const,617 }618 describe('finds a function exported as a default object property', () => {619 functions.supported.forEach(([source, name]) => {620 test(`such as "${source}"`, async () => {621 const input = new InlineInput([source])622 const [{ program }] = await AstParser.ANALYZER.parse(input)623 const [foundFunction, ...others] = extractFunctions(program)624 expect(others).toHaveLength(0)625 expect(foundFunction).not.toBeUndefined()626 expect(foundFunction.name).toBe(name)627 expect(foundFunction.type).toBe('property')628 })629 })630 })631 })632 describe('multiple functions', () => {633 test('finds them all', async () => {634 const [{ program }] = AstParser.ANALYZER.parseSync(`635function declaration() { return 42 }636const declaration2 = function* hiddenName() { yield 42 }637const declaration3 = () => { return 42 }638const collection = {639 shorthand() { return 42 },640 property: async () => {},641 [computed]: function* () { yield 42 },642}643Klazz.prototype.fn = () => { }`)644 const [fn1, fn2, fn3, fn4, fn5, fn6, fn7, ...others] =645 extractFunctions(program)646 expect(others).toHaveLength(0)647 expect(fn7).not.toBeUndefined()648 expect(fn1.name).toBe('declaration')649 expect(fn2.name).toBe('declaration2')650 expect(fn3.name).toBe('declaration3')651 expect(fn4.name).toBe('shorthand')652 expect(fn5.name).toBe('property')653 expect(fn6.name).toBe(undefined)654 expect(fn7.name).toBe('fn')655 })656 test('ignores nested functions', async () => {657 const [{ program }] = AstParser.ANALYZER.parseSync(`658function declaration() { return () => {} }659const declaration2 = function* hiddenName() { yield function () {} }660const declaration3 = () => { return () => 42 }661const collection = {662 shorthand() { return () => () => {} },663 property: async () => { function nope() {} },664 [computed]: function* () { function nope() {} },665}666Klazz.prototype.fn = () => { return () => {} }`)667 const [fn1, fn2, fn3, fn4, fn5, fn6, fn7, ...others] =668 extractFunctions(program)669 expect(others).toHaveLength(0)670 expect(fn7).not.toBeUndefined()671 expect(fn1.name).toBe('declaration')672 expect(fn2.name).toBe('declaration2')673 expect(fn3.name).toBe('declaration3')674 expect(fn4.name).toBe('shorthand')675 expect(fn5.name).toBe('property')676 expect(fn6.name).toBe(undefined)677 expect(fn7.name).toBe('fn')678 })679 })...

Full Screen

Full Screen

codes.ts

Source:codes.ts Github

copy

Full Screen

1import Common from '@ethereumjs/common'2import { getFullname } from './util'3export class Opcode {4 readonly code: number5 readonly name: string6 readonly fullName: string7 readonly fee: number8 readonly isAsync: boolean9 constructor({10 code,11 name,12 fullName,13 fee,14 isAsync,15 }: {16 code: number17 name: string18 fullName: string19 fee: number20 isAsync: boolean21 }) {22 this.code = code23 this.name = name24 this.fullName = fullName25 this.fee = fee26 this.isAsync = isAsync27 // Opcode isn't subject to change, thus all futher modifications are prevented.28 Object.freeze(this)29 }30}31export type OpcodeList = Map<number, Opcode>32// Base opcode list. The opcode list is extended in future hardforks33const opcodes = {34 // 0x0 range - arithmetic ops35 // name, async36 0x00: { name: 'STOP', isAsync: false },37 0x01: { name: 'ADD', isAsync: false },38 0x02: { name: 'MUL', isAsync: false },39 0x03: { name: 'SUB', isAsync: false },40 0x04: { name: 'DIV', isAsync: false },41 0x05: { name: 'SDIV', isAsync: false },42 0x06: { name: 'MOD', isAsync: false },43 0x07: { name: 'SMOD', isAsync: false },44 0x08: { name: 'ADDMOD', isAsync: false },45 0x09: { name: 'MULMOD', isAsync: false },46 0x0a: { name: 'EXP', isAsync: false },47 0x0b: { name: 'SIGNEXTEND', isAsync: false },48 // 0x10 range - bit ops49 0x10: { name: 'LT', isAsync: false },50 0x11: { name: 'GT', isAsync: false },51 0x12: { name: 'SLT', isAsync: false },52 0x13: { name: 'SGT', isAsync: false },53 0x14: { name: 'EQ', isAsync: false },54 0x15: { name: 'ISZERO', isAsync: false },55 0x16: { name: 'AND', isAsync: false },56 0x17: { name: 'OR', isAsync: false },57 0x18: { name: 'XOR', isAsync: false },58 0x19: { name: 'NOT', isAsync: false },59 0x1a: { name: 'BYTE', isAsync: false },60 // 0x20 range - crypto61 0x20: { name: 'SHA3', isAsync: false },62 // 0x30 range - closure state63 0x30: { name: 'ADDRESS', isAsync: true },64 0x31: { name: 'BALANCE', isAsync: true },65 0x32: { name: 'ORIGIN', isAsync: true },66 0x33: { name: 'CALLER', isAsync: true },67 0x34: { name: 'CALLVALUE', isAsync: true },68 0x35: { name: 'CALLDATALOAD', isAsync: true },69 0x36: { name: 'CALLDATASIZE', isAsync: true },70 0x37: { name: 'CALLDATACOPY', isAsync: true },71 0x38: { name: 'CODESIZE', isAsync: false },72 0x39: { name: 'CODECOPY', isAsync: false },73 0x3a: { name: 'GASPRICE', isAsync: false },74 0x3b: { name: 'EXTCODESIZE', isAsync: true },75 0x3c: { name: 'EXTCODECOPY', isAsync: true },76 // '0x40' range - block operations77 0x40: { name: 'BLOCKHASH', isAsync: true },78 0x41: { name: 'COINBASE', isAsync: true },79 0x42: { name: 'TIMESTAMP', isAsync: true },80 0x43: { name: 'NUMBER', isAsync: true },81 0x44: { name: 'DIFFICULTY', isAsync: true },82 0x45: { name: 'GASLIMIT', isAsync: true },83 // 0x50 range - 'storage' and execution84 0x50: { name: 'POP', isAsync: false },85 0x51: { name: 'MLOAD', isAsync: false },86 0x52: { name: 'MSTORE', isAsync: false },87 0x53: { name: 'MSTORE8', isAsync: false },88 0x54: { name: 'SLOAD', isAsync: true },89 0x55: { name: 'SSTORE', isAsync: true },90 0x56: { name: 'JUMP', isAsync: false },91 0x57: { name: 'JUMPI', isAsync: false },92 0x58: { name: 'PC', isAsync: false },93 0x59: { name: 'MSIZE', isAsync: false },94 0x5a: { name: 'GAS', isAsync: false },95 0x5b: { name: 'JUMPDEST', isAsync: false },96 // 0x60, range97 0x60: { name: 'PUSH', isAsync: false },98 0x61: { name: 'PUSH', isAsync: false },99 0x62: { name: 'PUSH', isAsync: false },100 0x63: { name: 'PUSH', isAsync: false },101 0x64: { name: 'PUSH', isAsync: false },102 0x65: { name: 'PUSH', isAsync: false },103 0x66: { name: 'PUSH', isAsync: false },104 0x67: { name: 'PUSH', isAsync: false },105 0x68: { name: 'PUSH', isAsync: false },106 0x69: { name: 'PUSH', isAsync: false },107 0x6a: { name: 'PUSH', isAsync: false },108 0x6b: { name: 'PUSH', isAsync: false },109 0x6c: { name: 'PUSH', isAsync: false },110 0x6d: { name: 'PUSH', isAsync: false },111 0x6e: { name: 'PUSH', isAsync: false },112 0x6f: { name: 'PUSH', isAsync: false },113 0x70: { name: 'PUSH', isAsync: false },114 0x71: { name: 'PUSH', isAsync: false },115 0x72: { name: 'PUSH', isAsync: false },116 0x73: { name: 'PUSH', isAsync: false },117 0x74: { name: 'PUSH', isAsync: false },118 0x75: { name: 'PUSH', isAsync: false },119 0x76: { name: 'PUSH', isAsync: false },120 0x77: { name: 'PUSH', isAsync: false },121 0x78: { name: 'PUSH', isAsync: false },122 0x79: { name: 'PUSH', isAsync: false },123 0x7a: { name: 'PUSH', isAsync: false },124 0x7b: { name: 'PUSH', isAsync: false },125 0x7c: { name: 'PUSH', isAsync: false },126 0x7d: { name: 'PUSH', isAsync: false },127 0x7e: { name: 'PUSH', isAsync: false },128 0x7f: { name: 'PUSH', isAsync: false },129 0x80: { name: 'DUP', isAsync: false },130 0x81: { name: 'DUP', isAsync: false },131 0x82: { name: 'DUP', isAsync: false },132 0x83: { name: 'DUP', isAsync: false },133 0x84: { name: 'DUP', isAsync: false },134 0x85: { name: 'DUP', isAsync: false },135 0x86: { name: 'DUP', isAsync: false },136 0x87: { name: 'DUP', isAsync: false },137 0x88: { name: 'DUP', isAsync: false },138 0x89: { name: 'DUP', isAsync: false },139 0x8a: { name: 'DUP', isAsync: false },140 0x8b: { name: 'DUP', isAsync: false },141 0x8c: { name: 'DUP', isAsync: false },142 0x8d: { name: 'DUP', isAsync: false },143 0x8e: { name: 'DUP', isAsync: false },144 0x8f: { name: 'DUP', isAsync: false },145 0x90: { name: 'SWAP', isAsync: false },146 0x91: { name: 'SWAP', isAsync: false },147 0x92: { name: 'SWAP', isAsync: false },148 0x93: { name: 'SWAP', isAsync: false },149 0x94: { name: 'SWAP', isAsync: false },150 0x95: { name: 'SWAP', isAsync: false },151 0x96: { name: 'SWAP', isAsync: false },152 0x97: { name: 'SWAP', isAsync: false },153 0x98: { name: 'SWAP', isAsync: false },154 0x99: { name: 'SWAP', isAsync: false },155 0x9a: { name: 'SWAP', isAsync: false },156 0x9b: { name: 'SWAP', isAsync: false },157 0x9c: { name: 'SWAP', isAsync: false },158 0x9d: { name: 'SWAP', isAsync: false },159 0x9e: { name: 'SWAP', isAsync: false },160 0x9f: { name: 'SWAP', isAsync: false },161 0xa0: { name: 'LOG', isAsync: false },162 0xa1: { name: 'LOG', isAsync: false },163 0xa2: { name: 'LOG', isAsync: false },164 0xa3: { name: 'LOG', isAsync: false },165 0xa4: { name: 'LOG', isAsync: false },166 // '0xf0' range - closures167 0xf0: { name: 'CREATE', isAsync: true },168 0xf1: { name: 'CALL', isAsync: true },169 0xf2: { name: 'CALLCODE', isAsync: true },170 0xf3: { name: 'RETURN', isAsync: false },171 // '0x70', range - other172 0xfe: { name: 'INVALID', isAsync: false },173 0xff: { name: 'SELFDESTRUCT', isAsync: true },174}175// Array of hard forks in order. These changes are repeatedly applied to `opcodes` until the hard fork is in the future based upon the common176// TODO: All gas price changes should be moved to common177// If the base gas cost of any of the operations change, then these should also be added to this list.178// If there are context variables changed (such as "warm slot reads") which are not the base gas fees,179// Then this does not have to be added.180const hardforkOpcodes = [181 {182 hardforkName: 'homestead',183 opcodes: {184 0xf4: { name: 'DELEGATECALL', isAsync: true }, // EIP 7185 },186 },187 {188 hardforkName: 'tangerineWhistle',189 opcodes: {190 0x54: { name: 'SLOAD', isAsync: true },191 0xf1: { name: 'CALL', isAsync: true },192 0xf2: { name: 'CALLCODE', isAsync: true },193 0x3b: { name: 'EXTCODESIZE', isAsync: true },194 0x3c: { name: 'EXTCODECOPY', isAsync: true },195 0xf4: { name: 'DELEGATECALL', isAsync: true }, // EIP 7196 0xff: { name: 'SELFDESTRUCT', isAsync: true },197 0x31: { name: 'BALANCE', isAsync: true },198 },199 },200 {201 hardforkName: 'byzantium',202 opcodes: {203 0xfd: { name: 'REVERT', isAsync: false }, // EIP 140204 0xfa: { name: 'STATICCALL', isAsync: true }, // EIP 214205 0x3d: { name: 'RETURNDATASIZE', isAsync: true }, // EIP 211206 0x3e: { name: 'RETURNDATACOPY', isAsync: true }, // EIP 211207 },208 },209 {210 hardforkName: 'constantinople',211 opcodes: {212 0x1b: { name: 'SHL', isAsync: false }, // EIP 145213 0x1c: { name: 'SHR', isAsync: false }, // EIP 145214 0x1d: { name: 'SAR', isAsync: false }, // EIP 145215 0x3f: { name: 'EXTCODEHASH', isAsync: true }, // EIP 1052216 0xf5: { name: 'CREATE2', isAsync: true }, // EIP 1014217 },218 },219 {220 hardforkName: 'istanbul',221 opcodes: {222 0x46: { name: 'CHAINID', isAsync: false }, // EIP 1344223 0x47: { name: 'SELFBALANCE', isAsync: false }, // EIP 1884224 },225 },226]227const eipOpcodes = [228 {229 eip: 2315,230 opcodes: {231 0x5c: { name: 'BEGINSUB', isAsync: false },232 0x5d: { name: 'RETURNSUB', isAsync: false },233 0x5e: { name: 'JUMPSUB', isAsync: false },234 },235 },236 {237 eip: 3198,238 opcodes: {239 0x48: { name: 'BASEFEE', isAsync: false },240 },241 },242]243/**244 * Convert basic opcode info dictonary into complete OpcodeList instance.245 *246 * @param opcodes {Object} Receive basic opcodes info dictionary.247 * @returns {OpcodeList} Complete Opcode list248 */249function createOpcodes(opcodes: {250 [key: number]: { name: string; fee: number; isAsync: boolean }251}): OpcodeList {252 const result: OpcodeList = new Map()253 for (const [key, value] of Object.entries(opcodes)) {254 const code = parseInt(key, 10)255 result.set(256 code,257 new Opcode({258 code,259 fullName: getFullname(code, value.name),260 ...value,261 })262 )263 }264 return result265}266/**267 * Get suitable opcodes for the required hardfork.268 *269 * @param common {Common} Ethereumjs Common metadata object.270 * @returns {OpcodeList} Opcodes dictionary object.271 */272export function getOpcodesForHF(common: Common): OpcodeList {273 let opcodeBuilder: any = { ...opcodes }274 for (let fork = 0; fork < hardforkOpcodes.length; fork++) {275 if (common.gteHardfork(hardforkOpcodes[fork].hardforkName)) {276 opcodeBuilder = { ...opcodeBuilder, ...hardforkOpcodes[fork].opcodes }277 }278 }279 for (const eipOps of eipOpcodes) {280 if (common.isActivatedEIP(eipOps.eip)) {281 opcodeBuilder = { ...opcodeBuilder, ...eipOps.opcodes }282 }283 }284 /* eslint-disable-next-line no-restricted-syntax */285 for (const key in opcodeBuilder) {286 const baseFee = common.param('gasPrices', opcodeBuilder[key].name.toLowerCase())287 // explicitly verify that we have defined a base fee288 if (baseFee === undefined) {289 throw new Error(`base fee not defined for: ${opcodeBuilder[key].name}`)290 }291 opcodeBuilder[key].fee = common.param('gasPrices', opcodeBuilder[key].name.toLowerCase())292 }293 return createOpcodes(opcodeBuilder)...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

...18 */19function before (exports, beforeFn) {20 getTestNames(exports).map(name => {21 let testFn = exports[name];22 if (!isAsync(testFn) && !isAsync(beforeFn)) {23 exports[name] = function (assert) {24 beforeFn(name);25 testFn(assert);26 };27 }28 else if (isAsync(testFn) && !isAsync(beforeFn)) {29 exports[name] = function (assert, done) {30 beforeFn(name);31 testFn(assert, done);32 }33 }34 else if (!isAsync(testFn) && isAsync(beforeFn)) {35 exports[name] = function (assert, done) {36 beforeFn(name, () => {37 testFn(assert);38 done();39 });40 }41 } else if (isAsync(testFn) && isAsync(beforeFn)) {42 exports[name] = function (assert, done) {43 beforeFn(name, () => {44 testFn(assert, done);45 });46 }47 }48 });49}50exports.before = before;51/*52 * Takes an `exports` object of a test file and a function `afterFn`53 * to be run after each test. `afterFn` is called with a `name` string54 * as the first argument of the test name, and may specify a second55 * argument function `done` to indicate that this function should56 * resolve asynchronously57 */58function after (exports, afterFn) {59 getTestNames(exports).map(name => {60 let testFn = exports[name];61 if (!isAsync(testFn) && !isAsync(afterFn)) {62 exports[name] = function (assert) {63 testFn(assert);64 afterFn(name);65 };66 }67 else if (isAsync(testFn) && !isAsync(afterFn)) {68 exports[name] = function (assert, done) {69 testFn(assert, () => {70 afterFn(name);71 done();72 });73 }74 }75 else if (!isAsync(testFn) && isAsync(afterFn)) {76 exports[name] = function (assert, done) {77 testFn(assert);78 afterFn(name, done);79 }80 } else if (isAsync(testFn) && isAsync(afterFn)) {81 exports[name] = function (assert, done) {82 testFn(assert, () => {83 afterFn(name, done);84 });85 }86 }87 });88}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const isAsync = require('fast-check').isAsync;2const fc = require('fast-check');3fc.assert(4 fc.property(fc.integer(), fc.integer(), (a, b) => {5 return a + b === b + a;6 })7);8fc.assert(9 fc.property(fc.integer(), fc.integer(), (a, b) => {10 return a + b === b + a;11 })12);13fc.assert(14 fc.property(fc.integer(), fc.integer(), (a, b) => {15 return a + b === b + a;16 })17);18console.log(isAsync(fc.integer()));19const isAsync = require('fast-check').isAsync;20const fc = require('fast-check');21fc.assert(22 fc.property(fc.integer(), fc.integer(), (a, b) => {23 return a + b === b + a;24 })25);26fc.assert(27 fc.property(fc.integer(), fc.integer(), (a, b) => {28 return a + b === b + a;29 })30);31fc.assert(32 fc.property(fc.integer(), fc.integer(), (a, b) => {33 return a + b === b + a;34 })35);36console.log(isAsync(fc.integer()));37const isAsync = require('fast-check').isAsync;38const fc = require('fast-check');39fc.assert(40 fc.property(fc.integer(), fc.integer(), (a, b) => {41 return a + b === b + a;42 })43);44fc.assert(45 fc.property(fc.integer(), fc.integer(), (a, b) => {46 return a + b === b + a;47 })48);49fc.assert(50 fc.property(fc.integer(), fc.integer(), (a, b) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { asyncProperty, isAsync } from 'fast-check';2import { expect } from 'chai';3describe('isAsync', () => {4 it('should return true for asyncProperty', () => {5 expect(isAsync(asyncProperty(() => true))).to.be.true;6 });7});8"paths": {9 }10import { asyncProperty, isAsync } from 'fast-check/lib/fast-check-default';11"paths": {12 }13import { asyncProperty, isAsync } from 'fast-check';14describe('isAsync', () => {15 it('should return true for asyncProperty', () => {16 expect(isAsync(asyncProperty(() => true))).to.be.true;17 });18});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { isAsync } from 'fast-check/lib/check/arbitrary/AsyncArbitrary.js';2const isAsync1 = isAsync(async function* () {3 yield 1;4});5console.log('isAsync1:', isAsync1);6const isAsync2 = isAsync(function* () {7 yield 1;8});9console.log('isAsync2:', isAsync2);10const isAsync3 = isAsync(function* () {11 yield 1;12 return 1;13});14console.log('isAsync3:', isAsync3);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('../../fast-check/lib/fast-check');2const isAsync = fc.isAsync;3const asyncProperty = fc.asyncProperty;4const asyncPropertyNoShrink = fc.asyncPropertyNoShrink;5const asyncPropertyNoShrinkNoPrint = fc.asyncPropertyNoShrinkNoPrint;6const asyncPropertyNoPrint = fc.asyncPropertyNoPrint;7const asyncPropertyNoShrinkNoPrintNoRun = fc.asyncPropertyNoShrinkNoPrintNoRun;8const asyncPropertyNoShrinkNoRun = fc.asyncPropertyNoShrinkNoRun;9const asyncPropertyNoRun = fc.asyncPropertyNoRun;10const asyncPropertyNoPrintNoRun = fc.asyncPropertyNoPrintNoRun;11const asyncPropertyNoPrintNoShrinkNoRun = fc.asyncPropertyNoPrintNoShrinkNoRun;12const asyncPropertyNoShrinkNoPrintNoRunNoReport = fc.asyncPropertyNoShrinkNoPrintNoRunNoReport;13const prop = async (a, b) => {14 return a + b === b + a;15};16const test = asyncProperty(prop, fc.integer(), fc.integer());17isAsync(test).then((result) => {18 console.log(`Is async: ${result}`);19 console.log(`Is not async: ${!result}`);20});

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const isAsync = require('is-async');3const myAsyncFunction = async () => { /* ... */ };4const mySyncFunction = () => { /* ... */ };5const fc = require('fast-check');6const isAsync = require('is-async');7const myAsyncFunction = async () => { /* ... */ };8const mySyncFunction = () => { /* ... */ };9const fc = require('fast-check');10const isAsync = require('is-async');11const myAsyncFunction = async () => { /* ... */ };12const mySyncFunction = () => { /* ... */ };13const fc = require('fast-check');14const isAsync = require('is-async');15const myAsyncFunction = async () => { /* ... */ };16const mySyncFunction = () => { /* ... */ };17const fc = require('fast-check');18const isAsync = require('is-async');19const myAsyncFunction = async () => { /* ... */ };20const mySyncFunction = () => { /* ... */ };

Full Screen

Using AI Code Generation

copy

Full Screen

1const { isAsync } = require('fast-check');2const isFunctionAsync = (fn) => {3 return isAsync(fn);4};5const asyncFunction = async () => {6 return 3;7};8const nonAsyncFunction = () => {9 return 3;10};11const { isAsync } = require('fast-check');12const isFunctionAsync = (fn) => {13 return isAsync(fn);14};15const asyncFunction = async () => {16 return 3;17};18const nonAsyncFunction = () => {19 return 3;20};21const { isAsync } = require('fast-check');22const isFunctionAsync = (fn) => {23 return isAsync(fn);24};25const asyncFunction = async () => {26 return 3;27};28const nonAsyncFunction = () => {29 return 3;30};31const { isAsync } = require('fast-check');32const isFunctionAsync = (fn) => {33 return isAsync(fn);34};35const asyncFunction = async () => {36 return 3;37};38const nonAsyncFunction = () => {39 return 3;40};41console.log(isFunctionAsync(async

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo 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