diff --git a/.github/workflows/UnitTest.yml b/.github/workflows/UnitTest.yml index 5c6d49fa..1b5e8b4d 100644 --- a/.github/workflows/UnitTest.yml +++ b/.github/workflows/UnitTest.yml @@ -1,11 +1,11 @@ name: Unit test on: - create: - tags: push: branches: - master + - release-* + tags: ['*'] pull_request: jobs: @@ -15,13 +15,15 @@ jobs: fail-fast: false matrix: julia-version: ['1.0', '1', '1.6', 'nightly'] - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macos-13] julia-arch: [x64] - # only test one 32-bit job include: - - os: ubuntu-latest + - os: ubuntu-latest # only test one 32-bit job julia-version: '1' julia-arch: x86 + - os: macos-latest + julia-version: '1' + julia-arch: aarch64 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/UnitTestArm.yml b/.github/workflows/UnitTestArm.yml index 4b712be3..5929fe08 100644 --- a/.github/workflows/UnitTestArm.yml +++ b/.github/workflows/UnitTestArm.yml @@ -15,8 +15,8 @@ jobs: strategy: fail-fast: false matrix: - julia-version: ['1.0', '1', '1.6', 'nightly'] - os: [ubuntu-latest] + julia-version: ['1.0', '1.6', '1', 'nightly'] + os: [macos-latest] distro: [ubuntu_latest] arch: [aarch64] @@ -24,7 +24,8 @@ jobs: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v2 with: - version: ${{ matrix.julia-version }} + version: '1' + arch: aarch64 - uses: julia-actions/cache@v1 - name: Download Julia Binary run: > @@ -46,8 +47,8 @@ jobs: - name: Extract Julia Files run: | - mkdir -p /home/runner/work/julia/ - tar -xf /tmp/julia-aarch64.tar.gz --strip-components=1 -C /home/runner/work/julia/ + mkdir -p /Users/runner/work/julia/ + tar -xf /tmp/julia-aarch64.tar.gz --strip-components=1 -C /Users/runner/work/julia/ rm /tmp/julia-aarch64.tar.gz - uses: uraimo/run-on-arch-action@v2.7.1 @@ -56,12 +57,12 @@ jobs: arch: ${{ matrix.arch }} distro: ${{ matrix.distro }} dockerRunArgs: | - -v "/home/runner/work/julia:/home/runner/work/julia" - -v "/home/runner/.julia/registries:/root/.julia/registries" + -v "/Users/runner/work/julia:/home/runner/work/julia" + -v "/Users/runner/.julia/registries:/root/.julia/registries" --net=host install: | - ln -s /home/runner/work/julia/bin/julia /usr/local/bin/julia - echo /home/runner/work/julia/lib > /etc/ld.so.conf.d/julia.conf + ln -s /Users/runner/work/julia/bin/julia /usr/local/bin/julia + echo /Users/runner/work/julia/lib > /etc/ld.so.conf.d/julia.conf mkdir -p /root/.julia/registries/General run: | julia --compile=min -O0 -e 'using InteractiveUtils; versioninfo();' diff --git a/test/fixed.jl b/test/fixed.jl index 8fbb1bf8..3836a9a2 100644 --- a/test/fixed.jl +++ b/test/fixed.jl @@ -7,6 +7,25 @@ function symbol_to_inttype(::Type{Fixed}, s::Symbol) d[s] end +# issue #288 +# The following needs to be outside of `@testset` to reproduce the issue. +# issue #288 +# The following needs to be outside of `@testset` to reproduce the issue. +@inline _to_fixed(::Val, x) = x % Q0f7 +@inline _to_fixed(::Val{:Q0f15}, x) = x % Q0f15 +function _issue288(::Type{Fixed}, x) + buf = IOBuffer() + for sym in (:Q0f7, :Q0f15) + show(buf, _to_fixed(Val(sym), x)) + print(buf, " ") + end + for sym in (:Q0f15, :Q0f7) + show(buf, _to_fixed(Val(sym), x)) + print(buf, " ") + end + return String(take!(buf)) +end + function test_op(fun::Fun, fx::F, fy::F, fxf, fyf, tol) where {Fun, F} # Make sure that the result is representable zf = fun(fxf, fyf) @@ -282,6 +301,23 @@ end @test -1 % Q0f7 === Q0f7(-1) @test -2 % Q0f7 === Q0f7(0) + + # issue #288 + expected_issue288 = "-1.0Q0f7 -1.0Q0f15 -1.0Q0f15 -1.0Q0f7 " + if _issue288(Fixed, -1.0) == expected_issue288 # just leave it in the report + @test _issue288(Fixed, -1.0) == expected_issue288 + else + @test_broken _issue288(Fixed, -1.0) == expected_issue288 + @warn """broken: "$(_issue288(Fixed, -1.0))"\nexpected: "$expected_issue288" """ + end + # out of range + expected_issue288 = "-1.0Q0f7 -1.0Q0f15 -1.0Q0f15 -1.0Q0f7 " + if _issue288(Fixed, 1.0) == expected_issue288 # just leave it in the report + @test _issue288(Fixed, 1.0) == expected_issue288 + else + @test_broken _issue288(Fixed, 1.0) == expected_issue288 + @warn """broken: "$(_issue288(Fixed, 1.0))"\nexpected: "$expected_issue288" """ + end end @testset "neg" begin diff --git a/test/normed.jl b/test/normed.jl index 4678182c..8bed8337 100644 --- a/test/normed.jl +++ b/test/normed.jl @@ -7,6 +7,25 @@ function symbol_to_inttype(::Type{Normed}, s::Symbol) d[s] end +# issue #288 +# The following needs to be outside of `@testset` to reproduce the issue. +@inline _to_normed(::Val, x) = x % N0f8 +@inline _to_normed(::Val{:N0f16}, x) = x % N0f16 +function _issue288(::Type{Normed}, x) + buf = IOBuffer() + for sym in (:N0f8, :N0f16) + print(buf, _to_normed(Val(sym), -1.0)) + print(buf, " ") + end + #= + for sym in (:N0f16, :N0f8) + show(buf, _to_normed(Val(sym), -1.0)) + print(buf, " ") + end + =# + return String(take!(buf)) +end + @testset "domain of f" begin @test_throws DomainError zero(Normed{UInt8,-1}) @test_throws DomainError zero(Normed{UInt8,0}) @@ -279,6 +298,23 @@ end # issue #211 @test big"1.2" % N0f8 === 0.196N0f8 @test reinterpret(BigFloat(0x0_01234567_89abcdef) % N63f1) === 0x01234567_89abcdef + + # issue #288 + expected_issue288 = "1.0N0f8 1.0N0f16 1.0N0f16 1.0N0f8 " + if _issue288(Normed, 1.0) == expected_issue288 # just leave it in the report + @test _issue288(Normed, 1.0) == expected_issue288 + else + @test_broken _issue288(Normed, 1.0) == expected_issue288 + @warn """broken: "$(_issue288(Normed, 1.0))"\nexpected: "$expected_issue288" """ + end + # out of range + expected_issue288 = "0.502N0f8 0.50001N0f16 0.50001N0f16 0.502N0f8 " + if _issue288(Normed, -0.5) == expected_issue288 # just leave it in the report + @test _issue288(Normed, -0.5) == expected_issue288 + else + @test_broken _issue288(Normed, -0.5) == expected_issue288 + @warn """broken: "$(_issue288(Normed, -0.5))"\nexpected: "$expected_issue288" """ + end end @testset "arithmetic" begin diff --git a/test/runtests.jl b/test/runtests.jl index d037d440..32b74c61 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,5 @@ using FixedPointNumbers, Test, Aqua - +@info Sys.ARCH Aqua.test_all(FixedPointNumbers) if Sys.ARCH === :x86_64 || Sys.ARCH === :i686