diff --git a/Upsilon/BaseTypes/Number/ScriptNumber.cs b/Upsilon/BaseTypes/Number/ScriptNumber.cs index 6a6400a..055c41a 100644 --- a/Upsilon/BaseTypes/Number/ScriptNumber.cs +++ b/Upsilon/BaseTypes/Number/ScriptNumber.cs @@ -102,6 +102,15 @@ namespace Upsilon.BaseTypes.Number { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; + if (IsFloat && obj is double d) + { + return Math.Abs(((ScriptNumberDouble) this).Value - d) < 0.0000001; + } + if (!IsFloat && obj is long l) + { + return ((ScriptNumberLong) this).Value == l; + } + if (obj.GetType() != this.GetType()) return false; return Equals((ScriptNumber) obj); } diff --git a/Upsilon/BaseTypes/ScriptBoolean.cs b/Upsilon/BaseTypes/ScriptBoolean.cs index 14388f0..36cee8c 100644 --- a/Upsilon/BaseTypes/ScriptBoolean.cs +++ b/Upsilon/BaseTypes/ScriptBoolean.cs @@ -49,6 +49,7 @@ namespace Upsilon.BaseTypes { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; + if (obj is bool b) return b == Value; if (obj.GetType() != this.GetType()) return false; return Equals((ScriptBoolean) obj); } diff --git a/Upsilon/BaseTypes/ScriptNull.cs b/Upsilon/BaseTypes/ScriptNull.cs index 37e8014..6ff4c43 100644 --- a/Upsilon/BaseTypes/ScriptNull.cs +++ b/Upsilon/BaseTypes/ScriptNull.cs @@ -26,7 +26,7 @@ namespace Upsilon.BaseTypes public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; + if (obj == null) return true; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; return Equals((ScriptNull) obj); diff --git a/Upsilon/BaseTypes/ScriptString.cs b/Upsilon/BaseTypes/ScriptString.cs index 8d0e9df..7a64777 100644 --- a/Upsilon/BaseTypes/ScriptString.cs +++ b/Upsilon/BaseTypes/ScriptString.cs @@ -29,6 +29,10 @@ namespace Upsilon.BaseTypes { if (obj == null) return false; + if (obj is string str) + { + return string.Equals(str, Value); + } if (!(obj is ScriptString s)) return false; return Equals(s); @@ -39,6 +43,11 @@ namespace Upsilon.BaseTypes return (Value != null ? Value.GetHashCode() : 0); } + public static implicit operator string(ScriptString s) + { + return s.Value; + } + private bool Equals(ScriptString s) { return s != null && string.Equals(s.Value, Value); diff --git a/Upsilon/BaseTypes/UserData/DictionaryUserData.cs b/Upsilon/BaseTypes/UserData/DictionaryUserData.cs index c7ec453..4b0a5f0 100644 --- a/Upsilon/BaseTypes/UserData/DictionaryUserData.cs +++ b/Upsilon/BaseTypes/UserData/DictionaryUserData.cs @@ -65,6 +65,10 @@ namespace Upsilon.BaseTypes.UserData { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() == Dictionary.GetType()) + { + return Dictionary.Equals(obj); + } if (obj.GetType() != this.GetType()) return false; return Equals((DictionaryUserData) obj); } diff --git a/Upsilon/BaseTypes/UserData/GenericUserData.cs b/Upsilon/BaseTypes/UserData/GenericUserData.cs index 7bea836..3a1fb96 100644 --- a/Upsilon/BaseTypes/UserData/GenericUserData.cs +++ b/Upsilon/BaseTypes/UserData/GenericUserData.cs @@ -65,6 +65,10 @@ namespace Upsilon.BaseTypes.UserData { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() == Value.GetType()) + { + return obj.Equals(Value); + } if (obj.GetType() != this.GetType()) return false; return Equals((GenericUserData) obj); } diff --git a/Upsilon/BaseTypes/UserData/ListUserData.cs b/Upsilon/BaseTypes/UserData/ListUserData.cs index 3db4bd5..cafcc59 100644 --- a/Upsilon/BaseTypes/UserData/ListUserData.cs +++ b/Upsilon/BaseTypes/UserData/ListUserData.cs @@ -81,6 +81,10 @@ namespace Upsilon.BaseTypes.UserData { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() == List.GetType()) + { + return List.Equals(obj); + } if (obj.GetType() != this.GetType()) return false; return Equals((ListUserData) obj); }