From 0b64e71ab31205e473a8e6c5e0b06483c85a7340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Fri, 4 Apr 2025 10:36:05 +0200 Subject: [PATCH 1/4] Test src/julia/Float.jl --- test/Nemo-test.jl | 2 ++ test/julia/Float-test.jl | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/julia/Float-test.jl diff --git a/test/Nemo-test.jl b/test/Nemo-test.jl index 7bc810b55..267043580 100644 --- a/test/Nemo-test.jl +++ b/test/Nemo-test.jl @@ -1,6 +1,8 @@ testlist = [ # Aqua.jl "Aqua.jl", +# Julia extensions + "julia/Float-test.jl", # Fields-test.jl "flint/fmpq-test.jl", "flint/gfp-test.jl", diff --git a/test/julia/Float-test.jl b/test/julia/Float-test.jl new file mode 100644 index 000000000..4a569b277 --- /dev/null +++ b/test/julia/Float-test.jl @@ -0,0 +1,14 @@ +@testset "BigFloat manipulation" begin + a = BigFloat(5) / BigFloat(3) + b = BigFloat(1) / BigFloat(7) + def_prec = Base.MPFR.DEFAULT_PRECISION.x + new_prec = 127 + + @test precision(a) == def_prec + setprecision!(a, new_prec) + @test precision(a) == new_prec + setprecision!(b, new_prec) + @test precision(b) == new_prec + mul!(a, a, b) # Does not work with a *= b + @test precision(a) == new_prec +end From ea338229c5a05e87d243b7d56b2bb8abfbdfc987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Fri, 4 Apr 2025 11:11:28 +0200 Subject: [PATCH 2/4] Test src/julia/Integer.jl --- test/Nemo-test.jl | 1 + test/julia/Integer-test.jl | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/julia/Integer-test.jl diff --git a/test/Nemo-test.jl b/test/Nemo-test.jl index 267043580..554471370 100644 --- a/test/Nemo-test.jl +++ b/test/Nemo-test.jl @@ -3,6 +3,7 @@ testlist = [ "Aqua.jl", # Julia extensions "julia/Float-test.jl", + "julia/Integer-test.jl", # Fields-test.jl "flint/fmpq-test.jl", "flint/gfp-test.jl", diff --git a/test/julia/Integer-test.jl b/test/julia/Integer-test.jl new file mode 100644 index 000000000..a2a969803 --- /dev/null +++ b/test/julia/Integer-test.jl @@ -0,0 +1,28 @@ +@testset "Prime wrappers" begin + a = UInt8(3) + @test is_prime(a) + b = next_prime(a) + @test b == UInt8(5) + @test typeof(b) == UInt8 +end + +@testset "UInt valuation" begin + for (a, b) in [(1, 2), (4, 2), (9, 3), (12, 2), (12, 3), (12, 4), (12, 5)] + @test valuation(UInt(a), UInt(b)) == valuation(a, b) + end +end + +@testset "Integer fits" begin + @test fits(Int, typemin(Int)) + @test fits(Int, typemax(Int)) + @test !fits(Int, typemax(UInt)) + @test fits(Int, typemin(UInt)) + @test fits(Int, UInt(typemax(Int))) +end + +@testset "Integer clog" begin + @test clog(7, 2) == 3 + @test clog(8, 2) == 3 + @test clog(25, 5) == 2 + @test clog(27, 5) == 3 +end From ba32987738807bc8bfc095fe6a86f8ccba0349f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Fri, 4 Apr 2025 11:26:20 +0200 Subject: [PATCH 3/4] Test src/julia/Rational.jl --- test/Nemo-test.jl | 1 + test/julia/Rational-test.jl | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 test/julia/Rational-test.jl diff --git a/test/Nemo-test.jl b/test/Nemo-test.jl index 554471370..091d41db7 100644 --- a/test/Nemo-test.jl +++ b/test/Nemo-test.jl @@ -4,6 +4,7 @@ testlist = [ # Julia extensions "julia/Float-test.jl", "julia/Integer-test.jl", + "julia/Rational-test.jl", # Fields-test.jl "flint/fmpq-test.jl", "flint/gfp-test.jl", diff --git a/test/julia/Rational-test.jl b/test/julia/Rational-test.jl new file mode 100644 index 000000000..02a12b13c --- /dev/null +++ b/test/julia/Rational-test.jl @@ -0,0 +1,15 @@ +@testset "Rational in-place operations" begin + a = 1 // 3 + b = 3 // 2 + q = 0 // 1 + n = 0 + d = 0 + + q = divexact!(q, a, b) + n = numerator!(n, q) + d = denominator!(d, q) + + @test q == 2 // 9 && typeof(q) == Rational{Int} + @test n == 2 && typeof(n) == Int + @test d == 9 && typeof(d) == Int +end From 5a60aa7d48d27c923b00561109f120ee35035a1f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 7 May 2025 21:52:32 +0200 Subject: [PATCH 4/4] Update test/julia/Float-test.jl Co-authored-by: Tommy Hofmann --- test/julia/Float-test.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/julia/Float-test.jl b/test/julia/Float-test.jl index 4a569b277..79320c419 100644 --- a/test/julia/Float-test.jl +++ b/test/julia/Float-test.jl @@ -1,7 +1,7 @@ @testset "BigFloat manipulation" begin a = BigFloat(5) / BigFloat(3) b = BigFloat(1) / BigFloat(7) - def_prec = Base.MPFR.DEFAULT_PRECISION.x + def_prec = precision(BigFloat) new_prec = 127 @test precision(a) == def_prec