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? UnitTest_Left_Shift_Assign_UnChecked(); + /// + /// Unsafe method + /// + /// + /// Script: VwEADAQAAQID2zAXEsBwaEoQzhOiShAuBCIISgH/ADIGAf8AkU4QUNBFaBDOEZc5aBHOE0tLzhSRShAuBCIISgH/ADIGAf8AkUpUU9BFaBHOEM4QlzlA + /// INITSLOT 0100 [64 datoshi] + /// PUSHDATA1 00010203 [8 datoshi] + /// CONVERT 30 'Buffer' [8192 datoshi] + /// PUSH7 [1 datoshi] + /// PUSH2 [1 datoshi] + /// PACK [2048 datoshi] + /// STLOC0 [2 datoshi] + /// LDLOC0 [2 datoshi] + /// DUP [2 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH3 [1 datoshi] + /// MOD [8 datoshi] + /// DUP [2 datoshi] + /// PUSH0 [1 datoshi] + /// JMPGE 04 [2 datoshi] + /// JMP 08 [2 datoshi] + /// DUP [2 datoshi] + /// PUSHINT16 FF00 [1 datoshi] + /// JMPLE 06 [2 datoshi] + /// PUSHINT16 FF00 [1 datoshi] + /// AND [8 datoshi] + /// TUCK [2 datoshi] + /// PUSH0 [1 datoshi] + /// SWAP [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH3 [1 datoshi] + /// OVER [2 datoshi] + /// OVER [2 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH4 [1 datoshi] + /// AND [8 datoshi] + /// DUP [2 datoshi] + /// PUSH0 [1 datoshi] + /// JMPGE 04 [2 datoshi] + /// JMP 08 [2 datoshi] + /// DUP [2 datoshi] + /// PUSHINT16 FF00 [1 datoshi] + /// JMPLE 06 [2 datoshi] + /// PUSHINT16 FF00 [1 datoshi] + /// AND [8 datoshi] + /// DUP [2 datoshi] + /// REVERSE4 [2 datoshi] + /// REVERSE3 [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// RET [0 datoshi] + /// + [DisplayName("unitTest_Member_Element_Complex_Assign")] + public abstract void UnitTest_Member_Element_Complex_Assign(); + /// /// Unsafe method /// diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_NULL.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_NULL.cs index 3fd8ca757..e0d0cc279 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_NULL.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_NULL.cs @@ -10,12 +10,12 @@ public abstract class Contract_NULL(Neo.SmartContract.Testing.SmartContractIniti { #region Compiled data - public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_NULL"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""isNull"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":0,""safe"":false},{""name"":""equalNullA"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":8,""safe"":false},{""name"":""equalNullB"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":15,""safe"":false},{""name"":""equalNotNullA"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":21,""safe"":false},{""name"":""equalNotNullB"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":28,""safe"":false},{""name"":""nullCoalescing"",""parameters"":[{""name"":""code"",""type"":""String""}],""returntype"":""String"",""offset"":35,""safe"":false},{""name"":""nullCollation"",""parameters"":[{""name"":""code"",""type"":""String""}],""returntype"":""String"",""offset"":49,""safe"":false},{""name"":""nullPropertyGT"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":68,""safe"":false},{""name"":""nullPropertyLT"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":80,""safe"":false},{""name"":""nullPropertyGE"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":92,""safe"":false},{""name"":""nullPropertyLE"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":104,""safe"":false},{""name"":""nullProperty"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":116,""safe"":false},{""name"":""ifNull"",""parameters"":[{""name"":""obj"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":128,""safe"":false},{""name"":""nullCollationAndCollation"",""parameters"":[{""name"":""code"",""type"":""String""}],""returntype"":""Any"",""offset"":138,""safe"":false},{""name"":""nullCollationAndCollation2"",""parameters"":[{""name"":""code"",""type"":""String""}],""returntype"":""Any"",""offset"":167,""safe"":false},{""name"":""nullType"",""parameters"":[],""returntype"":""Void"",""offset"":208,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}"); + public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_NULL"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""isNull"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":0,""safe"":false},{""name"":""equalNullA"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":8,""safe"":false},{""name"":""equalNullB"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":15,""safe"":false},{""name"":""equalNotNullA"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":21,""safe"":false},{""name"":""equalNotNullB"",""parameters"":[{""name"":""value"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":28,""safe"":false},{""name"":""nullCoalescing"",""parameters"":[{""name"":""code"",""type"":""String""}],""returntype"":""String"",""offset"":35,""safe"":false},{""name"":""nullCollation"",""parameters"":[{""name"":""code"",""type"":""String""}],""returntype"":""String"",""offset"":49,""safe"":false},{""name"":""nullPropertyGT"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":68,""safe"":false},{""name"":""nullPropertyLT"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":80,""safe"":false},{""name"":""nullPropertyGE"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":92,""safe"":false},{""name"":""nullPropertyLE"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":104,""safe"":false},{""name"":""nullProperty"",""parameters"":[{""name"":""a"",""type"":""String""}],""returntype"":""Boolean"",""offset"":116,""safe"":false},{""name"":""ifNull"",""parameters"":[{""name"":""obj"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":128,""safe"":false},{""name"":""nullCollationAndCollation"",""parameters"":[{""name"":""code"",""type"":""String""}],""returntype"":""Any"",""offset"":138,""safe"":false},{""name"":""nullCollationAndCollation2"",""parameters"":[{""name"":""code"",""type"":""String""}],""returntype"":""Any"",""offset"":167,""safe"":false},{""name"":""nullType"",""parameters"":[],""returntype"":""Void"",""offset"":208,""safe"":false},{""name"":""nullCoalescingAssignment"",""parameters"":[],""returntype"":""Void"",""offset"":221,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}"); /// /// Optimization: "All" /// - public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAN1XAQF4cGjYQFcAAQt4l0BXAAF42EBXAAELeJhAVwABeNiqQFcBAXhK2CQFERKMcGhAVwEBeErYJgpFDAVsaW51eHBoQFcAAXhK2CQDyhC3QFcAAXhK2CQDyhC1QFcAAXhK2CQDyhC4QFcAAXhK2CQDyhC2QFcAAXhK2CQDyhCYQFcAAXgmBAhACUBXAQFBm/ZnznB4aEGSXegxStgmCkUMAXvbMNsoQFcBAUGb9mfOcAwDMTExeGhB5j8YhHhoQZJd6DFK2CYKRQwBe9sw2yhAVwEAC3BoStgkA0BFQLsXm8A=")); + public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP1/AVcBAXhwaNhAVwABC3iXQFcAAXjYQFcAAQt4mEBXAAF42KpAVwEBeErYJAUREoxwaEBXAQF4StgmCkUMBWxpbnV4cGhAVwABeErYJAPKELdAVwABeErYJAPKELVAVwABeErYJAPKELhAVwABeErYJAPKELZAVwABeErYJAPKEJhAVwABeCYECEAJQFcBAUGb9mfOcHhoQZJd6DFK2CYKRQwBe9sw2yhAVwEBQZv2Z85wDAMxMTF4aEHmPxiEeGhBkl3oMUrYJgpFDAF72zDbKEBXAQALcGhK2CQDQEVAVwEACxESwHBoEM4RlzkLSmgQUdBFaBHO2DloShHOStgkBUYiEUVoEM4TEgsQFcBOUBFR0EVoEEtLztgkBc4iC2gRzhDOSlRT0EVoEM4QlzloEEtLztgkBc4iC2gRzhHOSlRT0EVoEM4QlzloEc4RS0vO2CQFziIHEUpUU9BFaBHOEc4RlzloEc4RS0vO2CQFziIHEkpUU9BFaBHOEc4RlzlArhsXHA==")); #endregion @@ -127,6 +127,165 @@ public abstract class Contract_NULL(Neo.SmartContract.Testing.SmartContractIniti [DisplayName("nullCoalescing")] public abstract string? NullCoalescing(string? code); + /// + /// Unsafe method + /// + /// + /// Script: VwEACxESwHBoEM4RlzkLSmgQUdBFaBHO2DloShHOStgkBUYiEUVoEM4TEgsQFcBOUBFR0EVoEEtLztgkBc4iC2gRzhDOSlRT0EVoEM4QlzloEEtLztgkBc4iC2gRzhHOSlRT0EVoEM4QlzloEc4RS0vO2CQFziIHEUpUU9BFaBHOEc4RlzloEc4RS0vO2CQFziIHEkpUU9BFaBHOEc4RlzlA + /// INITSLOT 0100 [64 datoshi] + /// PUSHNULL [1 datoshi] + /// PUSH1 [1 datoshi] + /// PUSH2 [1 datoshi] + /// PACK [2048 datoshi] + /// STLOC0 [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// PUSHNULL [1 datoshi] + /// DUP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH0 [1 datoshi] + /// ROT [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// ISNULL [2 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// DUP [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// DUP [2 datoshi] + /// ISNULL [2 datoshi] + /// JMPIF 05 [2 datoshi] + /// NIP [2 datoshi] + /// JMP 11 [2 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH3 [1 datoshi] + /// PUSH2 [1 datoshi] + /// PUSHNULL [1 datoshi] + /// PUSH0 [1 datoshi] + /// PUSH5 [1 datoshi] + /// PACK [2048 datoshi] + /// TUCK [2 datoshi] + /// SWAP [2 datoshi] + /// PUSH1 [1 datoshi] + /// ROT [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH0 [1 datoshi] + /// OVER [2 datoshi] + /// OVER [2 datoshi] + /// PICKITEM [64 datoshi] + /// ISNULL [2 datoshi] + /// JMPIF 05 [2 datoshi] + /// PICKITEM [64 datoshi] + /// JMP 0B [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// DUP [2 datoshi] + /// REVERSE4 [2 datoshi] + /// REVERSE3 [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH0 [1 datoshi] + /// OVER [2 datoshi] + /// OVER [2 datoshi] + /// PICKITEM [64 datoshi] + /// ISNULL [2 datoshi] + /// JMPIF 05 [2 datoshi] + /// PICKITEM [64 datoshi] + /// JMP 0B [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// DUP [2 datoshi] + /// REVERSE4 [2 datoshi] + /// REVERSE3 [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// OVER [2 datoshi] + /// OVER [2 datoshi] + /// PICKITEM [64 datoshi] + /// ISNULL [2 datoshi] + /// JMPIF 05 [2 datoshi] + /// PICKITEM [64 datoshi] + /// JMP 07 [2 datoshi] + /// PUSH1 [1 datoshi] + /// DUP [2 datoshi] + /// REVERSE4 [2 datoshi] + /// REVERSE3 [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// OVER [2 datoshi] + /// OVER [2 datoshi] + /// PICKITEM [64 datoshi] + /// ISNULL [2 datoshi] + /// JMPIF 05 [2 datoshi] + /// PICKITEM [64 datoshi] + /// JMP 07 [2 datoshi] + /// PUSH2 [1 datoshi] + /// DUP [2 datoshi] + /// REVERSE4 [2 datoshi] + /// REVERSE3 [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// RET [0 datoshi] + /// + [DisplayName("nullCoalescingAssignment")] + public abstract void NullCoalescingAssignment(); + /// /// Unsafe method /// diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_PostfixUnary.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_PostfixUnary.cs index 3d8090801..23859ccc7 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_PostfixUnary.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_PostfixUnary.cs @@ -10,12 +10,12 @@ public abstract class Contract_PostfixUnary(Neo.SmartContract.Testing.SmartContr { #region Compiled data - public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_PostfixUnary"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""test"",""parameters"":[],""returntype"":""String"",""offset"":0,""safe"":false},{""name"":""isValid"",""parameters"":[{""name"":""person"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":168,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}"); + public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_PostfixUnary"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""test"",""parameters"":[],""returntype"":""String"",""offset"":0,""safe"":false},{""name"":""isValid"",""parameters"":[{""name"":""person"",""type"":""Any""}],""returntype"":""Boolean"",""offset"":168,""safe"":false},{""name"":""testUndefinedCase"",""parameters"":[],""returntype"":""Void"",""offset"":187,""safe"":false},{""name"":""testInvert"",""parameters"":[],""returntype"":""Void"",""offset"":517,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}"); /// /// Optimization: "All" /// - public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALtXAQAAUAA8AFATwBALE8AMBEpvaG5LNYcAAABwaDWLAAAAJnloShHOTpxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfEVDQRWgSzhFLS85KVFOcSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn9BFaBDOQAtAVwACeUp4EFHQRUBXAQF4cGjYJgQJQHgQznBo2KpAad6x8A==")); + public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0IAlcBAABQADwAUBPAEAsTwAwESm9obks1hwAAAHBoNYsAAAAmeWhKEc5OnEoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ8RUNBFaBLOEUtLzkpUU5xKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACf0EVoEM5AC0BXAAJ5SngQUdBFQFcBAXhwaNgmBAlAeBDOcGjYqkBXAQAAUAA8AFATwBALE8AMCVVuZGVmaW5lZEs0x3BoEc4QlzloShHOTpxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfEVDQSmgRUdBFaBHOEJc5aEoRzpxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfThFQ0EpoEVHQRWgRzhGXOWgSzhDOAFCXOWgSzhBLS85KVFOcSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn9BKaBLOEFHQRWgSzhDOAFCXOWgSzhBLS86cSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn0pUU9BKaBLOEFHQRWgSzhDOAFGXOUAIOUCv254D")); #endregion @@ -129,5 +129,209 @@ public abstract class Contract_PostfixUnary(Neo.SmartContract.Testing.SmartContr [DisplayName("test")] public abstract string? Test(); + /// + /// Unsafe method + /// + /// + /// Script: CDlA + /// PUSHT [1 datoshi] + /// ASSERT [1 datoshi] + /// RET [0 datoshi] + /// + [DisplayName("testInvert")] + public abstract void TestInvert(); + + /// + /// Unsafe method + /// + /// + /// Script: VwEAAFAAPABQE8AQCxPADAlVbmRlZmluZWRLNMdwaBHOEJc5aEoRzk6cSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAnxFQ0EpoEVHQRWgRzhCXOWhKEc6cSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn04RUNBKaBFR0EVoEc4RlzloEs4QzgBQlzloEs4QS0vOSlRTnEoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ/QSmgSzhBR0EVoEs4QzgBQlzloEs4QS0vOnEoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9KVFPQSmgSzhBR0EVoEs4QzgBRlzlA + /// INITSLOT 0100 [64 datoshi] + /// PUSHINT8 50 [1 datoshi] + /// PUSHINT8 3C [1 datoshi] + /// PUSHINT8 50 [1 datoshi] + /// PUSH3 [1 datoshi] + /// PACK [2048 datoshi] + /// PUSH0 [1 datoshi] + /// PUSHNULL [1 datoshi] + /// PUSH3 [1 datoshi] + /// PACK [2048 datoshi] + /// PUSHDATA1 556E646566696E6564 'Undefined' [8 datoshi] + /// OVER [2 datoshi] + /// CALL C7 [512 datoshi] + /// STLOC0 [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// DUP [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// TUCK [2 datoshi] + /// INC [4 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 00000080 [1 datoshi] + /// JMPGE 04 [2 datoshi] + /// JMP 0A [2 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 1E [2 datoshi] + /// PUSHINT64 FFFFFFFF00000000 [1 datoshi] + /// AND [8 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 0C [2 datoshi] + /// PUSHINT64 0000000001000000 [1 datoshi] + /// SUB [8 datoshi] + /// PUSH1 [1 datoshi] + /// SWAP [2 datoshi] + /// SETITEM [8192 datoshi] + /// DUP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// ROT [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// DUP [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// INC [4 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 00000080 [1 datoshi] + /// JMPGE 04 [2 datoshi] + /// JMP 0A [2 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 1E [2 datoshi] + /// PUSHINT64 FFFFFFFF00000000 [1 datoshi] + /// AND [8 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 0C [2 datoshi] + /// PUSHINT64 0000000001000000 [1 datoshi] + /// SUB [8 datoshi] + /// TUCK [2 datoshi] + /// PUSH1 [1 datoshi] + /// SWAP [2 datoshi] + /// SETITEM [8192 datoshi] + /// DUP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// ROT [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH1 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH2 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSHINT8 50 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH2 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// OVER [2 datoshi] + /// OVER [2 datoshi] + /// PICKITEM [64 datoshi] + /// DUP [2 datoshi] + /// REVERSE4 [2 datoshi] + /// REVERSE3 [2 datoshi] + /// INC [4 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 00000080 [1 datoshi] + /// JMPGE 04 [2 datoshi] + /// JMP 0A [2 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 1E [2 datoshi] + /// PUSHINT64 FFFFFFFF00000000 [1 datoshi] + /// AND [8 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 0C [2 datoshi] + /// PUSHINT64 0000000001000000 [1 datoshi] + /// SUB [8 datoshi] + /// SETITEM [8192 datoshi] + /// DUP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH2 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// ROT [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH2 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSHINT8 50 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH2 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// OVER [2 datoshi] + /// OVER [2 datoshi] + /// PICKITEM [64 datoshi] + /// INC [4 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 00000080 [1 datoshi] + /// JMPGE 04 [2 datoshi] + /// JMP 0A [2 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 1E [2 datoshi] + /// PUSHINT64 FFFFFFFF00000000 [1 datoshi] + /// AND [8 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 0C [2 datoshi] + /// PUSHINT64 0000000001000000 [1 datoshi] + /// SUB [8 datoshi] + /// DUP [2 datoshi] + /// REVERSE4 [2 datoshi] + /// REVERSE3 [2 datoshi] + /// SETITEM [8192 datoshi] + /// DUP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH2 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// ROT [2 datoshi] + /// SETITEM [8192 datoshi] + /// DROP [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH2 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSH0 [1 datoshi] + /// PICKITEM [64 datoshi] + /// PUSHINT8 51 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// RET [0 datoshi] + /// + [DisplayName("testUndefinedCase")] + public abstract void TestUndefinedCase(); + #endregion } diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Tuple.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Tuple.cs index 7e14a7cc9..fa760ce34 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Tuple.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Tuple.cs @@ -15,7 +15,7 @@ public abstract class Contract_Tuple(Neo.SmartContract.Testing.SmartContractInit /// /// Optimization: "All" /// - public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADkUExIRFL9AVwIACxAQCwsVv3AQCxK/SmgUUdBFEHE04krBRWgSUdBoFM4RUdBFcUVpSmgTUdBFaECoZ8J4")); + public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwUExIRFL9AVwIACxAQCwsVv3AQCxK/SmgUUdBFEHE04krBRWgSUdBoFM4RUdBFcUU00EVpSmgTUdBFaEBi7byw")); #endregion @@ -41,7 +41,7 @@ public abstract class Contract_Tuple(Neo.SmartContract.Testing.SmartContractInit /// Unsafe method /// /// - /// Script: VwIACxAQCwsVv3AQCxK/SmgUUdBFEHE04krBRWgSUdBoFM4RUdBFcUVpSmgTUdBFaEA= + /// Script: VwIACxAQCwsVv3AQCxK/SmgUUdBFEHE04krBRWgSUdBoFM4RUdBFcUU00EVpSmgTUdBFaEA= /// INITSLOT 0200 [64 datoshi] /// PUSHNULL [1 datoshi] /// PUSH0 [1 datoshi] @@ -80,6 +80,8 @@ public abstract class Contract_Tuple(Neo.SmartContract.Testing.SmartContractInit /// DROP [2 datoshi] /// STLOC1 [2 datoshi] /// DROP [2 datoshi] + /// CALL D0 [512 datoshi] + /// DROP [2 datoshi] /// LDLOC1 [2 datoshi] /// DUP [2 datoshi] /// LDLOC0 [2 datoshi] diff --git a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_BinaryExpression.cs b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_BinaryExpression.cs new file mode 100644 index 000000000..bafce56bd --- /dev/null +++ b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_BinaryExpression.cs @@ -0,0 +1,24 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Neo.SmartContract.Testing; +using System.Text; + +namespace Neo.Compiler.CSharp.UnitTests +{ + [TestClass] + public class UnitTest_BinaryExpression : DebugAndTestBase + { + [TestMethod] + public void Test_BinaryIs() + { + Contract.BinaryIs(); + AssertGasConsumed(986850); + } + + [TestMethod] + public void Test_BinaryAs() + { + Contract.BinaryAs(); + AssertGasConsumed(987720); + } + } +} diff --git a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Contract_ComplexAssign.cs b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Contract_ComplexAssign.cs index 366da2d1c..07524dc1e 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Contract_ComplexAssign.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Contract_ComplexAssign.cs @@ -91,5 +91,12 @@ public void Test_RightShiftAssign_UnChecked() Assert.AreEqual(new BigInteger(unchecked(uint.MinValue >> 1)), values[0]); Assert.AreEqual(new BigInteger(unchecked(int.MinValue >> 1)), values[1]); } + + [TestMethod] + public void Test_Member_Element_Complex_Assign() + { + Contract.UnitTest_Member_Element_Complex_Assign(); + AssertGasConsumed(1800780); + } } } diff --git a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_NULL.cs b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_NULL.cs index 72ad0dec5..f69b9aabe 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_NULL.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_NULL.cs @@ -189,5 +189,12 @@ public void NullTypeTest() Contract.NullType(); // no error AssertGasConsumed(986340); } + + [TestMethod] + public void NullCoalescingAssignment() + { + Contract.NullCoalescingAssignment(); + AssertGasConsumed(2139660); + } } } diff --git a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_PostfixUnary.cs b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_PostfixUnary.cs index 37957e7dd..6e56414b3 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_PostfixUnary.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_PostfixUnary.cs @@ -11,5 +11,17 @@ public void Test() { Assert.AreEqual("John", Contract.Test()); } + + [TestMethod] + public void TestUndefinedCase() + { + Contract.TestUndefinedCase(); + } + + [TestMethod] + public void TestInvert() + { + Contract.TestInvert(); + } } } diff --git a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Tuple.cs b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Tuple.cs index 30da52d83..b3095e7f2 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Tuple.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Tuple.cs @@ -11,7 +11,7 @@ public class UnitTest_Tuple : DebugAndTestBase public void Test_Assign() { var tuple = Contract.T1()! as Struct; - AssertGasConsumed(2233890); + AssertGasConsumed(2310900); Assert.AreEqual(5, tuple!.Count); Assert.AreEqual(1, tuple[2].GetInteger()); Assert.AreEqual(4, tuple[3].GetInteger());