diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_BinaryExpression.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_BinaryExpression.cs
new file mode 100644
index 000000000..8f1548a4b
--- /dev/null
+++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_BinaryExpression.cs
@@ -0,0 +1,25 @@
+using Neo.SmartContract.Framework;
+using Neo.SmartContract.Framework.Services;
+using System.Numerics;
+
+namespace Neo.Compiler.CSharp.TestContracts
+{
+ public class Contract_BinaryExpression : SmartContract.Framework.SmartContract
+ {
+ public static void BinaryIs()
+ {
+ ByteString a = "a";
+ ExecutionEngine.Assert(a is ByteString);
+ string b = $"";
+#pragma warning disable CS0184
+ ExecutionEngine.Assert(b is ByteString);
+#pragma warning restore CS0184
+ }
+
+ public static void BinaryAs()
+ {
+ UInt160 a = UInt160.Zero;
+ ExecutionEngine.Assert(a as ByteString == UInt160.Zero);
+ }
+ }
+}
diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_ComplexAssign.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_ComplexAssign.cs
index a2dd4eb70..866d0e179 100644
--- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_ComplexAssign.cs
+++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_ComplexAssign.cs
@@ -1,3 +1,4 @@
+using Neo.SmartContract.Framework;
using System;
using System.ComponentModel;
@@ -124,5 +125,20 @@ public static (uint, int) UnitTest_Right_Shift_Assign_UnChecked()
}
return (value1, value2);
}
+
+ public class TestClass
+ {
+ public byte Property = 7;
+ public byte[] ArrayProperty = [0, 1, 2, 3];
+ }
+
+ public static void UnitTest_Member_Element_Complex_Assign()
+ {
+ TestClass t = new();
+ t.Property %= 3;
+ ExecutionEngine.Assert(t.Property == 1);
+ t.ArrayProperty[3] &= 4;
+ ExecutionEngine.Assert(t.ArrayProperty[0] == 0);
+ }
}
}
diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_NULL.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_NULL.cs
index 50e6812e9..f9cc8654b 100644
--- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_NULL.cs
+++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_NULL.cs
@@ -96,6 +96,8 @@ public void VoidMethod()
{
}
public int IntProperty => 42;
+ public byte? NullableProperty;
+ public byte?[]? NullableArray { get; set; }
}
public static void NullType()
@@ -103,5 +105,22 @@ public static void NullType()
TestClass? obj1 = null;
obj1?.VoidMethod();
}
+
+ public static void NullCoalescingAssignment()
+ {
+ TestClass t = new() { NullableProperty = 1 };
+ ExecutionEngine.Assert(t.NullableProperty == 1);
+ t.NullableProperty = null;
+ ExecutionEngine.Assert(t.NullableArray == null);
+ t.NullableArray ??= [0, null, 2, 3, t.NullableProperty];
+ t.NullableProperty ??= t.NullableArray[0];
+ ExecutionEngine.Assert(t.NullableProperty == 0);
+ t.NullableProperty ??= t.NullableArray[1];
+ ExecutionEngine.Assert(t.NullableProperty == 0);
+ t.NullableArray[1] ??= 1;
+ ExecutionEngine.Assert(t.NullableArray[1] == 1);
+ t.NullableArray[1] ??= 2;
+ ExecutionEngine.Assert(t.NullableArray[1] == 1);
+ }
}
}
diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_PostfixUnary.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_PostfixUnary.cs
index d67d700f5..49e263e6a 100644
--- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_PostfixUnary.cs
+++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_PostfixUnary.cs
@@ -1,3 +1,5 @@
+using Microsoft.ApplicationInsights.DataContracts;
+using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Native;
using Neo.SmartContract.Framework.Services;
using System;
@@ -13,7 +15,7 @@ public class Person
public int Age;
- public int[] BWH = { 80, 60, 80 };
+ public int[] BWH { get; set; } = { 80, 60, 80 };
public Person(string name) { Name = name; }
}
@@ -33,5 +35,26 @@ public class Person
}
public static bool IsValid(Person? person) => person is not null && person.Name is not null;
+
+ public static void TestUndefinedCase()
+ {
+ Person p = new("Undefined");
+ ExecutionEngine.Assert(p.Age == 0);
+ p.Age = p.Age++; // This is undefined; typically should be just p.Age++
+ ExecutionEngine.Assert(p.Age == 0);
+ p.Age = ++p.Age;
+ ExecutionEngine.Assert(p.Age == 1);
+
+ ExecutionEngine.Assert(p.BWH[0] == 80);
+ p.BWH[0] = p.BWH[0]++;
+ ExecutionEngine.Assert(p.BWH[0] == 80);
+ p.BWH[0] = ++p.BWH[0];
+ ExecutionEngine.Assert(p.BWH[0] == 81);
+ }
+
+ public static void TestInvert()
+ {
+ ExecutionEngine.Assert(~1 == -2);
+ }
}
}
diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Tuple.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Tuple.cs
index 33cf8c20b..d25ddb5bb 100644
--- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Tuple.cs
+++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Tuple.cs
@@ -34,6 +34,7 @@ public static object T1()
state.data = new StructB();
BigInteger index = 0;
(state.amount, state.data.height, _, index) = GetResult();
+ _ = GetResult();
state.index = index;
return state;
}
diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Neo.Compiler.CSharp.TestContracts.csproj b/tests/Neo.Compiler.CSharp.TestContracts/Neo.Compiler.CSharp.TestContracts.csproj
index 139eb2664..2fc665198 100644
--- a/tests/Neo.Compiler.CSharp.TestContracts/Neo.Compiler.CSharp.TestContracts.csproj
+++ b/tests/Neo.Compiler.CSharp.TestContracts/Neo.Compiler.CSharp.TestContracts.csproj
@@ -14,8 +14,7 @@
-
+
diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_BinaryExpression.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_BinaryExpression.cs
new file mode 100644
index 000000000..cb0ad2674
--- /dev/null
+++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_BinaryExpression.cs
@@ -0,0 +1,68 @@
+using Neo.Cryptography.ECC;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Numerics;
+
+namespace Neo.SmartContract.Testing;
+
+public abstract class Contract_BinaryExpression(Neo.SmartContract.Testing.SmartContractInitialize initialize) : Neo.SmartContract.Testing.SmartContract(initialize), IContractInfo
+{
+ #region Compiled data
+
+ public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_BinaryExpression"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""binaryIs"",""parameters"":[],""returntype"":""Void"",""offset"":0,""safe"":false},{""name"":""binaryAs"",""parameters"":[],""returntype"":""Void"",""offset"":19,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}");
+
+ ///
+ /// Optimization: "All"
+ ///
+ public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE5XAgAMAWFwaNkoOQwAcWnZKDlAVwEADBQAAAAAAAAAAAAAAAAAAAAAAAAAAHBoStkoJARFCwwUAAAAAAAAAAAAAAAAAAAAAAAAAACXOUBlVuZG"));
+
+ #endregion
+
+ #region Unsafe methods
+
+ ///
+ /// Unsafe method
+ ///
+ ///
+ /// Script: VwEADBQAAAAAAAAAAAAAAAAAAAAAAAAAAHBoStkoJARFCwwUAAAAAAAAAAAAAAAAAAAAAAAAAACXOUA=
+ /// INITSLOT 0100 [64 datoshi]
+ /// PUSHDATA1 0000000000000000000000000000000000000000 [8 datoshi]
+ /// STLOC0 [2 datoshi]
+ /// LDLOC0 [2 datoshi]
+ /// DUP [2 datoshi]
+ /// ISTYPE 28 'ByteString' [2 datoshi]
+ /// JMPIF 04 [2 datoshi]
+ /// DROP [2 datoshi]
+ /// PUSHNULL [1 datoshi]
+ /// PUSHDATA1 0000000000000000000000000000000000000000 [8 datoshi]
+ /// EQUAL [32 datoshi]
+ /// ASSERT [1 datoshi]
+ /// RET [0 datoshi]
+ ///
+ [DisplayName("binaryAs")]
+ public abstract void BinaryAs();
+
+ ///
+ /// Unsafe method
+ ///
+ ///
+ /// Script: VwIADAFhcGjZKDkMAHFp2Sg5QA==
+ /// INITSLOT 0200 [64 datoshi]
+ /// PUSHDATA1 61 'a' [8 datoshi]
+ /// STLOC0 [2 datoshi]
+ /// LDLOC0 [2 datoshi]
+ /// ISTYPE 28 'ByteString' [2 datoshi]
+ /// ASSERT [1 datoshi]
+ /// PUSHDATA1 [8 datoshi]
+ /// STLOC1 [2 datoshi]
+ /// LDLOC1 [2 datoshi]
+ /// ISTYPE 28 'ByteString' [2 datoshi]
+ /// ASSERT [1 datoshi]
+ /// RET [0 datoshi]
+ ///
+ [DisplayName("binaryIs")]
+ public abstract void BinaryIs();
+
+ #endregion
+}
diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_ComplexAssign.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_ComplexAssign.cs
index 788947af3..3be08bf33 100644
--- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_ComplexAssign.cs
+++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_ComplexAssign.cs
@@ -10,12 +10,12 @@ public abstract class Contract_ComplexAssign(Neo.SmartContract.Testing.SmartCont
{
#region Compiled data
- public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_ComplexAssign"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""unitTest_Add_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":0,""safe"":false},{""name"":""unitTest_Add_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":68,""safe"":false},{""name"":""unitTest_Sub_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":174,""safe"":false},{""name"":""unitTest_Sub_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":234,""safe"":false},{""name"":""unitTest_Mul_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":332,""safe"":false},{""name"":""unitTest_Mul_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":400,""safe"":false},{""name"":""unitTest_Left_Shift_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":506,""safe"":false},{""name"":""unitTest_Left_Shift_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":574,""safe"":false},{""name"":""unitTest_Right_Shift_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":680,""safe"":false},{""name"":""unitTest_Right_Shift_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":740,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}");
+ public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_ComplexAssign"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""unitTest_Add_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":0,""safe"":false},{""name"":""unitTest_Add_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":68,""safe"":false},{""name"":""unitTest_Sub_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":174,""safe"":false},{""name"":""unitTest_Sub_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":234,""safe"":false},{""name"":""unitTest_Mul_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":332,""safe"":false},{""name"":""unitTest_Mul_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":400,""safe"":false},{""name"":""unitTest_Left_Shift_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":506,""safe"":false},{""name"":""unitTest_Left_Shift_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":574,""safe"":false},{""name"":""unitTest_Right_Shift_Assign_Checked"",""parameters"":[],""returntype"":""Array"",""offset"":680,""safe"":false},{""name"":""unitTest_Right_Shift_Assign_UnChecked"",""parameters"":[],""returntype"":""Array"",""offset"":740,""safe"":false},{""name"":""unitTest_Member_Element_Complex_Assign"",""parameters"":[],""returntype"":""Void"",""offset"":838,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}");
///
/// Optimization: "All"
///
- public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP1GA1cCAAP/////AAAAAHAC////f3FoEZ5KEC4DOkoD/////wAAAAAyAzpwaRGeSgIAAACALgM6SgL///9/MgM6cWloEr9AVwIAA/////8AAAAAcAL///9/cWgRnkoQLgQiDkoD/////wAAAAAyDAP/////AAAAAJFwaRGeSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn3FpaBK/QFcCABBwAgAAAIBxaBGfShAuAzpKA/////8AAAAAMgM6cGkRn0oCAAAAgC4DOkoC////fzIDOnFpaBK/QFcCABBwAgAAAIBxaBGfShAuBCIOSgP/////AAAAADIMA/////8AAAAAkXBpEZ9KAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcWloEr9AVwIAA/////8AAAAAcAL///9/cWgSoEoQLgM6SgP/////AAAAADIDOnBpEqBKAgAAAIAuAzpKAv///38yAzpxaWgSv0BXAgAD/////wAAAABwAv///39xaBKgShAuBCIOSgP/////AAAAADIMA/////8AAAAAkXBpEqBKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcWloEr9AVwIAA/////8AAAAAcAL///9/cWgRqEoQLgM6SgP/////AAAAADIDOnBpEahKAgAAAIAuAzpKAv///38yAzpxaWgSv0BXAgAD/////wAAAABwAv///39xaBGoShAuBCIOSgP/////AAAAADIMA/////8AAAAAkXBpEahKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcWloEr9AVwIAEHACAAAAgHFoEalKEC4DOkoD/////wAAAAAyAzpwaRGpSgIAAACALgM6SgL///9/MgM6cWloEr9AVwIAEHACAAAAgHFoEalKEC4EIg5KA/////8AAAAAMgwD/////wAAAACRcGkRqUoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9xaWgSv0Cow2c0"));
+ public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP2dA1cCAAP/////AAAAAHAC////f3FoEZ5KEC4DOkoD/////wAAAAAyAzpwaRGeSgIAAACALgM6SgL///9/MgM6cWloEr9AVwIAA/////8AAAAAcAL///9/cWgRnkoQLgQiDkoD/////wAAAAAyDAP/////AAAAAJFwaRGeSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn3FpaBK/QFcCABBwAgAAAIBxaBGfShAuAzpKA/////8AAAAAMgM6cGkRn0oCAAAAgC4DOkoC////fzIDOnFpaBK/QFcCABBwAgAAAIBxaBGfShAuBCIOSgP/////AAAAADIMA/////8AAAAAkXBpEZ9KAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcWloEr9AVwIAA/////8AAAAAcAL///9/cWgSoEoQLgM6SgP/////AAAAADIDOnBpEqBKAgAAAIAuAzpKAv///38yAzpxaWgSv0BXAgAD/////wAAAABwAv///39xaBKgShAuBCIOSgP/////AAAAADIMA/////8AAAAAkXBpEqBKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcWloEr9AVwIAA/////8AAAAAcAL///9/cWgRqEoQLgM6SgP/////AAAAADIDOnBpEahKAgAAAIAuAzpKAv///38yAzpxaWgSv0BXAgAD/////wAAAABwAv///39xaBGoShAuBCIOSgP/////AAAAADIMA/////8AAAAAkXBpEahKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcWloEr9AVwIAEHACAAAAgHFoEalKEC4DOkoD/////wAAAAAyAzpwaRGpSgIAAACALgM6SgL///9/MgM6cWloEr9AVwIAEHACAAAAgHFoEalKEC4EIg5KA/////8AAAAAMgwD/////wAAAACRcGkRqUoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9xaWgSv0BXAQAMBAABAgPbMBcSwHBoShDOE6JKEC4EIghKAf8AMgYB/wCRThBQ0EVoEM4RlzloEc4TS0vOFJFKEC4EIghKAf8AMgYB/wCRSlRT0EVoEc4QzhCXOUCPzZu8"));
#endregion
@@ -207,6 +207,80 @@ public abstract class Contract_ComplexAssign(Neo.SmartContract.Testing.SmartCont
[DisplayName("unitTest_Left_Shift_Assign_UnChecked")]
public abstract IList