Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 62x 62x 62x 99x 4x 4x 4x 99x 26x 26x 26x 26x 24x 24x 24x 24x 24x 6x 6x 6x 6x 6x 6x 18x 24x 2x 2x 16x 16x 26x 26x 26x 26x 99x 94x 94x 94x 99x 8x 8x 8x 8x 8x 8x 8x 8x 1x 1x 1x 1x 1x 1x 1x 1x 8x 99x 99x 99x 99x 99x 99x 99x 99x | 'use strict'; const { RegExp, RegExpPrototypeExec } = primordials; const { basename } = require('path'); const { createDeferredPromise } = require('internal/util'); const { codes: { ERR_INVALID_ARG_VALUE, ERR_TEST_FAILURE, }, kIsNodeError, } = require('internal/errors'); const kMultipleCallbackInvocations = 'multipleCallbackInvocations'; const kRegExpPattern = /^\/(.*)\/([a-z]*)$/; const kSupportedFileExtensions = /\.[cm]?js$/; const kTestFilePattern = /((^test(-.+)?)|(.+[.\-_]test))\.[cm]?js$/; function doesPathMatchFilter(p) { return RegExpPrototypeExec(kTestFilePattern, basename(p)) !== null; } function isSupportedFileType(p) { return RegExpPrototypeExec(kSupportedFileExtensions, p) !== null; } function createDeferredCallback() { let calledCount = 0; const { promise, resolve, reject } = createDeferredPromise(); const cb = (err) => { calledCount++; // If the callback is called a second time, let the user know, but // don't let them know more than once. if (calledCount > 1) { if (calledCount === 2) { throw new ERR_TEST_FAILURE( 'callback invoked multiple times', kMultipleCallbackInvocations ); } return; } if (err) { return reject(err); } resolve(); }; return { promise, cb }; } function isTestFailureError(err) { return err?.code === 'ERR_TEST_FAILURE' && kIsNodeError in err; } function convertStringToRegExp(str, name) { const match = RegExpPrototypeExec(kRegExpPattern, str); const pattern = match?.[1] ?? str; const flags = match?.[2] || ''; try { return new RegExp(pattern, flags); } catch (err) { const msg = err?.message; throw new ERR_INVALID_ARG_VALUE( name, str, `is an invalid regular expression.${msg ? ` ${msg}` : ''}` ); } } module.exports = { convertStringToRegExp, createDeferredCallback, doesPathMatchFilter, isSupportedFileType, isTestFailureError, }; |