Skip to content

Commit c6c68ef

Browse files
committed
Auto-generated commit
1 parent 9a01f97 commit c6c68ef

4 files changed

Lines changed: 73 additions & 4 deletions

File tree

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-12-22)
7+
## Unreleased (2025-12-28)
88

99
<section class="features">
1010

@@ -22,6 +22,7 @@
2222

2323
<details>
2424

25+
- [`9333f71`](https://github.com/stdlib-js/stdlib/commit/9333f717337007d160cb66e57e7a97d4da2ff0c0) - **test:** add tests for DataType instances _(by Athan Reines)_
2526
- [`e5bf4a1`](https://github.com/stdlib-js/stdlib/commit/e5bf4a1e92052b705774cbb08bc74295cea3c5fc) - **docs:** update example _(by Athan Reines)_
2627
- [`8b85764`](https://github.com/stdlib-js/stdlib/commit/8b8576416a1925647193338763722d58d8c8752e) - **chore:** clean-up _(by Athan Reines)_
2728
- [`6eee151`](https://github.com/stdlib-js/stdlib/commit/6eee15199727d04e3757e66f38384e97b8a333da) - **style:** fix indentation in JSON files _(by Philipp Burckhardt)_

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
},
4646
"devDependencies": {
4747
"@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main",
48+
"@stdlib/dstructs-struct": "github:stdlib-js/dstructs-struct#main",
49+
"@stdlib/ndarray-dtype-ctor": "github:stdlib-js/ndarray-dtype-ctor#main",
4850
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
4951
"istanbul": "^0.4.1",
5052
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",

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( '@stdlib/ndarray-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)