Socket
Socket
Sign inDemoInstall

tape

Package Overview
Dependencies
Maintainers
3
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tape - npm Package Compare versions

Comparing version 5.7.4 to 5.7.5

test/default_stream.js

7

lib/default_stream.js

@@ -12,2 +12,9 @@ 'use strict';

function write(buf) {
if (
buf == null // eslint-disable-line eqeqeq
|| (Object(buf) !== buf && typeof buf !== 'string')
) {
flush();
return;
}
for (var i = 0; i < buf.length; i++) {

@@ -14,0 +21,0 @@ var c = typeof buf === 'string'

50

lib/test.js

@@ -38,2 +38,16 @@ 'use strict';

var isErrorConstructor = isProto(Error, TypeError) // IE 8 is `false` here
? function isErrorConstructor(C) {
return isProto(Error, C);
}
: function isErrorConstructor(C) {
return isProto(Error, C)
|| isProto(TypeError, C)
|| isProto(RangeError, C)
|| isProto(SyntaxError, C)
|| isProto(ReferenceError, C)
|| isProto(EvalError, C)
|| isProto(URIError, C);
};
// eslint-disable-next-line no-unused-vars

@@ -833,3 +847,3 @@ function getTestArgs(name_, opts_, cb_) {

passed = true;
} else if (isProto(Error, expected)) {
} else if (isErrorConstructor(expected)) {
passed = false;

@@ -843,18 +857,22 @@ } else {

} else if (expected && typeof expected === 'object') { // Handle validation objects.
var keys = objectKeys(expected);
// Special handle errors to make sure the name and the message are compared as well.
if (expected instanceof Error) {
$push(keys, 'name', 'message');
} else if (keys.length === 0) {
throw new TypeError('`throws` validation object must not be empty');
if (caught.error && typeof caught.error === 'object') {
var keys = objectKeys(expected);
// Special handle errors to make sure the name and the message are compared as well.
if (expected instanceof Error) {
$push(keys, 'name', 'message');
} else if (keys.length === 0) {
throw new TypeError('`throws` validation object must not be empty');
}
passed = every(keys, function (key) {
if (typeof caught.error[key] === 'string' && isRegExp(expected[key]) && $exec(expected[key], caught.error[key]) !== null) {
return true;
}
if (key in caught.error && deepEqual(caught.error[key], expected[key], { strict: true })) {
return true;
}
return false;
});
} else {
passed = false;
}
passed = every(keys, function (key) {
if (typeof caught.error[key] === 'string' && isRegExp(expected[key]) && $exec(expected[key], caught.error[key]) !== null) {
return true;
}
if (key in caught.error && deepEqual(caught.error[key], expected[key], { strict: true })) {
return true;
}
return false;
});
}

@@ -861,0 +879,0 @@ }

{
"name": "tape",
"version": "5.7.4",
"version": "5.7.5",
"description": "tap-producing test harness for node and browsers",

@@ -29,6 +29,6 @@ "main": "index.js",

"dependencies": {
"@ljharb/resumer": "^0.0.1",
"@ljharb/through": "^2.3.11",
"@ljharb/resumer": "^0.1.2",
"@ljharb/through": "^2.3.12",
"array.prototype.every": "^1.1.5",
"call-bind": "^1.0.5",
"call-bind": "^1.0.7",
"deep-equal": "^2.2.3",

@@ -41,3 +41,3 @@ "defined": "^1.0.1",

"has-dynamic-import": "^2.1.0",
"hasown": "^2.0.0",
"hasown": "^2.0.1",
"inherits": "^2.0.4",

@@ -44,0 +44,0 @@ "is-regex": "^1.1.4",

@@ -27,2 +27,3 @@ 'use strict';

var test = tape.createHarness();
var count = 0;
test.createStream().pipe(concat(function (body) {

@@ -32,12 +33,12 @@ tt.same(stripFullStack(body.toString('utf8')), [

'# non functions',
'ok 1 should throw',
'ok 2 should throw',
'ok 3 should throw',
'ok 4 should throw',
'ok 5 should throw',
'ok 6 should throw',
'ok 7 should throw',
'ok 8 should throw',
'ok ' + ++count + ' should throw',
'ok ' + ++count + ' should throw',
'ok ' + ++count + ' should throw',
'ok ' + ++count + ' should throw',
'ok ' + ++count + ' should throw',
'ok ' + ++count + ' should throw',
'ok ' + ++count + ' should throw',
'ok ' + ++count + ' should throw',
'# function',
'not ok 9 should throw',
'not ok ' + ++count + ' should throw',
' ---',

@@ -55,9 +56,9 @@ ' operator: throws',

'# custom error messages',
'ok 10 "message" is enumerable',
"ok 11 { custom: 'error', message: 'message' }",
'ok 12 getter is still the same',
'ok ' + ++count + ' "message" is enumerable',
'ok ' + ++count + ' { custom: \'error\', message: \'message\' }',
'ok ' + ++count + ' getter is still the same',
'# throws null',
'ok 13 throws null',
'ok ' + ++count + ' throws null',
'# wrong type of error',
'not ok 14 throws actual',
'not ok ' + ++count + ' throws actual',
' ---',

@@ -76,30 +77,127 @@ ' operator: throws',

'# object',
'ok 15 object properties are validated',
'ok ' + ++count + ' object properties are validated',
'# object with regexes',
'ok 16 object with regex values is validated',
'ok ' + ++count + ' object with regex values is validated',
'# similar error object',
'ok 17 throwing a similar error',
'ok ' + ++count + ' throwing a similar error',
'# validate with regex',
'ok 18 regex against toString of error',
'ok ' + ++count + ' regex against toString of error',
'# custom error validation',
'ok 19 error is SyntaxError',
'ok 20 error matches /value/',
'ok 21 unexpected error',
'ok ' + ++count + ' error is SyntaxError',
'ok ' + ++count + ' error matches /value/',
'ok ' + ++count + ' unexpected error',
'# throwing primitives',
'ok 22 primitive: null',
'ok 23 primitive: undefined',
'ok 24 primitive: 0',
'ok 25 primitive: NaN',
'ok 26 primitive: 42',
'ok 27 primitive: Infinity',
'ok 28 primitive: \'\'',
'ok 29 primitive: \'foo\'',
'ok 30 primitive: true',
'ok 31 primitive: false',
'ok ' + ++count + ' primitive: null, no expected',
'not ok ' + ++count + ' primitive: null, with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' null',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'ok ' + ++count + ' primitive: undefined, no expected',
'not ok ' + ++count + ' primitive: undefined, with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' undefined',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' stack: |-',
' Error: primitive: undefined, with non-empty expected object',
' [... stack stripped ...]',
' at $TEST/throws.js:$LINE:$COL',
' [... stack stripped ...]',
' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)',
' [... stack stripped ...]',
' ...',
'ok ' + ++count + ' primitive: 0, no expected',
'not ok ' + ++count + ' primitive: 0, with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' 0',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'ok ' + ++count + ' primitive: NaN, no expected',
'not ok ' + ++count + ' primitive: NaN, with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' NaN',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'ok ' + ++count + ' primitive: 42, no expected',
'not ok ' + ++count + ' primitive: 42, with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' 42',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'ok ' + ++count + ' primitive: Infinity, no expected',
'not ok ' + ++count + ' primitive: Infinity, with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' Infinity',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'ok ' + ++count + ' primitive: \'\', no expected',
'not ok ' + ++count + ' primitive: \'\', with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' \'\'',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'ok ' + ++count + ' primitive: \'foo\', no expected',
'not ok ' + ++count + ' primitive: \'foo\', with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' \'foo\'',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'ok ' + ++count + ' primitive: true, no expected',
'not ok ' + ++count + ' primitive: true, with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' true',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'ok ' + ++count + ' primitive: false, no expected',
'not ok ' + ++count + ' primitive: false, with non-empty expected object',
' ---',
' operator: throws',
' expected: |-',
' { a: \'b\' }',
' actual: |-',
' false',
' at: <anonymous> ($TEST/throws.js:$LINE:$COL)',
' ...',
'# ambiguous arguments',
'ok 32 Second',
'ok 33 Second',
'ok 34 Second',
'ok 35 should throw',
'not ok 36 should throw',
'ok ' + ++count + ' Second',
'ok ' + ++count + ' Second',
'ok ' + ++count + ' Second',
'ok ' + ++count + ' should throw',
'not ok ' + ++count + ' should throw',
' ---',

@@ -120,6 +218,6 @@ ' operator: throws',

'# non-extensible throw match',
'ok 37 error is non-extensible',
'ok 38 non-extensible error matches',
'ok 39 errorWithMessage is non-extensible',
'not ok 40 non-extensible error with message matches',
'ok ' + ++count + ' error is non-extensible',
'ok ' + ++count + ' non-extensible error matches',
'ok ' + ++count + ' errorWithMessage is non-extensible',
'not ok ' + ++count + ' non-extensible error with message matches',
' ---',

@@ -134,10 +232,10 @@ ' operator: throws',

'# frozen `message` property',
'ok 41 error is non-writable',
'ok 42 error is non-configurable',
'ok 43 non-writable error matches',
'ok ' + ++count + ' error is non-writable',
'ok ' + ++count + ' error is non-configurable',
'ok ' + ++count + ' non-writable error matches',
'',
'1..43',
'# tests 43',
'1..' + count,
'# tests ' + count,
'# pass 39',
'# fail 4',
'# fail ' + (count - 39),
''

@@ -290,3 +388,4 @@ ]);

[null, undefined, 0, NaN, 42, Infinity, '', 'foo', true, false].forEach(function (primitive) {
t.throws(function () { throw primitive; }, 'primitive: ' + inspect(primitive));
t.throws(function () { throw primitive; }, 'primitive: ' + inspect(primitive) + ', no expected');
t.throws(function () { throw primitive; }, { a: 'b' }, 'primitive: ' + inspect(primitive) + ', with non-empty expected object');
});

@@ -293,0 +392,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc