How to compare two types of Julia for unit testing?

e.g. I have my type

type Foo
  version::String
  id::String
  samplingRate::Int
  timeBuilt::String
  equations::Vector{Equation}
  exam::Vector{Exam}
end

Please clarify: do you want to compare types (eg typeof(something)) or their values? In the latter case, you should probably define Base.== (or something equivalent if it generally does not make sense and you just need it for unit testing), look at

Their all values. Can you give a simple example @Tamas_Papp , please?

I think that that package is well-documented, but

using AutoHashEquals

@auto_hash_equals immutable Foo
    a
    b
end

Foo(1,2) == Foo(1,2) # true
1 Like

Thanks very much :slight_smile: now it’s clear and simple or all types must be with @auto_hash_equals (e.g. type equations, Exam …) What with this types?

For types, you can use is (which can be typed as ), but most of the time you don’t need to do this; when I unit test for types I end up using Base.Test.@inferred most of the time.

is is going/has gone away; in the future === is the canonical name for this function. However testing the type should be done with :: type assertions, not with typeof.