Try following EUnit test cases:
public class OperatorTest : Test
{
public void Test1()
{
var a = new TestClass();
Assert.IsFalse(a==a); // passed
Assert.IsTrue(a!=a); // passed
}
public void Test2()
{
var a = new TestClassMapped();
Assert.IsFalse(a==a); // failed
Assert.IsTrue(a!=a); // failed
}
}
public class TestClass : Foundation.NSString{
public static bool operator == (TestClass a, TestClass b) {
return false;
}
public static bool operator != (TestClass a, TestClass b) {
return true;
}
}
public __mapped class TestClassMapped => Foundation.NSString{
public static bool operator == (TestClassMapped a, TestClassMapped b) {
return false;
}
public static bool operator != (TestClassMapped a, TestClassMapped b) {
return true;
}
}
I thought maybe it’s something wrong in RO C# compiler, then I try to simplify String.pas codes in Sugar to see if there’s no problem in Oxygene:
interface
type
OxygeneClass = public class mapped to Foundation.NSString
public
class operator Equal(Value1, Value2: OxygeneClass): Boolean;
class operator NotEqual(Value1, Value2: OxygeneClass): Boolean;
end;
implementation
class operator OxygeneClass.Equal(Value1: OxygeneClass; Value2: OxygeneClass): Boolean;
begin
exit false;
end;
class operator OxygeneClass.NotEqual(Value1: OxygeneClass; Value2: OxygeneClass): Boolean;
begin
exit true;
end;
end.
Unfortunately Test3 also failed:
public void Test3()
{
var a = new OxygeneClass();
Assert.IsFalse(a==a); // Failed
Assert.IsTrue(a!=a); // Failed
}
Here’s my test project:
ElementTest.zip (124.7 KB)