Skip to content

Commit 239a3c8

Browse files
committed
test: follow latest project conventions
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent f4756db commit 239a3c8

2 files changed

Lines changed: 27 additions & 14 deletions

File tree

lib/node_modules/@stdlib/math/base/special/cfloornf/test/test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ tape( 'if a component is too large a float to have decimals and `n < 0`, the com
197197
x = f32( sign * (1.0+randu()) * powf( 10.0, exp ) );
198198
n = -( round( randu()*38.0) );
199199
v = cfloornf( new Complex64( x, x ), n );
200-
t.strictEqual( real( v ), x, ' returns expected value' );
201-
t.strictEqual( imag( v ), x, ' returns expected value' );
200+
t.strictEqual( real( v ), x, 'returns expected value' );
201+
t.strictEqual( imag( v ), x, 'returns expected value' );
202202
}
203203
t.end();
204204
});
@@ -214,8 +214,8 @@ tape( 'if `n > 38` and a component is less than zero, the function returns `-inf
214214
x = f32( -(1.0+randu()) * powf( 10.0, exp ) );
215215
n = round( randu()*10.0 ) + 39;
216216
v = cfloornf( new Complex64( x, x ), n );
217-
t.strictEqual( real( v ), NINF, ' returns -infinity' );
218-
t.strictEqual( imag( v ), NINF, ' returns -infinity' );
217+
t.strictEqual( real( v ), NINF, 'returns expected value' );
218+
t.strictEqual( imag( v ), NINF, 'returns expected value' );
219219
}
220220
t.end();
221221
});
@@ -231,8 +231,8 @@ tape( 'if `n > 38` and a component is greater than or equal to zero, the functio
231231
x = f32( (1.0+randu()) * powf( 10.0, exp ) );
232232
n = round( randu()*10.0 ) + 39;
233233
v = cfloornf( new Complex64( x, x ), n );
234-
t.strictEqual( isPositiveZerof( real( v ) ), true, ' returns +0' );
235-
t.strictEqual( isPositiveZerof( imag( v ) ), true, ' returns +0' );
234+
t.strictEqual( isPositiveZerof( real( v ) ), true, 'returns expected value' );
235+
t.strictEqual( isPositiveZerof( imag( v ) ), true, 'returns expected value' );
236236
}
237237
t.end();
238238
});
@@ -272,7 +272,7 @@ tape( 'rounding components to a desired number of decimals can result in unexpec
272272
v = cfloornf( new Complex64( x, x ), -6 );
273273

274274
// The result may differ slightly from -0.3 due to float32 precision:
275-
t.strictEqual( isnanf( real( v ) ), false, 'returns a number and not NaN' );
276-
t.strictEqual( isnanf( imag( v ) ), false, 'returns a number and not NaN' );
275+
t.strictEqual( isnanf( real( v ) ), false, 'returns expected value' );
276+
t.strictEqual( isnanf( imag( v ) ), false, 'returns expected value' );
277277
t.end();
278278
});

lib/node_modules/@stdlib/math/base/special/cfloornf/test/test.native.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ tape( 'if a component is too large a float to have decimals and `n < 0`, the com
161161
x = f32( sign * (1.0+randu()) * powf( 10.0, exp ) );
162162
n = -( round( randu()*38.0) );
163163
v = cfloornf( new Complex64( x, x ), n );
164-
t.strictEqual( real( v ), x, ' returns expected value' );
165-
t.strictEqual( imag( v ), x, ' returns expected value' );
164+
t.strictEqual( real( v ), x, 'returns expected value' );
165+
t.strictEqual( imag( v ), x, 'returns expected value' );
166166
}
167167
t.end();
168168
});
@@ -178,8 +178,8 @@ tape( 'if `n > 38` and a component is less than zero, the function returns `-inf
178178
x = f32( -(1.0+randu()) * powf( 10.0, exp ) );
179179
n = round( randu()*10.0 ) + 39;
180180
v = cfloornf( new Complex64( x, x ), n );
181-
t.strictEqual( real( v ), NINF, ' returns -infinity' );
182-
t.strictEqual( imag( v ), NINF, ' returns -infinity' );
181+
t.strictEqual( real( v ), NINF, 'returns expected value' );
182+
t.strictEqual( imag( v ), NINF, 'returns expected value' );
183183
}
184184
t.end();
185185
});
@@ -195,8 +195,8 @@ tape( 'if `n > 38` and a component is greater than or equal to zero, the functio
195195
x = f32( (1.0+randu()) * powf( 10.0, exp ) );
196196
n = round( randu()*10.0 ) + 39;
197197
v = cfloornf( new Complex64( x, x ), n );
198-
t.strictEqual( isPositiveZerof( real( v ) ), true, ' returns +0' );
199-
t.strictEqual( isPositiveZerof( imag( v ) ), true, ' returns +0' );
198+
t.strictEqual( isPositiveZerof( real( v ) ), true, 'returns expected value' );
199+
t.strictEqual( isPositiveZerof( imag( v ) ), true, 'returns expected value' );
200200
}
201201
t.end();
202202
});
@@ -227,3 +227,16 @@ tape( 'if the function encounters overflow, the function returns the input compo
227227

228228
t.end();
229229
});
230+
231+
tape( 'rounding components to a desired number of decimals can result in unexpected behavior due to floating-point representation', opts, function test( t ) {
232+
var x;
233+
var v;
234+
235+
x = f32( -0.2 - 0.1 );
236+
v = cfloornf( new Complex64( x, x ), -6 );
237+
238+
// The result may differ slightly from -0.3 due to float32 precision:
239+
t.strictEqual( isnanf( real( v ) ), false, 'returns expected value' );
240+
t.strictEqual( isnanf( imag( v ) ), false, 'returns expected value' );
241+
t.end();
242+
});

0 commit comments

Comments
 (0)