| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f949080 commit 3ff174f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,6 @@ const { | |||
| 12 | 12 | MathMax, | |
| 13 | 13 | Number, | |
| 14 | 14 | ObjectDefineProperty, | |
| 15 | - ObjectEntries, | ||
| 16 | 15 | ObjectSeal, | |
| 17 | 16 | PromisePrototypeThen, | |
| 18 | 17 | PromiseResolve, | |
@@ -107,10 +106,28 @@ function lazyAssertObject() { | |||
| 107 | 106 | if (assertObj === undefined) { | |
| 108 | 107 | assertObj = new SafeMap(); | |
| 109 | 108 | const assert = require('assert'); | |
| 110 | - for (const { 0: key, 1: value } of ObjectEntries(assert)) { | ||
| 111 | - if (typeof value === 'function') { | ||
| 112 | - assertObj.set(value, key); | ||
| 113 | - } | ||
| 109 | + | ||
| 110 | + const methodsToCopy = [ | ||
| 111 | + 'deepEqual', | ||
| 112 | + 'deepStrictEqual', | ||
| 113 | + 'doesNotMatch', | ||
| 114 | + 'doesNotReject', | ||
| 115 | + 'doesNotThrow', | ||
| 116 | + 'equal', | ||
| 117 | + 'fail', | ||
| 118 | + 'ifError', | ||
| 119 | + 'match', | ||
| 120 | + 'notDeepEqual', | ||
| 121 | + 'notDeepStrictEqual', | ||
| 122 | + 'notEqual', | ||
| 123 | + 'notStrictEqual', | ||
| 124 | + 'ok', | ||
| 125 | + 'rejects', | ||
| 126 | + 'strictEqual', | ||
| 127 | + 'throws', | ||
| 128 | + ]; | ||
| 129 | + for (let i = 0; i < methodsToCopy.length; i++) { | ||
| 130 | + assertObj.set(methodsToCopy[i], assert[methodsToCopy[i]]); | ||
| 114 | 131 | } | |
| 115 | 132 | } | |
| 116 | 133 | return assertObj; | |
@@ -227,18 +244,18 @@ class TestContext { | |||
| 227 | 244 | get assert() { | |
| 228 | 245 | if (this.#assert === undefined) { | |
| 229 | 246 | const { plan } = this.#test; | |
| 230 | - const assertions = lazyAssertObject(); | ||
| 247 | + const map = lazyAssertObject(); | ||
| 231 | 248 | const assert = { __proto__: null }; | |
| 232 | 249 | ||
| 233 | 250 | this.#assert = assert; | |
| 234 | - for (const { 0: method, 1: name } of assertions.entries()) { | ||
| 251 | + map.forEach((method, name) => { | ||
| 235 | 252 | assert[name] = (...args) => { | |
| 236 | 253 | if (plan !== null) { | |
| 237 | 254 | plan.actual++; | |
| 238 | 255 | } | |
| 239 | 256 | return ReflectApply(method, assert, args); | |
| 240 | 257 | }; | |
| 241 | - } | ||
| 258 | + }); | ||
| 242 | 259 | } | |
| 243 | 260 | return this.#assert; | |
| 244 | 261 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + require('../common'); | ||
| 3 | + const { deepStrictEqual } = require('node:assert'); | ||
| 4 | + const test = require('node:test'); | ||
| 5 | + | ||
| 6 | + test('only methods from node:assert are on t.assert', (t) => { | ||
| 7 | + deepStrictEqual(Object.keys(t.assert).sort(), [ | ||
| 8 | + 'deepEqual', | ||
| 9 | + 'deepStrictEqual', | ||
| 10 | + 'doesNotMatch', | ||
| 11 | + 'doesNotReject', | ||
| 12 | + 'doesNotThrow', | ||
| 13 | + 'equal', | ||
| 14 | + 'fail', | ||
| 15 | + 'ifError', | ||
| 16 | + 'match', | ||
| 17 | + 'notDeepEqual', | ||
| 18 | + 'notDeepStrictEqual', | ||
| 19 | + 'notEqual', | ||
| 20 | + 'notStrictEqual', | ||
| 21 | + 'ok', | ||
| 22 | + 'rejects', | ||
| 23 | + 'strictEqual', | ||
| 24 | + 'throws', | ||
| 25 | + ]); | ||
| 26 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments