Skip to content

Commit

Permalink
Update tests to run
Browse files Browse the repository at this point in the history
Also prints test sections if VERBOSE

Also normalize whitespace
  • Loading branch information
jiahao committed Feb 26, 2015
1 parent 7a1fc22 commit 973c91c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
18 changes: 12 additions & 6 deletions test/9_Permutations.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
==(P::gsl_permutation, Q::gsl_permutation) = P.size == Q.size &&
==(P::gsl_permutation, Q::gsl_permutation) = P.size == Q.size &&
pointer_to_array(P.data, (int(P.size),)) == pointer_to_array(Q.data, (int(Q.size),))
==(P::Ptr{gsl_permutation}, Q::Ptr{gsl_permutation}) = unsafe_load(P) == unsafe_load(Q)

n = int(rand()*20)+1

#9.2 Permutation allocation

VERBOSE && info("9.2 Permutation allocation")

P = permutation_alloc(n)
permutation_init(P)
Expand All @@ -16,7 +17,8 @@ permutation_memcpy(R, Q)
@test P==Q==R
permutation_free(R)

#9.3 Accessing permutation elements

VERBOSE && info("9.3 Accessing permutation elements")

for i=0:n-1
@test i == permutation_get(P, i)
Expand All @@ -30,17 +32,21 @@ for i=0:n-1
end
end

#9.4 Permutation properties

VERBOSE && info("9.4 Permutation properties")

@test permutation_size(P) == n
@test permutation_data(P) == unsafe_load(P).data

@test permutation_valid(P)
pointer_to_array(unsafe_load(P).data, (int(unsafe_load(P).size),))[1]=-1
pointer_to_array(unsafe_load(P).data, (int(unsafe_load(P).size),))[1]=1000
@test !permutation_valid(P)
pointer_to_array(unsafe_load(P).data, (int(unsafe_load(P).size),))[1]=0
@test permutation_valid(P)

#9.5 Permutation functions

VERBOSE && info("9.5 Permutation functions")

permutation_reverse(P)
Q=permutation_inverse(P)
@test P==Q
Expand Down
4 changes: 3 additions & 1 deletion test/HypergeometricFunctions.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VERBOSE && info("Hypergeometric functions")

a = 3*randn()
b = 3*randn()
c = 3*randn()
Expand All @@ -16,7 +18,7 @@ x = 2*rand()-1
@test_approx_eq 1+x sf_hyperg_U(-1.0, -1.0, x)

#"Cancellation theorem" that reduces order of hypergeometric function
@test_approx_eq hypergeom([a], [a], x) hypergeom([], [], x)
@test_approx_eq hypergeom([a], [a], x) hypergeom(Float64[], Float64[], x)

c = a+b+3*rand()
@test_approx_eq hypergeom([a, b], c, 1.0) (gamma(c)*gamma(c-a-b)/(gamma(c-a)*gamma(c-b)))
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ using Base.Test
using GSL

const VERBOSE=false #change to show test output

srand(1)
include("basic.jl")
include("9_Permutations.jl")
include("HypergeometricFunctions.jl")

0 comments on commit 973c91c

Please sign in to comment.