Skip to content

Commit 20b3872

Browse files
committed
feat: add support for boolean arrays
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent ed0e9eb commit 20b3872

File tree

2 files changed

+15
-1
lines changed
  • lib/node_modules/@stdlib/_tools/doctest/compare-values

2 files changed

+15
-1
lines changed

lib/node_modules/@stdlib/_tools/doctest/compare-values/lib/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ var isObjectLike = require( '@stdlib/assert/is-object-like' );
4646
var isFunction = require( '@stdlib/assert/is-function' );
4747
var isTypedArray = require( '@stdlib/assert/is-typed-array' );
4848
var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' );
49+
var isBooleanArray = require( '@stdlib/assert/is-booleanarray' );
4950
var isError = require( '@stdlib/assert/is-error' );
5051
var isTypeError = require( '@stdlib/assert/is-type-error' );
5152
var isSyntaxError = require( '@stdlib/assert/is-syntax-error' );
@@ -63,6 +64,7 @@ var trim = require( '@stdlib/string/trim' );
6364
var PINF = require( '@stdlib/constants/float64/pinf' );
6465
var NINF = require( '@stdlib/constants/float64/ninf' );
6566
var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' );
67+
var copyArray = require( '@stdlib/array/base/copy' );
6668
var createAnnotationValue = require( '@stdlib/_tools/doctest/create-annotation-value' );
6769
var parse = require( './parse.js' );
6870

@@ -255,6 +257,8 @@ function checkTypedArrays( actual, expected ) {
255257
if ( entries ) {
256258
if ( isComplexTypedArray( actual ) ) {
257259
actual = reinterpretComplex( actual, 0 );
260+
} else if ( isBooleanArray( actual ) ) {
261+
actual = copyArray( actual );
258262
}
259263
return compareEntries( actual, parse( entries ) );
260264
}
@@ -409,7 +413,7 @@ function compareValues( actual, expected ) {
409413
}
410414
return null;
411415
}
412-
if ( isTypedArray( actual ) || isComplexTypedArray( actual ) ) {
416+
if ( isTypedArray( actual ) || isComplexTypedArray( actual ) || isBooleanArray( actual ) ) {
413417
return checkTypedArrays( actual, expected );
414418
}
415419
if ( isArray( actual ) ) {

lib/node_modules/@stdlib/_tools/doctest/compare-values/test/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var Complex64 = require( '@stdlib/complex/float32/ctor' );
2929
var Complex128 = require( '@stdlib/complex/float64/ctor' );
3030
var Complex64Array = require( '@stdlib/array/complex64' );
3131
var Complex128Array = require( '@stdlib/array/complex128' );
32+
var BooleanArray = require( '@stdlib/array/bool' );
3233
var compareValues = require( './../lib' );
3334

3435

@@ -315,6 +316,15 @@ tape( 'the function compares a typed array and a corresponding return annotation
315316
msg = 'Expected array entries [1,1,2,2], but observed [1,-1,2,-2]';
316317
t.strictEqual( compareValues( actual, expected ), msg, 'returns expected message' );
317318

319+
actual = new BooleanArray( [ true, false, true, false ] );
320+
expected = '<BooleanArray>[ true, false, true, false ]';
321+
t.strictEqual( compareValues( actual, expected ), null, 'returns null' );
322+
323+
actual = new BooleanArray( [ true, false, true, false ] );
324+
expected = '<BooleanArray>[ true, true, true, true ]';
325+
msg = 'Expected array entries [true,true,true,true], but observed [true,false,true,false]';
326+
t.strictEqual( compareValues( actual, expected ), msg, 'returns expected message' );
327+
318328
t.end();
319329
});
320330

0 commit comments

Comments
 (0)