@@ -80,7 +80,7 @@ tape( 'the method throws an error if invoked with a `this` context which is not
8080 }
8181} ) ;
8282
83- tape ( 'the method throws an error if provided `fromIndex` argument which is not an integer' , function test ( t ) {
83+ tape ( 'the method throws an error if provided a second argument which is not an integer' , function test ( t ) {
8484 var values ;
8585 var ctor ;
8686 var arr ;
@@ -113,7 +113,7 @@ tape( 'the method throws an error if provided `fromIndex` argument which is not
113113 }
114114} ) ;
115115
116- tape ( 'the method returns `-1` if provided fromIndex argument which exceeds array dimensions' , function test ( t ) {
116+ tape ( 'the method returns `-1` if provided a second argument which exceeds array dimensions' , function test ( t ) {
117117 var ctor ;
118118 var arr ;
119119 var v ;
@@ -122,7 +122,7 @@ tape( 'the method returns `-1` if provided fromIndex argument which exceeds arra
122122 ctor = factory ( 'float64' ) ;
123123 arr = new ctor ( 'little-endian' , [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 ] ) ;
124124
125- for ( i = arr . length ; i < arr . length + 5 ; i ++ ) {
125+ for ( i = arr . length ; i < arr . length + 5 ; i ++ ) {
126126 v = arr . indexOf ( 1.0 , i ) ;
127127 t . strictEqual ( v , - 1 , 'returns expected value' ) ;
128128 }
@@ -138,12 +138,12 @@ tape( 'the method returns `-1` if operating on an empty array', function test( t
138138 arr = new ctor ( 'little-endian' , [ ] ) ;
139139
140140 v = arr . indexOf ( 1.0 ) ;
141- t . strictEqual ( v , - 1 , 'returns -1 for an empty array ' ) ;
141+ t . strictEqual ( v , - 1 , 'returns expected value ' ) ;
142142
143143 t . end ( ) ;
144144} ) ;
145145
146- tape ( 'the method returns `-1` if element not found' , function test ( t ) {
146+ tape ( 'the method returns `-1` if a search element is not found' , function test ( t ) {
147147 var ctor ;
148148 var arr ;
149149 var v ;
@@ -152,12 +152,12 @@ tape( 'the method returns `-1` if element not found', function test( t ) {
152152 arr = new ctor ( 'little-endian' , [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 ] ) ;
153153
154154 v = arr . indexOf ( 10.0 ) ;
155- t . strictEqual ( v , - 1 , 'returns -1 when element is not found ' ) ;
155+ t . strictEqual ( v , - 1 , 'returns expected value ' ) ;
156156
157157 t . end ( ) ;
158158} ) ;
159159
160- tape ( 'the method returns the index of the first match if element is found' , function test ( t ) {
160+ tape ( 'the method returns the index of the first match if an element is found' , function test ( t ) {
161161 var ctor ;
162162 var arr ;
163163 var v ;
@@ -166,7 +166,7 @@ tape( 'the method returns the index of the first match if element is found', fun
166166 arr = new ctor ( 'little-endian' , [ 1.0 , 2.0 , 3.0 , 4.0 , 2.0 ] ) ;
167167
168168 v = arr . indexOf ( 2.0 ) ;
169- t . strictEqual ( v , 1 , 'returns index of the first match when the element is found ' ) ;
169+ t . strictEqual ( v , 1 , 'returns expected value ' ) ;
170170
171171 t . end ( ) ;
172172} ) ;
@@ -179,8 +179,14 @@ tape( 'the method supports specifying a starting search index', function test( t
179179 ctor = factory ( 'float64' ) ;
180180 arr = new ctor ( 'little-endian' , [ 1.0 , 2.0 , 3.0 , 4.0 , 2.0 ] ) ;
181181
182+ v = arr . indexOf ( 2.0 , 0 ) ;
183+ t . strictEqual ( v , 2 , 'returns expected value' ) ;
184+
182185 v = arr . indexOf ( 2.0 , 2 ) ;
183- t . strictEqual ( v , 4 , 'returns index of the match starting from the specified index' ) ;
186+ t . strictEqual ( v , 4 , 'returns expected value' ) ;
187+
188+ v = arr . indexOf ( 1.0 , 4 ) ;
189+ t . strictEqual ( v , - 1 , 'returns expected value' ) ;
184190
185191 t . end ( ) ;
186192} ) ;
@@ -194,7 +200,10 @@ tape( 'the method supports specifying a starting search index (negative)', funct
194200 arr = new ctor ( 'little-endian' , [ 1.0 , 2.0 , 3.0 , 4.0 , 2.0 ] ) ;
195201
196202 v = arr . indexOf ( 2.0 , - 3 ) ;
197- t . strictEqual ( v , 4 , 'returns index of the match starting from the resolved negative index' ) ;
203+ t . strictEqual ( v , 4 , 'returns expected value' ) ;
204+
205+ v = arr . indexOf ( 1.0 , - 3 ) ;
206+ t . strictEqual ( v , - 1 , 'returns expected value' ) ;
198207
199208 t . end ( ) ;
200209} ) ;
@@ -208,7 +217,10 @@ tape( 'when provided a starting index which resolves to an index less than zero,
208217 arr = new ctor ( 'little-endian' , [ 1.0 , 2.0 , 3.0 , 4.0 , 2.0 ] ) ;
209218
210219 v = arr . indexOf ( 2.0 , - 10 ) ;
211- t . strictEqual ( v , 1 , 'returns index of the match starting from the first array element when starting index resolves to less than zero' ) ;
220+ t . strictEqual ( v , 1 , 'returns expected value' ) ;
221+
222+ v = arr . indexOf ( 1.0 , - 10 ) ;
223+ t . strictEqual ( v , 0 , 'returns expected value' ) ;
212224
213225 t . end ( ) ;
214226} ) ;
0 commit comments