Skip to content

Commit 391333b

Browse files
committed
Auto-generated commit
1 parent 478af3b commit 391333b

2 files changed

Lines changed: 70 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ A total of 37 issues were closed in this release:
667667

668668
<details>
669669

670+
- [`9333f71`](https://github.com/stdlib-js/stdlib/commit/9333f717337007d160cb66e57e7a97d4da2ff0c0) - **test:** add tests for DataType instances _(by Athan Reines)_
670671
- [`908b8bb`](https://github.com/stdlib-js/stdlib/commit/908b8bbc9abb690c1038d9a31eb99dc079584667) - **docs:** update `ndarray` TypeScript declarations [(#9405)](https://github.com/stdlib-js/stdlib/pull/9405) _(by stdlib-bot)_
671672
- [`880be90`](https://github.com/stdlib-js/stdlib/commit/880be90c78565355d6e6616def13ccf5037faeca) - **style:** add missing spaces before closing bracket _(by Philipp Burckhardt)_
672673
- [`3977119`](https://github.com/stdlib-js/stdlib/commit/39771197cd35f28f98740f9818a973b0e551e5af) - **test:** fix broken test _(by Athan Reines)_

base/dtype-char/test/test.js

Lines changed: 69 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( './../../../dtype-ctor' );
25+
var structFactory = require( '@stdlib/dstructs/struct' );
2426
var dtypeChar = require( './../lib' );
2527

2628

@@ -91,7 +93,7 @@ tape( 'the function returns an object mapping data type strings to single letter
9193
t.end();
9294
});
9395

94-
tape( 'the function returns the single letter character abbreviation for an underlying array data type', function test( t ) {
96+
tape( 'the function returns the single letter character abbreviation for an underlying array data type (data type string)', function test( t ) {
9597
var expected;
9698
var ch;
9799
var i;
@@ -123,8 +125,73 @@ tape( 'the function returns the single letter character abbreviation for an unde
123125
t.end();
124126
});
125127

128+
tape( 'the function returns the single letter character abbreviation for an underlying array data type (data type instance)', function test( t ) {
129+
var expected;
130+
var dtypes;
131+
var ch;
132+
var i;
133+
134+
dtypes = [
135+
'float64',
136+
'float32',
137+
'float16',
138+
'int8',
139+
'uint8',
140+
'uint8c',
141+
'int16',
142+
'uint16',
143+
'int32',
144+
'uint32',
145+
'binary',
146+
'generic',
147+
'complex32',
148+
'complex64',
149+
'complex128',
150+
'bool'
151+
];
152+
153+
expected = [
154+
'd',
155+
'f',
156+
'h',
157+
's',
158+
'b',
159+
'a',
160+
'k',
161+
't',
162+
'i',
163+
'u',
164+
'r',
165+
'o',
166+
'j',
167+
'c',
168+
'z',
169+
'x'
170+
];
171+
for ( i = 0; i < dtypes.length; i++ ) {
172+
ch = dtypeChar( new DataType( dtypes[ i ] ) );
173+
t.strictEqual( ch, expected[ i ], 'returns '+expected[i]+' when provided '+dtypes[i] );
174+
}
175+
t.end();
176+
});
177+
126178
tape( 'the function returns `null` if provided an unknown/unsupported data type', function test( t ) {
127-
var ch = dtypeChar( 'foobar' );
179+
var schema;
180+
var ch;
181+
182+
ch = dtypeChar( 'foobar' );
183+
t.strictEqual( ch, null, 'returns expected value' );
184+
185+
schema = [
186+
{
187+
'name': 'foo',
188+
'type': 'float64'
189+
}
190+
];
191+
ch = dtypeChar( structFactory( schema ) );
192+
t.strictEqual( ch, null, 'returns expected value' );
193+
194+
ch = dtypeChar( new DataType( structFactory( schema ) ) );
128195
t.strictEqual( ch, null, 'returns expected value' );
129196
t.end();
130197
});

0 commit comments

Comments
 (0)