+import { expect } from '@std/expect'
import { randomInt } from 'node:crypto'
import os from 'node:os'
-import { expect } from 'expect'
-
import { KillBehaviors } from '../lib/index.cjs'
import {
availableParallelism,
// once,
round,
secureRandom,
- sleep
+ sleep,
} from '../lib/utils.cjs'
describe('Utils test suite', () => {
expect(isAsyncFunction('')).toBe(false)
expect(isAsyncFunction([])).toBe(false)
expect(isAsyncFunction(new Date())).toBe(false)
- // eslint-disable-next-line prefer-regex-literals
- expect(isAsyncFunction(new RegExp('[a-z]', 'i'))).toBe(false)
+ expect(isAsyncFunction(/[a-z]/i)).toBe(false)
expect(isAsyncFunction(new Error())).toBe(false)
expect(isAsyncFunction(new Map())).toBe(false)
expect(isAsyncFunction(new Set())).toBe(false)
expect(isAsyncFunction(async function () {})).toBe(true)
expect(isAsyncFunction(async function named () {})).toBe(true)
class TestClass {
- testSync () {}
- async testAsync () {}
- testArrowSync = () => {}
- testArrowAsync = async () => {}
- static testStaticSync () {}
static async testStaticAsync () {}
+ static testStaticSync () {}
+ testArrowAsync = async () => {}
+ testArrowSync = () => {}
+ async testAsync () {}
+ testSync () {}
}
const testClass = new TestClass()
expect(isAsyncFunction(testClass.testSync)).toBe(false)
})
it('Verify min() behavior', () => {
- expect(min()).toBe(Infinity)
+ expect(min()).toBe(Number.POSITIVE_INFINITY)
expect(min(1, 2)).toBe(1)
expect(min(2, 1)).toBe(1)
expect(min(1, 1)).toBe(1)
})
it('Verify max() behavior', () => {
- expect(max()).toBe(-Infinity)
+ expect(max()).toBe(Number.NEGATIVE_INFINITY)
expect(max(1, 2)).toBe(2)
expect(max(2, 1)).toBe(2)
expect(max(1, 1)).toBe(1)