Skip to content

Commit

Permalink
Test field interface conformance for arb types
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Dec 3, 2024
1 parent 00e302b commit 258e64b
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/arb/Complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ function canonical_unit(x::ComplexFieldElem)
return x
end

# TODO: implement hash
# TODO: implement better hash
function hash(a::ComplexFieldElem, h::UInt)
return h
end

characteristic(::ComplexField) = 0

Expand Down
3 changes: 3 additions & 0 deletions src/arb/Real.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ zero(R::RealField) = R(0)
one(R::RealField) = R(1)

# TODO: Add hash (and document under ArbFieldElem basic functionality)
function hash(a::RealFieldElem, h::UInt)
return h
end

@doc raw"""
accuracy_bits(x::RealFieldElem)
Expand Down
3 changes: 3 additions & 0 deletions src/arb/acb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ function canonical_unit(x::AcbFieldElem)
end

# TODO: implement hash
function hash(a::AcbFieldElem, h::UInt)
return h
end

characteristic(::AcbField) = 0

Expand Down
3 changes: 3 additions & 0 deletions src/arb/arb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ zero(R::ArbField) = R(0)
one(R::ArbField) = R(1)

# TODO: Add hash (and document under ArbFieldElem basic functionality)
function hash(a::ArbFieldElem, h::UInt)
return h
end

@doc raw"""
accuracy_bits(x::ArbFieldElem)
Expand Down
17 changes: 17 additions & 0 deletions test/arb/Complex-test.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
RR = RealField()
CC = ComplexField()

function test_elem(R::ComplexField)
randtype = rand((
:urandom,
:randtest,
:randtest_exact,
:randtest_precise,
:randtest_wide,
:randtest_special,
))
return rand(R; randtype)
end

@testset "ComplexFieldElem.conformance_tests" begin
test_Field_interface(CC)
#test_Field_interface_recursive(CC)
end

@testset "ComplexFieldElem.constructors" begin
@test isa(CC, ComplexField)
@test isa(CC(2), FieldElem)
Expand Down
17 changes: 17 additions & 0 deletions test/arb/Real-test.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
RR = RealField()

function test_elem(R::RealField)
randtype = rand((
:urandom,
:randtest,
:randtest_exact,
:randtest_precise,
:randtest_wide,
:randtest_special,
))
return rand(R; randtype)
end

@testset "RealFieldElem.conformance_tests" begin
test_Field_interface(RR)
#test_Field_interface_recursive(RR)
end

@testset "RealFieldElem.precision" begin
old_prec = precision(RealField)

Expand Down
17 changes: 17 additions & 0 deletions test/arb/acb-test.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
RR = ArbField(64)
CC = AcbField(64)

function test_elem(R::AcbField)
randtype = rand((
:urandom,
:randtest,
:randtest_exact,
:randtest_precise,
:randtest_wide,
:randtest_special,
))
return rand(R; randtype)
end

@testset "AcbFieldElem.conformance_tests" begin
test_Field_interface(CC)
#test_Field_interface_recursive(CC)
end

@testset "AcbFieldElem.constructors" begin
@test isa(CC, AcbField)
@test isa(CC(2), FieldElem)
Expand Down
21 changes: 21 additions & 0 deletions test/arb/arb-test.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
RR = ArbField(64)

function test_elem(R::ArbField)
randtype = rand((
:urandom,
:randtest,
:randtest_exact,
:randtest_precise,
:randtest_wide,
:randtest_special,
))
return rand(R; randtype)
end

function equality(a::T, b::T) where T <: Union{ArbFieldElem,RealFieldElem,AcbFieldElem,ComplexFieldElem}
return isequal(a, b)
end

@testset "ArbFieldElem.conformance_tests" begin
test_Field_interface(RR)
#test_Field_interface_recursive(RR)
end

@testset "ArbFieldElem.constructors" begin
@test isa(RR, ArbField)
@test isa(RR(2), FieldElem)
Expand Down

0 comments on commit 258e64b

Please sign in to comment.