-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug in dictextension code and tested it
- Loading branch information
Showing
5 changed files
with
66 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using FieldProperties: set_dictextension_property! | ||
|
||
@testset "dictextension" begin | ||
@test set_dictextension_property!(m, :testprop, 1) | ||
@test set_dictextension_property!(MultiNest(Nested1(1,2),Nested2(3,4)), :testprop, 1) == false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,21 @@ | ||
|
||
@testset "nest properties" begin | ||
mutable struct Nested1 | ||
field1 | ||
field2 | ||
mn = MultiNest(Nested1(1,2), Nested2(3,4)) | ||
|
||
@test @inferred(FieldProperties.has_dictextension(mn)) == false | ||
@test @inferred(FieldProperties.has_nested_fields(mn)) == true | ||
@test @inferred(FieldProperties.nested_fields(mn)) == (:field1, :field2) | ||
@test @inferred(FieldProperties.assigned_fields(mn)) == () | ||
# we can't infer nested property names unless they are inferreable (which for some reason | ||
# they aren't for Nested1 and 2 | ||
@test propertynames(mn) == (:field1, :field2, :field3, :field4) | ||
|
||
@test mn.field1 == 1 | ||
@test mn.field2 == 2 | ||
@test mn.field3 == 3 | ||
@test mn.field4 == 4 | ||
|
||
mn.field1 = 2 | ||
@test mn.field1 == 2 | ||
end | ||
|
||
mutable struct Nested2 | ||
field3 | ||
field4 | ||
end | ||
|
||
struct MultiNest{F1,F2} | ||
field1::F1 | ||
field2::F2 | ||
end | ||
|
||
@assignprops( | ||
MultiNest, | ||
:field1 => nested, | ||
:field2 => nested | ||
) | ||
|
||
mn = MultiNest(Nested1(1,2), Nested2(3,4)) | ||
|
||
@test @inferred(FieldProperties.has_dictextension(mn)) == false | ||
@test @inferred(FieldProperties.has_nested_fields(mn)) == true | ||
@test @inferred(FieldProperties.nested_fields(mn)) == (:field1, :field2) | ||
@test @inferred(FieldProperties.assigned_fields(mn)) == () | ||
# we can't infer nested property names unless they are inferreable (which for some reason | ||
# they aren't for Nested1 and 2 | ||
@test propertynames(mn) == (:field1, :field2, :field3, :field4) | ||
|
||
@test mn.field1 == 1 | ||
@test mn.field2 == 2 | ||
@test mn.field3 == 3 | ||
@test mn.field4 == 4 | ||
|
||
mn.field1 = 2 | ||
@test mn.field1 == 2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters