forked from neo-project/neo-devpack-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix mapping between C# types and NeoVM types (neo-project#295)
fixed neo-project#290 Co-authored-by: lights li <lightsever@hotmail.com> Co-authored-by: erikzhang <erik@neo.org>
- Loading branch information
Showing
6 changed files
with
503 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_Types.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Neo.Compiler.MSIL.UnitTests.TestClasses | ||
{ | ||
class Contract_Types : SmartContract.Framework.SmartContract | ||
{ | ||
public enum EDummy : byte | ||
{ | ||
test = 5 | ||
} | ||
|
||
public delegate EDummy enumDel(); | ||
public delegate void del(string msg); | ||
public static event del dummyEvent; | ||
|
||
public class DummyClass | ||
{ | ||
public string Value; | ||
} | ||
|
||
public struct DummyStruct | ||
{ | ||
public string Value; | ||
} | ||
|
||
public static object checkNull() { return null; } | ||
public static bool checkBoolTrue() { return true; } | ||
public static bool checkBoolFalse() { return false; } | ||
public static sbyte checkSbyte() { return (sbyte)5; } | ||
public static byte checkByte() { return (byte)5; } | ||
public static short checkShort() { return (short)5; } | ||
public static ushort checkUshort() { return (ushort)5; } | ||
public static int checkInt() { return (int)5; } | ||
public static uint checkUint() { return (uint)5; } | ||
public static long checkLong() { return (long)5; } | ||
public static ulong checkUlong() { return (ulong)5; } | ||
public static char checkChar() { return 'n'; } | ||
public static string checkString() { return "neo"; } | ||
public static object[] checkArrayObj() { return new object[] { "neo" }; } | ||
public static BigInteger checkBigInteger() { return (BigInteger)5; } | ||
public static byte[] checkByteArray() { return new byte[] { 1, 2, 3 }; } | ||
public static EDummy checkEnum() { return EDummy.test; } | ||
public static enumDel checkDelegate() | ||
{ | ||
return new enumDel(checkEnum); | ||
} | ||
public static Func<EDummy> checkLambda() | ||
{ | ||
return checkEnum; | ||
} | ||
public static void checkEvent() | ||
{ | ||
dummyEvent("neo"); | ||
} | ||
public static DummyClass checkClass() | ||
{ | ||
var ret = new DummyClass(); | ||
ret.Value = "neo"; | ||
return ret; | ||
} | ||
public static DummyStruct checkStruct() | ||
{ | ||
var ret = new DummyStruct(); | ||
ret.Value = "neo"; | ||
return ret; | ||
} | ||
public static (string value1, string value2) checkTuple() | ||
{ | ||
return ("neo", "smart economy"); | ||
} | ||
public static (string value1, string value2) checkTuple2() | ||
{ | ||
var tuple = ("neo", "smart economy"); | ||
return tuple; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_Types_Decimal.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Neo.Compiler.MSIL.UnitTests.TestClasses | ||
{ | ||
class Contract_Types_Decimal : SmartContract.Framework.SmartContract | ||
{ | ||
public static Decimal checkDecimal() { return 0.1M; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_Types_Double.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Neo.Compiler.MSIL.UnitTests.TestClasses | ||
{ | ||
class Contract_Types_Double : SmartContract.Framework.SmartContract | ||
{ | ||
public static double checkDouble() { return 0.1D; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_Types_Float.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Neo.Compiler.MSIL.UnitTests.TestClasses | ||
{ | ||
class Contract_Types_Float : SmartContract.Framework.SmartContract | ||
{ | ||
public static float checkFloat() { return 0.1F; } | ||
} | ||
} |
Oops, something went wrong.