2121// MODULES //
2222
2323var tape = require ( 'tape' ) ;
24- var isSameComplex128 = require ( '@stdlib/assert/is-same-complex128 ' ) ;
24+ var isSameComplex128Array = require ( '@stdlib/assert/is-same-complex128array ' ) ;
2525var Complex128Array = require ( '@stdlib/array/complex128' ) ;
26- var Complex128 = require ( '@stdlib/complex/float64/ctor' ) ;
2726var ndarray = require ( '@stdlib/ndarray/base/ctor' ) ;
2827var getData = require ( '@stdlib/ndarray/data-buffer' ) ;
2928var zzeroTo = require ( './../lib' ) ;
@@ -60,9 +59,9 @@ tape( 'the function has an arity of 1', function test( t ) {
6059} ) ;
6160
6261tape ( 'the function fills a one-dimensional ndarray with linearly spaced numeric elements which increment by 1 starting from zero' , function test ( t ) {
62+ var expected ;
6363 var actual ;
6464 var xbuf ;
65- var buf ;
6665 var x ;
6766
6867 xbuf = new Complex128Array ( [ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ] ) ;
@@ -71,11 +70,8 @@ tape( 'the function fills a one-dimensional ndarray with linearly spaced numeric
7170 actual = zzeroTo ( [ x ] ) ;
7271 t . strictEqual ( actual , x , 'returns expected value' ) ;
7372
74- buf = getData ( actual ) ;
75- t . strictEqual ( isSameComplex128 ( buf . get ( 0 ) , new Complex128 ( 0.0 , 0.0 ) ) , true , 'returns expected value' ) ;
76- t . strictEqual ( isSameComplex128 ( buf . get ( 1 ) , new Complex128 ( 1.0 , 0.0 ) ) , true , 'returns expected value' ) ;
77- t . strictEqual ( isSameComplex128 ( buf . get ( 2 ) , new Complex128 ( 2.0 , 0.0 ) ) , true , 'returns expected value' ) ;
78- t . strictEqual ( isSameComplex128 ( buf . get ( 3 ) , new Complex128 ( 3.0 , 0.0 ) ) , true , 'returns expected value' ) ;
73+ expected = new Complex128Array ( [ 0.0 , 0.0 , 1.0 , 0.0 , 2.0 , 0.0 , 3.0 , 0.0 ] ) ;
74+ t . strictEqual ( isSameComplex128Array ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
7975
8076 t . end ( ) ;
8177} ) ;
@@ -96,9 +92,9 @@ tape( 'the function returns the input ndarray unchanged when the input ndarray i
9692} ) ;
9793
9894tape ( 'the function fills a one-dimensional ndarray containing a single element' , function test ( t ) {
95+ var expected ;
9996 var actual ;
10097 var xbuf ;
101- var buf ;
10298 var x ;
10399
104100 xbuf = new Complex128Array ( [ 5.0 , 5.0 ] ) ;
@@ -107,16 +103,16 @@ tape( 'the function fills a one-dimensional ndarray containing a single element'
107103 actual = zzeroTo ( [ x ] ) ;
108104 t . strictEqual ( actual , x , 'returns expected value' ) ;
109105
110- buf = getData ( actual ) ;
111- t . strictEqual ( isSameComplex128 ( buf . get ( 0 ) , new Complex128 ( 0.0 , 0.0 ) ) , true , 'returns expected value' ) ;
106+ expected = new Complex128Array ( [ 0.0 , 0.0 ] ) ;
107+ t . strictEqual ( isSameComplex128Array ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
112108
113109 t . end ( ) ;
114110} ) ;
115111
116112tape ( 'the function supports an input ndarray having a non-unit stride' , function test ( t ) {
113+ var expected ;
117114 var actual ;
118115 var xbuf ;
119- var buf ;
120116 var x ;
121117
122118 xbuf = new Complex128Array ( [
@@ -142,19 +138,33 @@ tape( 'the function supports an input ndarray having a non-unit stride', functio
142138 actual = zzeroTo ( [ x ] ) ;
143139 t . strictEqual ( actual , x , 'returns expected value' ) ;
144140
145- buf = getData ( actual ) ;
146- t . strictEqual ( isSameComplex128 ( buf . get ( 0 ) , new Complex128 ( 0.0 , 0.0 ) ) , true , 'returns expected value' ) ;
147- t . strictEqual ( isSameComplex128 ( buf . get ( 2 ) , new Complex128 ( 1.0 , 0.0 ) ) , true , 'returns expected value' ) ;
148- t . strictEqual ( isSameComplex128 ( buf . get ( 4 ) , new Complex128 ( 2.0 , 0.0 ) ) , true , 'returns expected value' ) ;
149- t . strictEqual ( isSameComplex128 ( buf . get ( 6 ) , new Complex128 ( 3.0 , 0.0 ) ) , true , 'returns expected value' ) ;
141+ expected = new Complex128Array ( [
142+ 0.0 , // 0
143+ 0.0 , // 0
144+ 9.0 ,
145+ 9.0 ,
146+ 1.0 , // 1
147+ 0.0 , // 1
148+ 9.0 ,
149+ 9.0 ,
150+ 2.0 , // 2
151+ 0.0 , // 2
152+ 9.0 ,
153+ 9.0 ,
154+ 3.0 , // 3
155+ 0.0 , // 3
156+ 9.0 ,
157+ 9.0
158+ ] ) ;
159+ t . strictEqual ( isSameComplex128Array ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
150160
151161 t . end ( ) ;
152162} ) ;
153163
154164tape ( 'the function supports an input ndarray having a negative stride' , function test ( t ) {
165+ var expected ;
155166 var actual ;
156167 var xbuf ;
157- var buf ;
158168 var x ;
159169
160170 xbuf = new Complex128Array ( [
@@ -174,20 +184,27 @@ tape( 'the function supports an input ndarray having a negative stride', functio
174184 actual = zzeroTo ( [ x ] ) ;
175185 t . strictEqual ( actual , x , 'returns expected value' ) ;
176186
177- buf = getData ( actual ) ;
178- t . strictEqual ( isSameComplex128 ( buf . get ( 0 ) , new Complex128 ( 4.0 , 0.0 ) ) , true , 'returns expected value' ) ;
179- t . strictEqual ( isSameComplex128 ( buf . get ( 1 ) , new Complex128 ( 3.0 , 0.0 ) ) , true , 'returns expected value' ) ;
180- t . strictEqual ( isSameComplex128 ( buf . get ( 2 ) , new Complex128 ( 2.0 , 0.0 ) ) , true , 'returns expected value' ) ;
181- t . strictEqual ( isSameComplex128 ( buf . get ( 3 ) , new Complex128 ( 1.0 , 0.0 ) ) , true , 'returns expected value' ) ;
182- t . strictEqual ( isSameComplex128 ( buf . get ( 4 ) , new Complex128 ( 0.0 , 0.0 ) ) , true , 'returns expected value' ) ;
187+ expected = new Complex128Array ( [
188+ 4.0 , // 4
189+ 0.0 , // 4
190+ 3.0 , // 3
191+ 0.0 , // 3
192+ 2.0 , // 2
193+ 0.0 , // 2
194+ 1.0 , // 1
195+ 0.0 , // 1
196+ 0.0 , // 0
197+ 0.0 // 0
198+ ] ) ;
199+ t . strictEqual ( isSameComplex128Array ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
183200
184201 t . end ( ) ;
185202} ) ;
186203
187204tape ( 'the function supports an input ndarray having a non-zero offset' , function test ( t ) {
205+ var expected ;
188206 var actual ;
189207 var xbuf ;
190- var buf ;
191208 var x ;
192209
193210 xbuf = new Complex128Array ( [
@@ -209,19 +226,29 @@ tape( 'the function supports an input ndarray having a non-zero offset', functio
209226 actual = zzeroTo ( [ x ] ) ;
210227 t . strictEqual ( actual , x , 'returns expected value' ) ;
211228
212- buf = getData ( actual ) ;
213- t . strictEqual ( isSameComplex128 ( buf . get ( 2 ) , new Complex128 ( 0.0 , 0.0 ) ) , true , 'returns expected value' ) ;
214- t . strictEqual ( isSameComplex128 ( buf . get ( 3 ) , new Complex128 ( 1.0 , 0.0 ) ) , true , 'returns expected value' ) ;
215- t . strictEqual ( isSameComplex128 ( buf . get ( 4 ) , new Complex128 ( 2.0 , 0.0 ) ) , true , 'returns expected value' ) ;
216- t . strictEqual ( isSameComplex128 ( buf . get ( 5 ) , new Complex128 ( 3.0 , 0.0 ) ) , true , 'returns expected value' ) ;
229+ expected = new Complex128Array ( [
230+ 9.0 ,
231+ 9.0 ,
232+ 9.0 ,
233+ 9.0 ,
234+ 0.0 , // 0
235+ 0.0 , // 0
236+ 1.0 , // 1
237+ 0.0 , // 1
238+ 2.0 , // 2
239+ 0.0 , // 2
240+ 3.0 , // 3
241+ 0.0 // 3
242+ ] ) ;
243+ t . strictEqual ( isSameComplex128Array ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
217244
218245 t . end ( ) ;
219246} ) ;
220247
221248tape ( 'the function supports an input ndarray having a negative stride and non-zero offset' , function test ( t ) {
249+ var expected ;
222250 var actual ;
223251 var xbuf ;
224- var buf ;
225252 var x ;
226253
227254 xbuf = new Complex128Array ( [
@@ -243,10 +270,21 @@ tape( 'the function supports an input ndarray having a negative stride and non-z
243270 actual = zzeroTo ( [ x ] ) ;
244271 t . strictEqual ( actual , x , 'returns expected value' ) ;
245272
246- buf = getData ( actual ) ;
247- t . strictEqual ( isSameComplex128 ( buf . get ( 1 ) , new Complex128 ( 2.0 , 0.0 ) ) , true , 'returns expected value' ) ;
248- t . strictEqual ( isSameComplex128 ( buf . get ( 3 ) , new Complex128 ( 1.0 , 0.0 ) ) , true , 'returns expected value' ) ;
249- t . strictEqual ( isSameComplex128 ( buf . get ( 5 ) , new Complex128 ( 0.0 , 0.0 ) ) , true , 'returns expected value' ) ;
273+ expected = new Complex128Array ( [
274+ 9.0 ,
275+ 9.0 ,
276+ 2.0 , // 2
277+ 0.0 , // 2
278+ 9.0 ,
279+ 9.0 ,
280+ 1.0 , // 1
281+ 0.0 , // 1
282+ 9.0 ,
283+ 9.0 ,
284+ 0.0 , // 0
285+ 0.0 // 0
286+ ] ) ;
287+ t . strictEqual ( isSameComplex128Array ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
250288
251289 t . end ( ) ;
252290} ) ;
0 commit comments