| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 99da7d7 commit a721570
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,6 @@ const { | |||
| 11 | 11 | FunctionPrototype, | |
| 12 | 12 | MathMax, | |
| 13 | 13 | Number, | |
| 14 | - ObjectEntries, | ||
| 15 | 14 | ObjectSeal, | |
| 16 | 15 | PromisePrototypeThen, | |
| 17 | 16 | PromiseResolve, | |
@@ -103,10 +102,28 @@ function lazyAssertObject() { | |||
| 103 | 102 | if (assertObj === undefined) { | |
| 104 | 103 | assertObj = new SafeMap(); | |
| 105 | 104 | const assert = require('assert'); | |
| 106 | - for (const { 0: key, 1: value } of ObjectEntries(assert)) { | ||
| 107 | - if (typeof value === 'function') { | ||
| 108 | - assertObj.set(value, key); | ||
| 109 | - } | ||
| 105 | + | ||
| 106 | + const methodsToCopy = [ | ||
| 107 | + 'deepEqual', | ||
| 108 | + 'deepStrictEqual', | ||
| 109 | + 'doesNotMatch', | ||
| 110 | + 'doesNotReject', | ||
| 111 | + 'doesNotThrow', | ||
| 112 | + 'equal', | ||
| 113 | + 'fail', | ||
| 114 | + 'ifError', | ||
| 115 | + 'match', | ||
| 116 | + 'notDeepEqual', | ||
| 117 | + 'notDeepStrictEqual', | ||
| 118 | + 'notEqual', | ||
| 119 | + 'notStrictEqual', | ||
| 120 | + 'ok', | ||
| 121 | + 'rejects', | ||
| 122 | + 'strictEqual', | ||
| 123 | + 'throws', | ||
| 124 | + ]; | ||
| 125 | + for (let i = 0; i < methodsToCopy.length; i++) { | ||
| 126 | + assertObj.set(methodsToCopy[i], assert[methodsToCopy[i]]); | ||
| 110 | 127 | } | |
| 111 | 128 | } | |
| 112 | 129 | return assertObj; | |
@@ -210,18 +227,18 @@ class TestContext { | |||
| 210 | 227 | get assert() { | |
| 211 | 228 | if (this.#assert === undefined) { | |
| 212 | 229 | const { plan } = this.#test; | |
| 213 | - const assertions = lazyAssertObject(); | ||
| 230 | + const map = lazyAssertObject(); | ||
| 214 | 231 | const assert = { __proto__: null }; | |
| 215 | 232 | ||
| 216 | 233 | this.#assert = assert; | |
| 217 | - for (const { 0: method, 1: name } of assertions.entries()) { | ||
| 234 | + map.forEach((method, name) => { | ||
| 218 | 235 | assert[name] = (...args) => { | |
| 219 | 236 | if (plan !== null) { | |
| 220 | 237 | plan.actual++; | |
| 221 | 238 | } | |
| 222 | 239 | return ReflectApply(method, assert, args); | |
| 223 | 240 | }; | |
| 224 | - } | ||
| 241 | + }); | ||
| 225 | 242 | } | |
| 226 | 243 | return this.#assert; | |
| 227 | 244 | } | |
| 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