Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -0,0 +1,63 @@
'use strict'
const { test } = require('node:test')
const { kTestInternals } = require('../../lib/symbols')
const PonyPromise = require('../../lib/promise')
test('withResolvers', async (t) => {
t.plan(3)
await t.test('resolve', async (t) => {
t.plan(1)
const { promise, resolve } = PonyPromise.withResolvers()
resolve(true)
t.assert.ok(await promise)
})
await t.test('reject', async (t) => {
t.plan(1)
const { promise, reject } = PonyPromise.withResolvers()
await t.assert.rejects(async () => {
reject(Error('reject'))
return promise
}, {
name: 'Error',
message: 'reject'
})
})
await t.test('thenable', async (t) => {
t.plan(1)
const { promise, resolve } = PonyPromise.withResolvers()
resolve(true)
promise.then((value) => {
t.assert.ok(value)
})
})
})
test('withResolvers - ponyfill', async (t) => {
await t.test('resolve', async (t) => {
t.plan(1)
const { promise, resolve } = PonyPromise[kTestInternals].withResolvers()
resolve(true)
t.assert.ok(await promise)
})
await t.test('reject', async (t) => {
t.plan(1)
const { promise, reject } = PonyPromise[kTestInternals].withResolvers()
await t.assert.rejects(async () => {
reject(Error('reject'))
return promise
}, {
name: 'Error',
message: 'reject'
})
})
await t.test('thenable', async (t) => {
t.plan(1)
const { promise, resolve } = PonyPromise.withResolvers()
resolve(true)
promise.then((value) => {
t.assert.ok(value)
})
})
})