|
1 | 1 | /** |
2 | 2 | * @license Apache-2.0 |
3 | 3 | * |
4 | | -* Copyright (c) 2021 The Stdlib Authors. |
| 4 | +* Copyright (c) 2023 The Stdlib Authors. |
5 | 5 | * |
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | * you may not use this file except in compliance with the License. |
|
21 | 21 | // MODULES // |
22 | 22 |
|
23 | 23 | var tape = require( 'tape' ); |
24 | | -var dtypes = require( '@stdlib/ndarray-dtypes' ); |
25 | | -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); |
26 | | -var isFunction = require( '@stdlib/assert-is-function' ); |
27 | | -var dtypeEnum = require( './../../dist' ); |
28 | | - |
29 | | - |
30 | | -// VARIABLES // |
31 | | - |
32 | | -var DTYPES = dtypes(); |
33 | | -var TABLE = dtypes.enum(); |
| 24 | +var main = require( './../../dist' ); |
34 | 25 |
|
35 | 26 |
|
36 | 27 | // TESTS // |
37 | 28 |
|
38 | | -tape( 'main export is a function', function test( t ) { |
| 29 | +tape( 'main export is defined', function test( t ) { |
39 | 30 | t.ok( true, __filename ); |
40 | | - t.strictEqual( typeof dtypeEnum, 'function', 'main export is a function' ); |
41 | | - t.end(); |
42 | | -}); |
43 | | - |
44 | | -tape( 'the function returns the data type enumeration constant for ndarray data buffers', function test( t ) { |
45 | | - var ctor; |
46 | | - var buf; |
47 | | - var dt; |
48 | | - var i; |
49 | | - |
50 | | - for ( i = 0; i < DTYPES.length; i++ ) { |
51 | | - ctor = bufferCtors( DTYPES[ i ] ); |
52 | | - if ( DTYPES[ i ] === 'binary' && isFunction( ctor.alloc ) ) { |
53 | | - buf = ctor.alloc( 10 ); |
54 | | - } else { |
55 | | - buf = new ctor( 10 ); |
56 | | - } |
57 | | - dt = dtypeEnum( buf ); |
58 | | - t.strictEqual( dt, TABLE[ DTYPES[ i ] ], 'returns expected value' ); |
59 | | - } |
60 | | - t.end(); |
61 | | -}); |
62 | | - |
63 | | -tape( 'the function supports generic objects', function test( t ) { |
64 | | - var buf; |
65 | | - var dt; |
66 | | - |
67 | | - buf = { |
68 | | - 'length': 10 |
69 | | - }; |
70 | | - dt = dtypeEnum( buf ); |
71 | | - t.strictEqual( dt, TABLE[ 'generic' ], 'returns expected value' ); |
72 | | - t.end(); |
73 | | -}); |
74 | | - |
75 | | -tape( 'if provided an ndarray data buffer having an unknown/unsupported data type, the function returns `null`', function test( t ) { |
76 | | - var buffers; |
77 | | - var i; |
78 | | - |
79 | | - buffers = [ |
80 | | - 'beep', |
81 | | - 5, |
82 | | - NaN, |
83 | | - null, |
84 | | - void 0, |
85 | | - true, |
86 | | - false, |
87 | | - function noop() {} |
88 | | - ]; |
89 | | - for ( i = 0; i < buffers.length; i++ ) { |
90 | | - t.strictEqual( dtypeEnum( buffers[i] ), null, 'returns expected value for ' + buffers[ i ] ); |
91 | | - } |
| 31 | + t.strictEqual( main !== void 0, true, 'main export is defined' ); |
92 | 32 | t.end(); |
93 | 33 | }); |
0 commit comments