diff --git a/modules/juce_core/containers/juce_Variant.cpp b/modules/juce_core/containers/juce_Variant.cpp index 9cec75aa5c..db3f2f5666 100644 --- a/modules/juce_core/containers/juce_Variant.cpp +++ b/modules/juce_core/containers/juce_Variant.cpp @@ -120,6 +120,9 @@ public: bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept override { + if (otherType.isDouble() || otherType.isInt64() || otherType.isString()) + return otherType.equals (otherData, data, *this); + return otherType.toInt (otherData) == data.intValue; } @@ -147,6 +150,9 @@ public: bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept override { + if (otherType.isDouble() || otherType.isString()) + return otherType.equals (otherData, data, *this); + return otherType.toInt64 (otherData) == data.int64Value; } diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 11d367926f..d2137de84a 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -2398,6 +2398,28 @@ public: expectEquals (toks.size(), 3); expectEquals (toks.joinIntoString ("-"), String ("x-'y,z'-")); } + + { + beginTest ("var"); + + var v1 = 0; + var v2 = 0.1; + var v3 = "0.1"; + var v4 = (int64) 0; + var v5 = 0.0; + expect (! v2.equals (v1)); + expect (! v1.equals (v2)); + expect (v2.equals (v3)); + expect (v3.equals (v2)); + expect (! v3.equals (v1)); + expect (! v1.equals (v3)); + expect (v1.equals (v4)); + expect (v4.equals (v1)); + expect (v5.equals (v4)); + expect (v4.equals (v5)); + expect (! v2.equals (v4)); + expect (! v4.equals (v2)); + } } };