Skip to content

Commit 6c8898d

Browse files
committed
test: add tests for DataType instances
--- 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: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent c051895 commit 6c8898d

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

  • lib/node_modules/@stdlib/ndarray/base/dtype-desc/test

lib/node_modules/@stdlib/ndarray/base/dtype-desc/test/test.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24+
var DataType = require( '@stdlib/ndarray/dtype-ctor' );
25+
var structFactory = require( '@stdlib/dstructs/struct' );
2426
var table = require( './../lib/table.js' );
2527
var dtypeDesc = require( './../lib' );
2628

@@ -73,7 +75,7 @@ tape( 'the function returns an object mapping data type strings to descriptions
7375
t.end();
7476
});
7577

76-
tape( 'the function returns the description for a specified data type', function test( t ) {
78+
tape( 'the function returns the description for a specified data type (string)', function test( t ) {
7779
var expected;
7880
var v;
7981
var i;
@@ -86,8 +88,37 @@ tape( 'the function returns the description for a specified data type', function
8688
t.end();
8789
});
8890

91+
tape( 'the function returns the description for a specified data type (data type instance)', function test( t ) {
92+
var expected;
93+
var v;
94+
var i;
95+
96+
for ( i = 0; i < DTYPES.length; i++ ) {
97+
v = dtypeDesc( new DataType( DTYPES[ i ] ) );
98+
expected = DESC[ DTYPES[ i ] ] || null;
99+
t.strictEqual( v, expected, 'returns '+expected+' when provided '+DTYPES[i] );
100+
}
101+
t.end();
102+
});
103+
89104
tape( 'the function returns `null` if provided an unknown/unsupported data type', function test( t ) {
90-
var v = dtypeDesc( 'foobar' );
105+
var schema;
106+
var v;
107+
108+
v = dtypeDesc( 'foobar' );
91109
t.strictEqual( v, null, 'returns expected value' );
110+
111+
schema = [
112+
{
113+
'name': 'foo',
114+
'type': 'float64'
115+
}
116+
];
117+
v = dtypeDesc( structFactory( schema ) );
118+
t.strictEqual( v, null, 'returns expected value' );
119+
120+
v = dtypeDesc( new DataType( structFactory( schema ) ) );
121+
t.strictEqual( v, null, 'returns expected value' );
122+
92123
t.end();
93124
});

0 commit comments

Comments
 (0)