@@ -26,6 +26,27 @@ var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).is
2626var dtypes = require ( './../lib' ) ;
2727
2828
29+ // VARIABLES //
30+
31+ // List of native C types which should be supported...
32+ var DTYPES = [
33+ 'int8' ,
34+ 'uint8' ,
35+ 'int16' ,
36+ 'uint16' ,
37+ 'int32' ,
38+ 'uint32' ,
39+ 'int64' ,
40+ 'uint64' ,
41+
42+ 'float32' ,
43+ 'float64' ,
44+
45+ 'complex64' ,
46+ 'complex128'
47+ ] ;
48+
49+
2950// TESTS //
3051
3152tape ( 'main export is a function' , function test ( t ) {
@@ -61,7 +82,6 @@ tape( 'the function returns a list of strided array data types', function test(
6182
6283tape ( 'attached to the main function is an `enum` method to return an object mapping dtypes to integer values for C inter-operation' , function test ( t ) {
6384 var obj ;
64- var dt ;
6585 var i ;
6686
6787 t . strictEqual ( hasOwnProp ( dtypes , 'enum' ) , true , 'has property' ) ;
@@ -70,59 +90,30 @@ tape( 'attached to the main function is an `enum` method to return an object map
7090 obj = dtypes . enum ( ) ;
7191 t . strictEqual ( typeof obj , 'object' , 'returns expected value type' ) ;
7292
73- // List of native C types which should be supported...
74- dt = [
75- 'int8' ,
76- 'uint8' ,
77- 'uint8c' ,
78- 'int16' ,
79- 'uint16' ,
80- 'int32' ,
81- 'uint32' ,
82- 'int64' ,
83- 'uint64' ,
84-
85- 'float32' ,
86- 'float64' ,
87-
88- 'complex64' ,
89- 'complex128'
90- ] ;
91- for ( i = 0 ; i < dt . length ; i ++ ) {
92- t . strictEqual ( hasOwnProp ( obj , dt [ i ] ) , true , 'has property `' + dt [ i ] + '`' ) ;
93- t . strictEqual ( isNonNegativeInteger ( obj [ dt [ i ] ] ) , true , 'returns expected value' ) ;
93+ for ( i = 0 ; i < DTYPES . length ; i ++ ) {
94+ t . strictEqual ( hasOwnProp ( obj , DTYPES [ i ] ) , true , 'has property `' + DTYPES [ i ] + '`' ) ;
95+ t . strictEqual ( isNonNegativeInteger ( obj [ DTYPES [ i ] ] ) , true , 'returns expected value' ) ;
9496 }
9597
9698 t . end ( ) ;
9799} ) ;
98100
99101tape ( 'attached to the main function is an `enumerator` method to the integer value associated with a provided dtype for C inter-operation' , function test ( t ) {
100- var dt ;
101102 var i ;
102103
103104 t . strictEqual ( hasOwnProp ( dtypes , 'enumerator' ) , true , 'has property' ) ;
104105 t . strictEqual ( typeof dtypes . enumerator , 'function' , 'has method' ) ;
105106
106- // List of native C types which should be supported...
107- dt = [
108- 'int8' ,
109- 'uint8' ,
110- 'uint8c' ,
111- 'int16' ,
112- 'uint16' ,
113- 'int32' ,
114- 'uint32' ,
115- 'int64' ,
116- 'uint64' ,
117-
118- 'float32' ,
119- 'float64' ,
107+ for ( i = 0 ; i < DTYPES . length ; i ++ ) {
108+ t . strictEqual ( isNonNegativeInteger ( dtypes . enumerator ( DTYPES [ i ] ) ) , true , 'returns expected value' ) ;
109+ }
110+ t . end ( ) ;
111+ } ) ;
120112
121- 'complex64' ,
122- 'complex128'
123- ] ;
124- for ( i = 0 ; i < dt . length ; i ++ ) {
125- t . strictEqual ( isNonNegativeInteger ( dtypes . enumerator ( dt [ i ] ) ) , true , 'returns expected value' ) ;
113+ tape ( 'attached to the main function are dtype enumeration constants' , function test ( t ) {
114+ var i ;
115+ for ( i = 0 ; i < DTYPES . length ; i ++ ) {
116+ t . strictEqual ( isNonNegativeInteger ( dtypes [ DTYPES [ i ] ] ) , true , 'returns expected value' ) ;
126117 }
127118 t . end ( ) ;
128119} ) ;
0 commit comments