Skip to content

Commit

Permalink
Merge pull request #8 from andreasnoack/anj/06
Browse files Browse the repository at this point in the history
Get ready for 0.6
  • Loading branch information
andreasnoack authored Dec 30, 2016
2 parents 501a332 + 7eb53cc commit fbb95d7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ os:
- osx

julia:
- 0.3
- 0.4
- 0.5
- nightly
Expand All @@ -14,7 +13,7 @@ notifications:
email:
recipients:
- [email protected]
on_success: never
# on_success: never

#script: # use the default script setting
# - julia -e 'Pkg.init(); Pkg.add("RNGTest")'
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# The Crush test suite of l'Ecuyer for Julia
[![Build Status](https://travis-ci.org/andreasnoack/RNGTest.jl.png)](https://travis-ci.org/andreasnoack/RNGTest.jl)

[![RNGTest](http://pkg.julialang.org/badges/RNGTest_0.4.svg)](http://pkg.julialang.org/?pkg=RNGTest&ver=0.4)
[![RNGTest](http://pkg.julialang.org/badges/RNGTest_0.5.svg)](http://pkg.julialang.org/?pkg=RNGTest&ver=0.5)

The package is a Julia interface to the test suite TestU01 of Pierre l'Ecuyer. All the tests included in the SmallCrush and BigCrush test batteries can be called as Julia functions.
The first argument to the test function must be either

Expand Down
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.3
Compat
julia 0.4
Compat 0.8.5
19 changes: 10 additions & 9 deletions src/RNGTest.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module RNGTest

using Compat
import Compat.String

import Base: convert, getindex, pointer

Expand Down Expand Up @@ -63,17 +64,17 @@ module RNGTest
return g
end

function call{T<:Integer}(g::WrappedRNG{T})
@compat function (g::WrappedRNG{T}){T<:Integer}()
g.idx+1 > length(g.vals) && fillcache(g)
@inbounds return g.vals[g.idx+=1]
end

function call(g::WrappedRNG{Float64})
@compat function (g::WrappedRNG{Float64})()
g.idx+1 > length(g.cache) && fillcache(g)
@inbounds return g.cache[g.idx+=1]
end

function call(g::WrappedRNG{Float32})
@compat function (g::WrappedRNG{Float32})()
g.idx+3 > length(g.cache) && fillcache(g)
@inbounds begin
f = Float64(g.cache[g.idx+1])
Expand All @@ -84,7 +85,7 @@ module RNGTest
end
end

function call(g::WrappedRNG{Float16})
@compat function (g::WrappedRNG{Float16})()
g.idx+6 > length(g.cache) && fillcache(g)
@inbounds begin
f = Float64(g.cache[g.idx+1])
Expand All @@ -103,7 +104,7 @@ module RNGTest
type Unif01
ptr::Ptr{Array{Int32}}
gentype::Type
name::ASCIIString
name::String
function Unif01(f::Function, genname)
for i in 1:100
tmp = f()
Expand All @@ -118,14 +119,14 @@ module RNGTest

@compat function Unif01{T<:AbstractFloat}(g::WrappedRNG{T}, genname)
# we assume that g being created out of an AbstractRNG, it produces Floats in the interval [0,1)
@eval f() = call($g) :: Float64
@eval f() = ($g)() :: Float64
cf = cfunction(f, Float64, ())
@compat return new(ccall((:unif01_CreateExternGen01, libtestu01), Ptr{Void}, (Ptr{UInt8}, Ptr{Void}), genname, cf), Float64)
end

function Unif01{T<:Integer}(g::WrappedRNG{T}, genname)
@assert Cuint === UInt32
@eval f() = call($g) :: UInt32
@eval f() = ($g)() :: UInt32
cf = cfunction(f, UInt32, ())
@compat return new(ccall((:unif01_CreateExternGenBits, libtestu01), Ptr{Void}, (Ptr{UInt8}, Ptr{Void}), genname, cf), UInt32)
end
Expand Down Expand Up @@ -825,7 +826,7 @@ module RNGTest
##################
for (snm, fnm) in ((:SmallCrush, :smallcrushTestU01), (:Crush, :crushTestU01), (:BigCrush, :bigcrushTestU01), (:pseudoDIEHARD, :diehardTestU01), (:FIPS_140_2, :fips_140_2TestU01))
@eval begin
function $(fnm)(f::Generator, fname::ByteString)
function $(fnm)(f::Generator, fname::String)
unif01 = Unif01(f, fname)
ccall(($(string("bbattery_", snm)), libtestu01), Void, (Ptr{Void},), unif01.ptr)
delete(unif01)
Expand Down

0 comments on commit fbb95d7

Please sign in to comment.