I find the process of developing an extension and all the steps extremely puzzling.
So far i have
these files:
– Package.jk
– – Utils.jl
Package is as follows:
module Package
include("Utils.jl")
export Utils.MarsagliaRng, Utils.next_u32, Utils.rand
end
and Utils as follows:
then runtests.jl is
using TestItemRunner
@run_package_tests
and UtilsTests.jl:
using Test
using Rndmwlk
using Rndmwlk.Utils.MarsagliaRng
using Rndmwlk.Utils.next_u32
using Rndmwlk.Utils.rand
@testitem "MarsagliaRng_nextu32" begin
# Test for specific seed and expected results
rng = MarsagliaRng(UInt8.([77, 0, 0, 0])) # Seed = 77
@test next_u32(rng) == 863531084
@test next_u32(rng) == 2082884757
@test next_u32(rng) == 788188464
@test next_u32(rng) == 951323774
@test next_u32(rng) == 744852019
# Reset seed and test again
rng = MarsagliaRng(UInt8.([77, 0, 0, 0])) # Seed = 77
@test next_u32(rng) == 863531084
@test next_u32(rng) == 2082884757
@test next_u32(rng) == 788188464
@test next_u32(rng) == 951323774
@test next_u32(rng) == 744852019
# Test for seed 1
rng = MarsagliaRng(UInt8.([1, 0, 0, 0])) # Seed = 1
@test next_u32(rng) == 1304893148
@test next_u32(rng) == 840426891
@test next_u32(rng) == 2480088888
@test next_u32(rng) == 2020221409
@test next_u32(rng) == 2766137397
end
@tesitem "Uniform Distribution Random Number Generation Tests" begin
#Uniform distribution with seed 33
rng = MarsagliaRng(UInt8.([33, 0, 0, 0])) # Seed = 33
@test isapprox(rand(rng), 0.68160327; atol=1e-8)
@test isapprox(rand(rng), 0.37011177; atol=1e-8)
@test isapprox(rand(rng), 0.00732552; atol=1e-8)
@test isapprox(rand(rng), 0.53339489; atol=1e-8)
@test isapprox(rand(rng), 0.79831550; atol=1e-8)
#Uniform distribution with seed 1
rng = MarsagliaRng(UInt8.([1, 0, 0, 0])) # Seed = 1
@test isapprox(rand(rng), 0.30381911; atol=1e-8)
@test isapprox(rand(rng), 0.19567713; atol=1e-8)
@test isapprox(rand(rng), 0.57744069; atol=1e-8)
@test isapprox(rand(rng), 0.47036945; atol=1e-8)
@test isapprox(rand(rng), 0.64404155; atol=1e-8)
#Repeating tests for seed 33 to ensure repeatability
rng = MarsagliaRng(UInt8.([33, 0, 0, 0])) # Seed = 33, repeat to ensure repeatability
@test isapprox(rand(rng), 0.68160327; atol=1e-8)
@test isapprox(rand(rng), 0.37011177; atol=1e-8)
@test isapprox(rand(rng), 0.00732552; atol=1e-8)
@test isapprox(rand(rng), 0.53339489; atol=1e-8)
@test isapprox(rand(rng), 0.79831550; atol=1e-8)
end
resulting in the most cryptic error message ever:
ERROR: LoadError: syntax: "module" at Package.jl:1 expected "end", got "."
So far its been a few hours trying to understand what’s the differnece between actIVATE .
and dev .
how it all plays out with VsCode, VsCode’s test runner vs Julia native and i think i almost have it in some kind of working state but this error makes no sense. Original package name was rndmwlk
so there might be some refs to it…
Also is there any way to get around having to export every single thing twice or some kind of public private macro? I dont see any value of not having the visibility defined where the symbol is defined but instead having to double export. FYI if i dont export from Package.jl using the FQN in the tests still results in missing symbol…