|
1 | 1 | /**
|
2 | 2 | * @license Apache-2.0
|
3 | 3 | *
|
4 |
| -* Copyright (c) 2018 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 isSingleSegmentCompatible = require( './../../dist' ); |
| 24 | +var main = require( './../../dist' ); |
25 | 25 |
|
26 | 26 |
|
27 | 27 | // TESTS //
|
28 | 28 |
|
29 |
| -tape( 'main export is a function', function test( t ) { |
| 29 | +tape( 'main export is defined', function test( t ) { |
30 | 30 | t.ok( true, __filename );
|
31 |
| - t.strictEqual( typeof isSingleSegmentCompatible, 'function', 'main export is a function' ); |
32 |
| - t.end(); |
33 |
| -}); |
34 |
| - |
35 |
| -tape( 'the function returns `true` if an array is compatible with a single memory segment', function test( t ) { |
36 |
| - var strides; |
37 |
| - var offset; |
38 |
| - var shape; |
39 |
| - var bool; |
40 |
| - |
41 |
| - shape = [ 3, 2 ]; |
42 |
| - |
43 |
| - strides = [ 2, 1 ]; |
44 |
| - offset = 0; |
45 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
46 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
47 |
| - |
48 |
| - strides = [ 2, 1 ]; |
49 |
| - offset = 99999; |
50 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
51 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
52 |
| - |
53 |
| - strides = [ -2, 1 ]; |
54 |
| - offset = 4; |
55 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
56 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
57 |
| - |
58 |
| - strides = [ 2, -1 ]; |
59 |
| - offset = 1; |
60 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
61 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
62 |
| - |
63 |
| - strides = [ -2, -1 ]; |
64 |
| - offset = 5; |
65 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
66 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
67 |
| - |
68 |
| - strides = [ 1, 3 ]; |
69 |
| - offset = 0; |
70 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
71 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
72 |
| - |
73 |
| - strides = [ -1, 3 ]; |
74 |
| - offset = 2; |
75 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
76 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
77 |
| - |
78 |
| - strides = [ 1, -3 ]; |
79 |
| - offset = 3; |
80 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
81 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
82 |
| - |
83 |
| - strides = [ -1, -3 ]; |
84 |
| - offset = 5; |
85 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
86 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
87 |
| - |
88 |
| - shape = [ 1, 1, 1, 2 ]; |
89 |
| - strides = [ 2, 2, 2, 1 ]; |
90 |
| - offset = 0; |
91 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
92 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
93 |
| - |
94 |
| - shape = [ 2, 3, 10 ]; |
95 |
| - strides = [ 30, 10, 1 ]; |
96 |
| - offset = 99999; |
97 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
98 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
99 |
| - |
100 |
| - shape = [ 2, 3, 10 ]; |
101 |
| - strides = [ 30, -10, 1 ]; |
102 |
| - offset = 20; |
103 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
104 |
| - t.strictEqual( bool, true, 'returns expected value' ); |
105 |
| - |
106 |
| - t.end(); |
107 |
| -}); |
108 |
| - |
109 |
| -tape( 'the function returns `false` if an array is incompatible with a single memory segment', function test( t ) { |
110 |
| - var strides; |
111 |
| - var offset; |
112 |
| - var shape; |
113 |
| - var bool; |
114 |
| - |
115 |
| - shape = [ 1, 1, 1, 2 ]; |
116 |
| - strides = [ 2, 2, 2, 2 ]; |
117 |
| - offset = 0; |
118 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
119 |
| - t.strictEqual( bool, false, 'returns expected value' ); |
120 |
| - |
121 |
| - shape = [ 10 ]; |
122 |
| - strides = [ 3 ]; |
123 |
| - offset = 0; |
124 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
125 |
| - t.strictEqual( bool, false, 'returns expected value' ); |
126 |
| - |
127 |
| - shape = [ 2, 2 ]; |
128 |
| - strides = [ 2, 2 ]; |
129 |
| - offset = 0; |
130 |
| - bool = isSingleSegmentCompatible( shape, strides, offset ); |
131 |
| - t.strictEqual( bool, false, 'returns expected value' ); |
132 |
| - |
133 |
| - t.end(); |
134 |
| -}); |
135 |
| - |
136 |
| -tape( 'the function returns `false` if an array has 0 elements', function test( t ) { |
137 |
| - var bool = isSingleSegmentCompatible( [ 2, 0 ], [ 2, 0 ], 0 ); |
138 |
| - t.strictEqual( bool, false, 'returns expected value' ); |
| 31 | + t.strictEqual( main !== void 0, true, 'main export is defined' ); |
139 | 32 | t.end();
|
140 | 33 | });
|
0 commit comments