Skip to content

Commit

Permalink
Fix Sum.Equals
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmatech committed Nov 4, 2014
1 parent 6d88e40 commit 289c8ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Symbolism/Symbolism.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,11 @@ public override int GetHashCode()
{ return elts.GetHashCode(); }

public override bool Equals(object obj)
{ return ListUtils.equal(elts, ((Sum)obj).elts); }
{
if (obj is Sum) return ListUtils.equal(elts, ((Sum)obj).elts);

return false;
}
//////////////////////////////////////////////////////////////////////

static List<MathObject> MergeSums(List<MathObject> pElts, List<MathObject> qElts)
Expand Down
8 changes: 7 additions & 1 deletion Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static void Main(string[] args)
var x = new Symbol("x");
var y = new Symbol("y");
var z = new Symbol("z");

Func<int, Integer> Int = (n) => new Integer(n);

AssertIsTrue(x + x == 2 * x);
Expand Down Expand Up @@ -187,6 +187,12 @@ static void Main(string[] args)

// Console.WriteLine((x + x + x + x) / x);

#region Sum

Assert((x + y).Equals(x * y) == false, "(x + y).Equals(x * y)");

#endregion

#region FreeOf

var a = new Symbol("a");
Expand Down

0 comments on commit 289c8ac

Please sign in to comment.