From 050c555777ed4c534152c9aa4a2c148929850ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20F=20Schrauf?= Date: Tue, 27 Dec 2016 10:38:30 -0300 Subject: [PATCH 1/3] Update for julia v0.5 Most importantly, changed inspection of lambda function --- src/QuickCheck.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/QuickCheck.jl b/src/QuickCheck.jl index 6c63614..6ec22a4 100644 --- a/src/QuickCheck.jl +++ b/src/QuickCheck.jl @@ -10,10 +10,15 @@ export condproperty export quantproperty function lambda_arg_types(f::Function) - if !isa(f.code, LambdaStaticData) + if !isa(f, Function) error("You must supply either an anonymous function with typed arguments or an array of argument types.") end - [eval(var.args[2]) for var in Base.uncompressed_ast(f.code).args[1]] + # [eval(var.args[2]) for var in Base.uncompressed_ast(f.code).args[1]] + c = methods(f).ms + if length(c) != 1 + error("The function must have one, and only one mehtod.") + end + [c[1].sig.parameters[2:end]...] end # Simple properties @@ -43,7 +48,7 @@ function check_property(prop::Function, arggens, argconds, ntests, maxtests) totalTests = 0 for i in 1:ntests goodargs = false - args = {} + args = [] while !goodargs totalTests += 1 if totalTests > maxtests @@ -63,7 +68,7 @@ end # Default generators for primitive types generator{T<:Unsigned}(::Type{T}, size) = convert(T, rand(1:size)) generator{T<:Signed}(::Type{T}, size) = convert(T, rand(-size:size)) -generator{T<:FloatingPoint}(::Type{T}, size) = convert(T, (rand()-0.5).*size) +generator{T<:AbstractFloat}(::Type{T}, size) = convert(T, (rand()-0.5).*size) # This won't generate interesting UTF-8, but doing that is a Hard Problem generator{T<:String}(::Type{T}, size) = convert(T, randstring(size)) From d6003fece7e638944eb5cfebe935bb6e3429fb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20F=20Schrauf?= Date: Tue, 27 Dec 2016 10:40:17 -0300 Subject: [PATCH 2/3] Update index.rst --- doc/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/index.rst b/doc/index.rst index a41c5d6..955df8f 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -54,7 +54,7 @@ Methods Test the property ``prop``, with argument tpyes ``typs``, running ``ntests`` tests, and using the argument generators arggens. Each argument generator must be a function in a single positive integer which returns an item of the appropriate type which has "size" of the integer. This integer is used to scale the tests. This is a more efficient and flexible approach than conditional properties, but is sometimes harder to express:: - julia> quantproperty((x::Int, y::Int)->(x/y)>=floor(x/y), 100, (size)->QuickCheck.generator(Int,size), (size)->randbool() ? rand(1:size) : rand(-size:1)) + julia> quantproperty((x::Int, y::Int)->(x/y)>=floor(x/y), 100, (size)->QuickCheck.generator(Int,size), (size)->rand(Bool) ? rand(1:size) : rand(-size:1)) OK, passed 100 tests. ---------- From b4dd0a65556f550b99d7183a4e9f1b28728629e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20F=20Schrauf?= Date: Tue, 27 Dec 2016 13:47:11 -0300 Subject: [PATCH 3/3] corrected misspeling --- src/QuickCheck.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QuickCheck.jl b/src/QuickCheck.jl index 6ec22a4..a6b799c 100644 --- a/src/QuickCheck.jl +++ b/src/QuickCheck.jl @@ -16,7 +16,7 @@ function lambda_arg_types(f::Function) # [eval(var.args[2]) for var in Base.uncompressed_ast(f.code).args[1]] c = methods(f).ms if length(c) != 1 - error("The function must have one, and only one mehtod.") + error("The function must have one, and only one method.") end [c[1].sig.parameters[2:end]...] end