This instance will be upgraded to Heptapod 0.17.0 on 2020-11-26 at 14:00 UTC+1 (a few minutes of down time)

Commit 3723dbff authored by Jesse McGrew's avatar Jesse McGrew

Change ZilForm.ExactlyEquals so that two empty FORMs are considered ==?.

(h/t Roman Bartke) [ZILF-206]
parent e75185f66895
......@@ -264,15 +264,16 @@ namespace Zilf.Interpreter.Values
public override bool ExactlyEquals(ZilObject? other)
{
if (ReferenceEquals(this, other))
return true;
if (other == null)
return false;
return ((IsLVAL(out var myAtom) && other.IsLVAL(out var theirAtom)) ||
(IsGVAL(out myAtom) && other.IsGVAL(out theirAtom))) &&
myAtom == theirAtom;
if ((IsLVAL(out var myAtom) && other.IsLVAL(out var theirAtom)) ||
(IsGVAL(out myAtom) && other.IsGVAL(out theirAtom)))
{
return myAtom == theirAtom;
}
return base.ExactlyEquals(other);
}
public override int GetHashCode()
......
......@@ -32,6 +32,15 @@ namespace Zilf.Tests.Interpreter
[TestClass, TestCategory("Interpreter")]
public class StructureTests
{
[TestMethod]
public void TestComparisonOfEmptyFORM()
{
var ctx = new Context();
TestHelpers.EvalAndAssert(ctx, "<==? <FORM> '<>>", ctx.TRUE);
TestHelpers.EvalAndAssert(ctx, "<==? '() '<>>", ctx.FALSE);
TestHelpers.EvalAndAssert(ctx, "<==? '<> '()>", ctx.FALSE);
}
[TestMethod]
public void TestMEMQ()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment