From 15b76b9a7c4e554edbab63aee8076b971cf5ff33 Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Tue, 19 Jun 2018 14:28:50 -0400 Subject: [PATCH] Use StrAPI instead of APITest to test api macro --- .travis.yml | 2 +- Manifest.toml | 18 ++++++++++++++++++ Project.toml | 4 ++++ test/APITest.jl | 18 ------------------ test/REQUIRE | 2 ++ test/runtests.jl | 23 +++++++++++------------ 6 files changed, 36 insertions(+), 31 deletions(-) delete mode 100644 test/APITest.jl create mode 100644 test/REQUIRE diff --git a/.travis.yml b/.travis.yml index 58ee122..fd225bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ matrix: ## uncomment the following lines to override the default test script script: - - julia -e 'if VERSION < v"0.7.0-DEV.5183"; Pkg.clone(pwd()); Pkg.test("ModuleInterfaceTools", coverage=true); else; using UUIDs; import Pkg; p = "Project.toml"; uuid = "5cb8414e-7aab-5a03-a681-351269c074bf"; write(p, replace(read(p, String), uuid => uuid4())); Pkg.instantiate(); push!(LOAD_PATH, "test"); Pkg.test(; coverage=true); end' + - julia -e 'if VERSION < v"0.7.0-DEV.5183"; Pkg.clone(pwd()); Pkg.test("ModuleInterfaceTools", coverage=true); else; using UUIDs; import Pkg; p = "Project.toml"; uuid = "5cb8414e-7aab-5a03-a681-351269c074bf"; write(p, replace(read(p, String), uuid => uuid4())); Pkg.instantiate(); Pkg.test(; coverage=true); end' after_success: # push coverage results to Coveralls - julia -e 'cd(Pkg.dir("ModuleInterfaceTools")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' diff --git a/Manifest.toml b/Manifest.toml index c35f115..b571d3a 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,5 +1,23 @@ +[[InteractiveUtils]] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[ModuleInterfaceTools]] +deps = ["InteractiveUtils", "Test"] +git-tree-sha1 = "cee1e40a47a60742a40287f3c1df6375e92e524c" +uuid = "5cb8414e-7aab-5a03-a681-351269c074bf" +version = "0.1.2" + [[Pkg]] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +[[Random]] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[StrAPI]] +deps = ["InteractiveUtils", "ModuleInterfaceTools", "Pkg", "Random"] +git-tree-sha1 = "b905011d68af46965c9e89594d7d217153a742e1" +uuid = "69e7dfc3-c4d0-5e14-8d95-d6042a05b383" +version = "0.1.2" + [[Test]] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/Project.toml b/Project.toml index 56d17cf..2aa79ed 100644 --- a/Project.toml +++ b/Project.toml @@ -9,3 +9,7 @@ version = "0.1.3" [deps] Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets.test.deps] +StrAPI = "69e7dfc3-c4d0-5e14-8d95-d6042a05b383" + diff --git a/test/APITest.jl b/test/APITest.jl deleted file mode 100644 index d8fdfa5..0000000 --- a/test/APITest.jl +++ /dev/null @@ -1,18 +0,0 @@ -module APITest -using ModuleInterfaceTools - -@api base nextind, getindex, setindex! - -@api public! myfunc - -@api public Foo - -struct Foo end - -function myfunc end -myfunc(::Integer) = 1 -myfunc(::String) = 2 - -@api freeze - -end # module APITest diff --git a/test/REQUIRE b/test/REQUIRE new file mode 100644 index 0000000..40c9950 --- /dev/null +++ b/test/REQUIRE @@ -0,0 +1,2 @@ +julia 0.6 +StrAPI diff --git a/test/runtests.jl b/test/runtests.jl index 0abc945..f580c3f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,11 +5,9 @@ using ModuleInterfaceTools @api test -@api path (@static V6_COMPAT ? joinpath(Pkg.dir("ModuleInterfaceTools"), "test") : @__DIR__) +@api extend StrAPI -@api extend APITest - -@api list APITest +@api list StrAPI @api def testcase begin myname = "Scott Paul Jones" @@ -20,17 +18,18 @@ end @test myname == "Scott Paul Jones" end -myfunc(::AbstractFloat) = 3 +codepoints(x::Integer) = 1 +codepoints(x::Float64) = 2 @testset "Function extension" begin - @test myfunc(1) == 1 - @test myfunc("foo") == 2 - @test myfunc(2.0) == 3 + @test typeof(codepoints("foo")) === CodePoints{String} + @test codepoints(1) == 1 + @test codepoints(2.0) == 2 end @testset "API lists" begin - @test APITest.__api__.mod == APITest - @test Set(APITest.__api__.base) == Set([:nextind, :getindex, :setindex!]) - @test Set(APITest.__api__.public) == Set([:Foo]) - @test Set(APITest.__api__.public!) == Set([:myfunc]) + @test StrAPI.__api__.mod == StrAPI + @test :split in Set(StrAPI.__api__.base) + @test :encoding in Set(StrAPI.__api__.public!) + @test :Direction in Set(StrAPI.__api__.public) end