Skip to content

Commit 499812a

Browse files
Fix some leaky test conflicts (#2223)
1 parent 7eb0abb commit 499812a

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

test/MatrixFields/field_names.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ import ClimaCore.MatrixFields: @name, is_subset_that_covers_set
55

66
include("matrix_field_test_utils.jl")
77

8-
struct Foo{T}
8+
struct FooFieldName{T}
99
_value::T
1010
end
11-
Base.propertynames(::Foo) = (:value,)
12-
Base.getproperty(foo::Foo, s::Symbol) =
11+
Base.propertynames(::FooFieldName) = (:value,)
12+
Base.getproperty(foo::FooFieldName, s::Symbol) =
1313
s == :value ? getfield(foo, :_value) : error("Invalid property name")
14-
Base.convert(::Type{Foo{T}}, foo::Foo) where {T} = Foo{T}(foo.value)
15-
Base.zero(::Type{Foo{T}}) where {T} = Foo(zero(T))
14+
Base.convert(::Type{FooFieldName{T}}, foo::FooFieldName) where {T} =
15+
FooFieldName{T}(foo.value)
16+
Base.zero(::Type{FooFieldName{T}}) where {T} = FooFieldName(zero(T))
1617

17-
const x = (; foo = Foo(0), a = (; b = 1, c = ((; d = 2), (;), (3, ()))))
18+
get_x() =
19+
(; foo = FooFieldName(0), a = (; b = 1, c = ((; d = 2), (;), (3, ()))))
1820

1921
@testset "FieldName Unit Tests" begin
22+
x = get_x()
2023
@test_all @name() == MatrixFields.FieldName()
2124
@test_all @name(a.c.:(1).d) == MatrixFields.FieldName(:a, :c, 1, :d)
2225
@test_all @name(a.c.:(3).:(1)) == MatrixFields.FieldName(:a, :c, 3, 1)
@@ -81,6 +84,7 @@ const x = (; foo = Foo(0), a = (; b = 1, c = ((; d = 2), (;), (3, ()))))
8184
end
8285

8386
@testset "FieldNameTree Unit Tests" begin
87+
x = get_x()
8488
name_tree = MatrixFields.FieldNameTree(x)
8589

8690
@test_all MatrixFields.FieldNameTree(x) == name_tree
@@ -110,6 +114,7 @@ end
110114
end
111115

112116
@testset "FieldNameSet Unit Tests" begin
117+
x = get_x()
113118
name_tree = MatrixFields.FieldNameTree(x)
114119

115120
vector_keys(names...) = MatrixFields.FieldVectorKeys(names, name_tree)
@@ -706,6 +711,7 @@ end
706711
end
707712

708713
@testset "FieldNameDict Unit Tests" begin
714+
x = get_x()
709715
FT = Float64
710716
x_FT = convert(replace_basetype(Int, FT, typeof(x)), x)
711717

test/Spaces/unit_dss.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function get_space_cs(::Type{FT}; context, R = 300.0) where {FT}
3434
return space
3535
end
3636

37-
function one_to_n(a::AbstractArray)
37+
function one_to_n_dss(a::AbstractArray)
3838
_a = Array(a)
3939
Random.seed!(1234)
4040
for i in 1:length(_a)
@@ -44,7 +44,7 @@ function one_to_n(a::AbstractArray)
4444
end
4545

4646
function test_dss_count(f::Fields.Field, buff::Topologies.DSSBuffer, nc)
47-
parent(f) .= one_to_n(parent(f))
47+
parent(f) .= one_to_n_dss(parent(f))
4848
@test allunique(parent(f))
4949
cf = copy(f)
5050
Spaces.weighted_dss!(f => buff)

0 commit comments

Comments
 (0)