|
1 | 1 | /** |
2 | 2 | * @license Apache-2.0 |
3 | 3 | * |
4 | | -* Copyright (c) 2022 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 Float64Array = require( '@stdlib/array-float64' ); |
25 | | -var Complex64Array = require( '@stdlib/array-complex64' ); |
26 | | -var Complex64 = require( '@stdlib/complex-float32' ); |
27 | | -var realf = require( '@stdlib/complex-realf' ); |
28 | | -var imagf = require( '@stdlib/complex-imagf' ); |
29 | | -var arraylike2object = require( './../../dist' ); |
| 24 | +var main = require( './../../dist' ); |
30 | 25 |
|
31 | 26 |
|
32 | 27 | // TESTS // |
33 | 28 |
|
34 | | -tape( 'main export is a function', function test( t ) { |
| 29 | +tape( 'main export is defined', function test( t ) { |
35 | 30 | t.ok( true, __filename ); |
36 | | - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); |
37 | | - t.end(); |
38 | | -}); |
39 | | - |
40 | | -tape( 'the function converts an array to a standardized object', function test( t ) { |
41 | | - var expected; |
42 | | - var actual; |
43 | | - var x; |
44 | | - var v; |
45 | | - |
46 | | - x = new Float64Array( 10 ); |
47 | | - |
48 | | - expected = { |
49 | | - 'data': x, |
50 | | - 'accessorProtocol': false |
51 | | - }; |
52 | | - actual = arraylike2object( x ); |
53 | | - |
54 | | - t.strictEqual( actual.data, expected.data, 'returns expected value' ); |
55 | | - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); |
56 | | - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); |
57 | | - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); |
58 | | - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); |
59 | | - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); |
60 | | - |
61 | | - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); |
62 | | - v = actual.accessors[ 0 ]( actual.data, 0 ); |
63 | | - t.strictEqual( v, 1.0, 'returns expected value' ); |
64 | | - |
65 | | - t.end(); |
66 | | -}); |
67 | | - |
68 | | -tape( 'the function converts an array-like object to a standardized object', function test( t ) { |
69 | | - var expected; |
70 | | - var actual; |
71 | | - var x; |
72 | | - var v; |
73 | | - |
74 | | - x = { |
75 | | - 'length': 10 |
76 | | - }; |
77 | | - |
78 | | - expected = { |
79 | | - 'data': x, |
80 | | - 'accessorProtocol': false |
81 | | - }; |
82 | | - actual = arraylike2object( x ); |
83 | | - |
84 | | - t.strictEqual( actual.data, expected.data, 'returns expected value' ); |
85 | | - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); |
86 | | - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); |
87 | | - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); |
88 | | - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); |
89 | | - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); |
90 | | - |
91 | | - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); |
92 | | - v = actual.accessors[ 0 ]( actual.data, 0 ); |
93 | | - t.strictEqual( v, 1.0, 'returns expected value' ); |
94 | | - |
95 | | - t.end(); |
96 | | -}); |
97 | | - |
98 | | -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { |
99 | | - var expected; |
100 | | - var actual; |
101 | | - var x; |
102 | | - var v; |
103 | | - |
104 | | - x = new Complex64Array( 10 ); |
105 | | - |
106 | | - expected = { |
107 | | - 'data': x, |
108 | | - 'accessorProtocol': true |
109 | | - }; |
110 | | - actual = arraylike2object( x ); |
111 | | - |
112 | | - t.strictEqual( actual.data, expected.data, 'returns expected value' ); |
113 | | - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); |
114 | | - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); |
115 | | - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); |
116 | | - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); |
117 | | - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); |
118 | | - |
119 | | - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); |
120 | | - v = actual.accessors[ 0 ]( actual.data, 0 ); |
121 | | - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); |
122 | | - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); |
123 | | - |
| 31 | + t.strictEqual( main !== void 0, true, 'main export is defined' ); |
124 | 32 | t.end(); |
125 | 33 | }); |
0 commit comments