From 85cb9e5d87d6977195bd5ccda1c9d5f8dd630e10 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 2 Oct 2019 07:59:49 -0400 Subject: [PATCH] add ForwardDiff dependency and setup safetestsets --- Project.toml | 7 ++++++- src/MyExample.jl | 4 +++- src/extra_file.jl | 1 + test/my_f_tests.jl | 13 +++++++++++++ test/runtests.jl | 11 ++--------- 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 test/my_f_tests.jl diff --git a/Project.toml b/Project.toml index ed5582d..fc96965 100644 --- a/Project.toml +++ b/Project.toml @@ -3,11 +3,16 @@ uuid = "be72d800-e507-11e9-3551-81be3d289e2a" authors = ["Chris Rackauckas"] version = "0.1.0" +[deps] +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + [compat] +ForwardDiff = "0.10" julia = "1" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" [targets] -test = ["Test"] +test = ["Test","SafeTestsets"] diff --git a/src/MyExample.jl b/src/MyExample.jl index 2f7fbaa..ee47da6 100644 --- a/src/MyExample.jl +++ b/src/MyExample.jl @@ -1,9 +1,11 @@ module MyExample +using ForwardDiff + greet() = print("Hello World!") include("extra_file.jl") -export my_f +export my_f, derivative_of_my_f end # module diff --git a/src/extra_file.jl b/src/extra_file.jl index e111656..e2b309c 100644 --- a/src/extra_file.jl +++ b/src/extra_file.jl @@ -1 +1,2 @@ my_f(x,y) = 2x+3y +derivative_of_my_f(x,y) = ForwardDiff.derivative(x->my_f(x,y),x) diff --git a/test/my_f_tests.jl b/test/my_f_tests.jl new file mode 100644 index 0000000..2d59d1d --- /dev/null +++ b/test/my_f_tests.jl @@ -0,0 +1,13 @@ +using MyExample +using Test + +@testset "MyExample.jl" begin + # 2x + 3y + @test my_f(2,1) == 7 + @test my_f(2,3) == 13 + @test my_f(1,3) == 11 +end + +@testset "Derivative Tests" begin + @test derivative_of_my_f(2,1) == 2 +end diff --git a/test/runtests.jl b/test/runtests.jl index d6972ed..dc9f615 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,9 +1,2 @@ -using MyExample -using Test - -@testset "MyExample.jl" begin - # 2x + 3y - @test my_f(2,1) == 7 - @test my_f(2,3) == 13 - @test my_f(1,3) == 11 -end +using SafeTestsets +@safetestset "My f tests" begin include("my_f_tests.jl") end