Introduce tolerance in tests of numeric functions.

There are slight differences across CPU architectures which we cannot
avoid. These should have no practical consequences for the users.
This commit is contained in:
Stanisław Barzowski 2020-02-02 12:23:25 +01:00
parent 03f5ad2dc0
commit 5976644a3b
7 changed files with 16 additions and 6 deletions

View File

@ -1 +1 @@
0.78539816339744828
"0.785398163397448"

View File

@ -1 +1,2 @@
std.atan(1)
local tolerance = (import 'tolerance.libsonnet').tolerance;
tolerance(std.atan(1))

View File

@ -1 +1 @@
1.5574077246549021
"1.557407724654902"

View File

@ -1 +1,2 @@
std.tan(1)
local tolerance = (import 'tolerance.libsonnet').tolerance;
tolerance(std.tan(1))

View File

@ -1 +1 @@
1.1486983549970351
"1.148698354997035"

View File

@ -1 +1,2 @@
std.pow(2, 0.2)
local tolerance = (import 'tolerance.libsonnet').tolerance;
tolerance(std.pow(2, 0.2))

7
testdata/tolerance.libsonnet vendored Normal file
View File

@ -0,0 +1,7 @@
{
// Formats a floating point number to get 15 digits
// after the decimal point. It is used for some tests
// of numeric functions, where a range of values is
// acceptable, due to differences in cpu architecture.
tolerance(x):: "%.15f" % x
}