From 16dcd3b9948ec67248e9494109af108680b4d6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20H=C3=A9not?= <38465572+OlivierHnt@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:10:12 +0200 Subject: [PATCH] Fix decoration for `atan` with two arguments (#672) * Fix `atan` decoration * Fix the parsing of the test suite --- src/intervals/arithmetic/trigonometric.jl | 7 ++++--- test/ITF1788_tests/libieeep1788_elem.jl | 3 ++- test/generate_ITF1788.jl | 16 ++++++++++++---- test/runtests.jl | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/intervals/arithmetic/trigonometric.jl b/src/intervals/arithmetic/trigonometric.jl index 9350526dd..8a64da63b 100644 --- a/src/intervals/arithmetic/trigonometric.jl +++ b/src/intervals/arithmetic/trigonometric.jl @@ -565,9 +565,10 @@ function Base.atan(y::Interval, x::Interval) d = min(decoration(y), decoration(x), decoration(r)) d = min(d, ifelse(in_interval(0, by), - ifelse(in_interval(0, bx), trv, - ifelse(sup(bx) < 0, ifelse(inf(by) < 0, def, dac), d)), - d)) + ifelse(in_interval(0, bx), + trv, + ifelse(sup(bx) < 0, ifelse(inf(by) < 0, def, d), d)), + d)) t = isguaranteed(y) & isguaranteed(x) return _unsafe_interval(r, d, t) end diff --git a/test/ITF1788_tests/libieeep1788_elem.jl b/test/ITF1788_tests/libieeep1788_elem.jl index b214fbf9b..a98c27fbe 100644 --- a/test/ITF1788_tests/libieeep1788_elem.jl +++ b/test/ITF1788_tests/libieeep1788_elem.jl @@ -7144,7 +7144,8 @@ end @test atan(interval(bareinterval(-0.0, 1.0), com), interval(bareinterval(-0.0, -0.0), def)) === interval(bareinterval(0x1.921FB54442D18P+0, 0x1.921FB54442D19P+0), trv) - @test atan(interval(bareinterval(-0.0, 1.0), com), interval(bareinterval(-2.0, -0.1), com)) === interval(bareinterval(0x1.ABA397C7259DDP+0, 0x1.921FB54442D19P+1), dac) + @warn "The original test `atan2 [-0.0, 1.0]_com [-2.0, -0.1]_com = [0X1.ABA397C7259DDP+0, 0X1.921FB54442D19P+1]_dac` is wrong and has been modified. The result should have the decoration `com`" + @test atan(interval(bareinterval(-0.0, 1.0), com), interval(bareinterval(-2.0, -0.1), com)) === interval(bareinterval(0x1.ABA397C7259DDP+0, 0x1.921FB54442D19P+1), com) @test atan(interval(bareinterval(-0.0, 1.0), def), interval(bareinterval(-2.0, 0.0), com)) === interval(bareinterval(0x1.921FB54442D18P+0, 0x1.921FB54442D19P+1), trv) diff --git a/test/generate_ITF1788.jl b/test/generate_ITF1788.jl index 992021d76..0dca9e659 100644 --- a/test/generate_ITF1788.jl +++ b/test/generate_ITF1788.jl @@ -158,10 +158,18 @@ function parse_command(line) rhs = parse_rhs(rhs) expr = build_expression(lhs, rhs) + command = "@test $expr" - # one known broken test, unrelated to interval airthmetic - command = occursin("dot_nearest {0x10000000000001p0, 0x1p104} {0x0fffffffffffffp0, -1.0} = -1.0", line) ? - "@test_broken $expr" : "@test $expr" + if occursin("dot_nearest {0x10000000000001p0, 0x1p104} {0x0fffffffffffffp0, -1.0} = -1.0", line) + # broken test unrelated to interval airthmetic + command = "@test_broken $expr" + elseif occursin("atan2 [-0.0, 1.0]_com [-2.0, -0.1]_com = [0X1.ABA397C7259DDP+0, 0X1.921FB54442D19P+1]_dac", line) + # erroneous test: the decoration of the result should be `com` + command = + """ + @warn "The original test `atan2 [-0.0, 1.0]_com [-2.0, -0.1]_com = [0X1.ABA397C7259DDP+0, 0X1.921FB54442D19P+1]_dac` is wrong and has been modified. The result should have the decoration `com`" + @test atan(interval(bareinterval(-0.0, 1.0), com), interval(bareinterval(-2.0, -0.1), com)) === interval(bareinterval(0x1.ABA397C7259DDP+0, 0x1.921FB54442D19P+1), com)""" + end command = haswarning ? "@test_logs (:warn,) $command" : command @@ -238,7 +246,7 @@ end function parse_interval(ival::AbstractString, dec::Union{Nothing,AbstractString}) ival == "nai" && return "nai(Interval{Float64})" if ival == "entire" - ival = "entireinterval(BareInterval{Float64})" + ival = "entireinterval(BareInterval{Float64})" elseif ival == "empty" ival = "emptyinterval(BareInterval{Float64})" else diff --git a/test/runtests.jl b/test/runtests.jl index aabd85d91..1c5cf2d50 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,4 +24,4 @@ for f ∈ readdir("ITF1788_tests"; join = true) @testset "$f" begin include(f) end -end \ No newline at end of file +end