Skip to content

Commit 5d8484d

Browse files
committed
Fix bug when providing scalar arguments
1 parent d12f34e commit 5d8484d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/node_modules/@stdlib/console/log-each/lib/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ function logEach( str ) {
6767
strides.push( 0 );
6868
}
6969
}
70+
if ( len === void 0 ) {
71+
len = 1;
72+
}
7073
for ( ; i < nargs; i++ ) {
7174
v = arguments[ i ];
7275
if ( isCollection( v ) ) {

lib/node_modules/@stdlib/console/log-each/test/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ tape( 'the function prints a formatted message for each element in an array', fu
137137
for ( i = 0; i < values.length; i++ ) {
138138
logEach( '%s', values[ i ] );
139139
}
140+
t.strictEqual( j, expected.length, 'returns expected value' );
140141
t.end();
141142

142143
function logger( str ) {
@@ -170,6 +171,7 @@ tape( 'the function prints a formatted message for each pair of array elements (
170171
for ( i = 0; i < values.length; i += 2 ) {
171172
logEach( '%s, %s', values[ i ], values[ i + 1 ] );
172173
}
174+
t.strictEqual( j, expected.length, 'returns expected value' );
173175
t.end();
174176

175177
function logger( str ) {
@@ -205,6 +207,7 @@ tape( 'the function repeatedly prints a formatted message (three arrays)', funct
205207
for ( i = 0; i < values.length; i += 3 ) {
206208
logEach( '%s, %s, %s', values[ i ], values[ i + 1 ], values[ i + 2 ]);
207209
}
210+
t.strictEqual( j, expected.length, 'returns expected value' );
208211
t.end();
209212

210213
function logger( str ) {
@@ -242,6 +245,7 @@ tape( 'the function repeatedly prints a formatted message (four arrays)', functi
242245
for ( i = 0; i < values.length; i += 4 ) {
243246
logEach( '%s, %s, %s, %s', values[ i ], values[ i + 1 ], values[ i + 2 ], values[ i + 3 ]);
244247
}
248+
t.strictEqual( j, expected.length, 'returns expected value' );
245249
t.end();
246250

247251
function logger( str ) {
@@ -275,6 +279,7 @@ tape( 'the function broadcasts non-array arguments (one array, one scalar)', fun
275279
for ( i = 0; i < values.length; i += 2 ) {
276280
logEach( '%s, %s', values[ i ], values[ i + 1 ] );
277281
}
282+
t.strictEqual( j, expected.length, 'returns expected value' );
278283
t.end();
279284

280285
function logger( str ) {
@@ -308,6 +313,7 @@ tape( 'the function broadcasts non-array arguments (one scalar, one array)', fun
308313
for ( i = 0; i < values.length; i += 2 ) {
309314
logEach( '%s, %s', values[ i ], values[ i + 1 ] );
310315
}
316+
t.strictEqual( j, expected.length, 'returns expected value' );
311317
t.end();
312318

313319
function logger( str ) {
@@ -343,6 +349,7 @@ tape( 'the function broadcasts non-array elements (two arrays, one scalar)', fun
343349
for ( i = 0; i < values.length; i += 3 ) {
344350
logEach( '%s, %s, %s', values[ i ], values[ i + 1 ], values[ i + 2 ] );
345351
}
352+
t.strictEqual( j, expected.length, 'returns expected value' );
346353
t.end();
347354

348355
function logger( str ) {
@@ -378,6 +385,7 @@ tape( 'the function broadcasts non-array arguments (one scalar, two arrays)', fu
378385
for ( i = 0; i < values.length; i += 3 ) {
379386
logEach( '%s, %s, %s', values[ i ], values[ i + 1 ], values[ i + 2 ] );
380387
}
388+
t.strictEqual( j, expected.length, 'returns expected value' );
381389
t.end();
382390

383391
function logger( str ) {
@@ -413,6 +421,7 @@ tape( 'the function prints a formatted message when provided only a scalar argum
413421
for ( i = 0; i < values.length; i++ ) {
414422
logEach( '%s', values[ i ] );
415423
}
424+
t.strictEqual( j, expected.length, 'returns expected value' );
416425
t.end();
417426

418427
function logger( str ) {
@@ -448,6 +457,7 @@ tape( 'the function prints a formatted message when only provided two scalar arg
448457
for ( i = 0; i < values.length; i += 2 ) {
449458
logEach( '%s, %s', values[ i ], values[ i + 1 ] );
450459
}
460+
t.strictEqual( j, expected.length, 'returns expected value' );
451461
t.end();
452462

453463
function logger( str ) {

0 commit comments

Comments
 (0)