mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-19 01:48:47 +00:00
Merge pull request #81 from JuliaFEM/fix_80
Fix FactCheck dependencies (issue #80)
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
# This file is a part of JuliaFEM.
|
||||
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
||||
|
||||
using ForwardDiff
|
||||
|
||||
"""
|
||||
|
||||
+17
-26
@@ -8,7 +8,6 @@ function run_tests(; verbose=true)
|
||||
maybe_test_files = readdir(Pkg.dir("JuliaFEM")*"/test")
|
||||
is_test_file(fn) = startswith(fn, "test_") & endswith(fn, ".jl")
|
||||
test_files = filter(is_test_file, maybe_test_files)
|
||||
#test_files = ["test_nodal_constraints.jl"]
|
||||
|
||||
verbose && info("Test files:")
|
||||
for (i, test_file) in enumerate(test_files)
|
||||
@@ -33,7 +32,8 @@ end
|
||||
run_tests()
|
||||
|
||||
#=
|
||||
facts("Testing if somebody used print, println(), @sprint in src directory") do
|
||||
|
||||
@testset "Testing if somebody used print, println(), @sprint in src directory" begin
|
||||
# TODO: make better reqular expression. Currently it will match all print words
|
||||
lines_with_print = Dict()
|
||||
src_dir = joinpath(Pkg.dir("JuliaFEM"),"src")
|
||||
@@ -47,10 +47,10 @@ facts("Testing if somebody used print, println(), @sprint in src directory") do
|
||||
end
|
||||
close(fil)
|
||||
end
|
||||
@fact lines_with_print => isempty "Instead of println() use Logging.jl package"
|
||||
@test length(lines_with_print) == 0
|
||||
end
|
||||
|
||||
facts("Testing if we have non ascii characters in the src files") do
|
||||
@testset "Testing if we have non ascii characters in the src files" begin
|
||||
# TODO: we should allow Greeck letters in documentation. Thus this test should skip docstrings
|
||||
lines_with_non_ascii = []
|
||||
src_dir = joinpath(Pkg.dir("JuliaFEM"),"src")
|
||||
@@ -64,10 +64,12 @@ facts("Testing if we have non ascii characters in the src files") do
|
||||
end
|
||||
close(fil)
|
||||
end
|
||||
@fact lines_with_non_ascii => isempty "non ascii charecters found in src -> test is failing"
|
||||
@test length(lines_with_non_ascii) == 0 # non ascii charecters found in src -> test is failing
|
||||
end
|
||||
|
||||
facts("Looking the [src,test] folders *.jl files header information") do
|
||||
=#
|
||||
|
||||
@testset "Looking the [src,test] folders *.jl files header information" begin
|
||||
files_no_license = []
|
||||
pkg_dir = Pkg.dir("JuliaFEM")
|
||||
dirs = ["test";"src"]
|
||||
@@ -75,7 +77,7 @@ facts("Looking the [src,test] folders *.jl files header information") do
|
||||
for file_name in readdir(joinpath(pkg_dir,folder))
|
||||
if file_name[end-2:end] == ".jl"
|
||||
fil = open(joinpath(pkg_dir,folder,file_name),"r")
|
||||
head = readall(fil)
|
||||
head = readstring(fil)
|
||||
else
|
||||
continue
|
||||
end
|
||||
@@ -97,26 +99,15 @@ facts("Looking the [src,test] folders *.jl files header information") do
|
||||
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
||||
|
||||
"""
|
||||
@fact files_no_license => isempty out_str
|
||||
end
|
||||
|
||||
#=
|
||||
test_files = readdir(Pkg.dir("JuliaFEM")*"/test")
|
||||
for test_file in test_files
|
||||
Logging.info("checking is $test_file is real test file")
|
||||
if (startswith(test_file, "test_")) & (endswith(test_file, ".jl"))
|
||||
Logging.info("Running tests from file $test_file")
|
||||
include(test_file)
|
||||
if length(files_no_license) != 0
|
||||
info(out_str)
|
||||
end
|
||||
|
||||
for line in files_no_license
|
||||
info(line)
|
||||
end
|
||||
|
||||
@test length(files_no_license) == 0
|
||||
end
|
||||
=#
|
||||
|
||||
# Keep this at the end of this file (include statements above this)
|
||||
@Logging.configure(level=DEBUG)
|
||||
@debug("Let's print the summary of the tests")
|
||||
for dic in FactCheck.getstats()
|
||||
@debug(dic[1], ": ",dic[2])
|
||||
end
|
||||
=#
|
||||
|
||||
|
||||
|
||||
@@ -4,68 +4,3 @@
|
||||
using JuliaFEM
|
||||
using JuliaFEM.Testing
|
||||
|
||||
#= TODO: Fix test
|
||||
|
||||
facts("test interpolation of fields") do
|
||||
|
||||
# interpolation of field in spatial domain
|
||||
N = Basis((xi) -> [0.5*(1.0-xi[1]), 0.5*(1.0+xi[1])])
|
||||
u = Field(0.0, [0.0, 1.0])
|
||||
@fact interpolate(N, u, [0.0]) --> 0.5
|
||||
|
||||
# interpolation of fieldset in time domain
|
||||
u1 = Field(0.0, [0.0, 1.0])
|
||||
u2 = Field(1.0, [1.0, 2.0])
|
||||
u = FieldSet("displacement", [u1, u2])
|
||||
@fact interpolate(u, 0.5).values --> [0.5, 1.5]
|
||||
@fact interpolate(u, 0.5).time --> 0.5
|
||||
|
||||
# interpolation of fieldset is defined for every time value:
|
||||
u1 = Field(0.0, [0.0, 0.0])
|
||||
u2 = Field(1.0, [1.0, 2.0])
|
||||
u3 = Field(2.0, [0.5, 1.5])
|
||||
u = FieldSet("displacement", [u1, u2, u3])
|
||||
@fact interpolate(u, -1.0).values --> [0.0, 0.0] # "out of range -" -> first known value
|
||||
@fact interpolate(u, 0.0).values --> [0.0, 0.0]
|
||||
@fact interpolate(u, 1.0).values --> [1.0, 2.0]
|
||||
@fact interpolate(u, 2.0).values --> [0.5, 1.5]
|
||||
@fact interpolate(u, 3.0).values --> [0.5, 1.5] # "out of range +" -> last known value
|
||||
@fact interpolate(u, 0.5).values --> [0.5, 1.0]
|
||||
@fact interpolate(u, 1.5).values --> [0.75, 1.75]
|
||||
# use Inf to get very first or last value of field
|
||||
@fact interpolate(u, -Inf).values --> [0.0, 0.0]
|
||||
@fact interpolate(u, +Inf).values --> [0.5, 1.5]
|
||||
|
||||
# multidimensional interpolation with and without derivatives
|
||||
h(xi) = [
|
||||
(1-xi[1])*(1-xi[2])/4
|
||||
(1+xi[1])*(1-xi[2])/4
|
||||
(1+xi[1])*(1+xi[2])/4
|
||||
(1-xi[1])*(1+xi[2])/4]
|
||||
dh(xi) = [
|
||||
-(1-xi[2])/4.0 -(1-xi[1])/4.0
|
||||
(1-xi[2])/4.0 -(1+xi[1])/4.0
|
||||
(1+xi[2])/4.0 (1+xi[1])/4.0
|
||||
-(1+xi[2])/4.0 (1-xi[1])/4.0]
|
||||
N = Basis(h, dh)
|
||||
|
||||
X = Field(0.0, Vector[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]])
|
||||
|
||||
# get midpoint of field in spatial domain
|
||||
@fact interpolate(N, X, [0.0, 0.0]) --> [0.5, 0.5]
|
||||
|
||||
# interpolate of scalar field -> scalar
|
||||
H = Field(0.0, 6.0)
|
||||
@fact interpolate(N, H, [0.0, 0.0]) --> 6.0
|
||||
|
||||
# multiplying scalar field with a vector -> vector
|
||||
# this is actually not so good idea...
|
||||
#h(xi) = [1/2*(1-xi[1]), 1/2*(1+xi[1])]
|
||||
#dh(xi) = [-1/2 1/2]'
|
||||
#N = Basis(h, dh)
|
||||
#f = Field(0.0, 100.0)
|
||||
#@fact interpolate(N, f, [0.0]) --> [50.0, 50.0]
|
||||
|
||||
end
|
||||
|
||||
=#
|
||||
|
||||
Reference in New Issue
Block a user