We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
@mlj_model
1 parent 11e3f0f commit ba7bf24Copy full SHA for ba7bf24
test/model_def.jl
@@ -151,3 +151,26 @@ end
151
@test Cc().a === nothing
152
@test Cd().a === missing
153
end
154
+
155
+@testset "Expression defaults" begin
156
+ # Should work with and without constraint:
157
+ @mlj_model mutable struct Foo1
158
+ a::Vector{Int} = [1, 2, 3]
159
+ end
160
+ Foo1().a == [1, 2, 3]
161
+ @mlj_model mutable struct Foo2
162
+ a::Vector{Int} = [1, 2, 3]::(true)
163
164
+ Foo2().a == [1, 2, 3]
165
166
+ # Negative number:
167
+ @mlj_model mutable struct Foo3
168
+ a::Float64 = -1.0
169
170
+ Foo3().a === -1.0
171
+ @mlj_model mutable struct Foo4
172
+ a::Float64 = (-1.0)::(true)
173
174
+ Foo4().a == -1.0
175
176
+end
0 commit comments