Skip to content

Commit

Permalink
Merge branch 'master' into neo-nullable
Browse files Browse the repository at this point in the history
* master:
  Related to neo-project#3082 (comment) (neo-project#3119)
  [VM UT] update UT name (neo-project#3115)
  • Loading branch information
Jim8y committed Feb 7, 2024
2 parents c978279 + e3707fd commit 7a8b4bf
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 48 deletions.
6 changes: 3 additions & 3 deletions src/Neo.VM/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public static long GetBitLength(this BigInteger value)
var b = value.ToByteArray();
if (b.Length == 1 || (b.Length == 2 && b[1] == 0))
{
return BitLen(value.Sign > 0 ? b[0] : (byte)(255 - b[0]));
return BitCount(value.Sign > 0 ? b[0] : (byte)(255 - b[0]));
}
return (b.Length - 1) * 8 + BitLen(value.Sign > 0 ? b[^1] : 255 - b[^1]);
return (b.Length - 1) * 8 + BitCount(value.Sign > 0 ? b[^1] : 255 - b[^1]);
#endif
}

#if !NET5_0_OR_GREATER
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int BitLen(int w)
private static int BitCount(int w)
{
return w < 1 << 15 ? (w < 1 << 7
? (w < 1 << 3 ? (w < 1 << 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtDebugger.cs file belongs to the neo project and is free
// UT_Debugger.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -15,7 +15,7 @@
namespace Neo.Test
{
[TestClass]
public class UtDebugger
public class UT_Debugger
{
[TestMethod]
public void TestBreakPoint()
Expand Down Expand Up @@ -97,10 +97,10 @@ public void TestStepOver()
{
using ExecutionEngine engine = new();
using ScriptBuilder script = new();
/* ┌ CALL
/* ┌ CALL
│ ┌> NOT
│ │ RET
└> │ PUSH0
└> │ PUSH0
└─┘ RET */
script.EmitCall(4);
script.Emit(OpCode.NOT);
Expand Down Expand Up @@ -135,7 +135,7 @@ public void TestStepInto()
using ExecutionEngine engine = new();
using ScriptBuilder script = new();
/* ┌ CALL
│ ┌> NOT
│ ┌> NOT
│ │ RET
└> │ PUSH0
└─┘ RET */
Expand Down Expand Up @@ -185,7 +185,7 @@ public void TestBreakPointStepOver()
{
using ExecutionEngine engine = new();
using ScriptBuilder script = new();
/* ┌ CALL
/* ┌ CALL
│ ┌> NOT
│ │ RET
└>X│ PUSH0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtEvaluationStack.cs file belongs to the neo project and is free
// UT_EvaluationStack.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -19,7 +19,7 @@
namespace Neo.Test
{
[TestClass]
public class UtEvaluationStack
public class UT_EvaluationStack
{
private static EvaluationStack CreateOrderedStack(int count)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtExecutionContext.cs file belongs to the neo project and is free
// UT_ExecutionContext.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -17,15 +17,15 @@
namespace Neo.Test
{
[TestClass]
public class UtExecutionContext
public class UT_ExecutionContext
{
class TestState
{
public bool Flag = false;
}

[TestMethod]
public void StateTest()
public void TestStateTest()
{
var context = new ExecutionContext(Array.Empty<byte>(), -1, new ReferenceCounter());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtReferenceCounter.cs file belongs to the neo project and is free
// UT_ReferenceCounter.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -16,7 +16,7 @@
namespace Neo.Test
{
[TestClass]
public class UtReferenceCounter
public class UT_ReferenceCounter
{
[TestMethod]
public void TestCircularReferences()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtScript.cs file belongs to the neo project and is free
// UT_Script.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -17,10 +17,10 @@
namespace Neo.Test
{
[TestClass]
public class UtScript
public class UT_Script
{
[TestMethod]
public void Conversion()
public void TestConversion()
{
byte[] rawScript;
using (var builder = new ScriptBuilder())
Expand All @@ -39,7 +39,7 @@ public void Conversion()
}

[TestMethod]
public void StrictMode()
public void TestStrictMode()
{
var rawScript = new byte[] { (byte)OpCode.PUSH0, 0xFF };
Assert.ThrowsException<BadScriptException>(() => new Script(rawScript, true));
Expand All @@ -58,7 +58,7 @@ public void StrictMode()
}

[TestMethod]
public void Parse()
public void TestParse()
{
Script script;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtScriptBuilder.cs file belongs to the neo project and is free
// UT_ScriptBuilder.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -21,7 +21,7 @@
namespace Neo.Test
{
[TestClass]
public class UtScriptBuilder
public class UT_ScriptBuilder
{
[TestMethod]
public void TestEmit()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtSlot.cs file belongs to the neo project and is free
// UT_Slot.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -20,7 +20,7 @@
namespace Neo.Test
{
[TestClass]
public class UtSlot
public class UT_Slot
{
private static Slot CreateOrderedSlot(int count)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtStackItem.cs file belongs to the neo project and is free
// UT_StackItem.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -17,10 +17,10 @@
namespace Neo.Test
{
[TestClass]
public class UtStackItem
public class UT_StackItem
{
[TestMethod]
public void HashCodeTest()
public void TestHashCode()
{
StackItem itemA = "NEO";
StackItem itemB = "NEO";
Expand Down Expand Up @@ -80,7 +80,7 @@ public void HashCodeTest()
}

[TestMethod]
public void NullTest()
public void TestNull()
{
StackItem nullItem = System.Array.Empty<byte>();
Assert.AreNotEqual(StackItem.Null, nullItem);
Expand All @@ -90,7 +90,7 @@ public void NullTest()
}

[TestMethod]
public void EqualTest()
public void TestEqual()
{
StackItem itemA = "NEO";
StackItem itemB = "NEO";
Expand All @@ -106,7 +106,7 @@ public void EqualTest()
}

[TestMethod]
public void CastTest()
public void TestCast()
{
// Signed byte

Expand Down Expand Up @@ -187,7 +187,7 @@ public void CastTest()
}

[TestMethod]
public void DeepCopyTest()
public void TestDeepCopy()
{
Array a = new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtStruct.cs file belongs to the neo project and is free
// UT_Struct.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -17,19 +17,19 @@
namespace Neo.Test
{
[TestClass]
public class UtStruct
public class UT_Struct
{
private readonly Struct @struct;

public UtStruct()
public UT_Struct()
{
@struct = new Struct { 1 };
for (int i = 0; i < 20000; i++)
@struct = new Struct { @struct };
}

[TestMethod]
public void Clone()
public void TestClone()
{
Struct s1 = new() { 1, new Struct { 2 } };
Struct s2 = s1.Clone(ExecutionEngineLimits.Default);
Expand All @@ -41,7 +41,7 @@ public void Clone()
}

[TestMethod]
public void Equals()
public void TestEquals()
{
Struct s1 = new() { 1, new Struct { 2 } };
Struct s2 = new() { 1, new Struct { 2 } };
Expand All @@ -52,7 +52,7 @@ public void Equals()
}

[TestMethod]
public void EqualsDos()
public void TestEqualsDos()
{
string payloadStr = new string('h', 65535);
Struct s1 = new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtUnsafe.cs file belongs to the neo project and is free
// UT_Unsafe.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -15,10 +15,10 @@
namespace Neo.Test
{
[TestClass]
public class UtUnsafe
public class UT_Unsafe
{
[TestMethod]
public void NotZero()
public void TestNotZero()
{
Assert.IsFalse(Unsafe.NotZero(System.Array.Empty<byte>()));
Assert.IsFalse(Unsafe.NotZero(new byte[4]));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtUtility.cs file belongs to the neo project and is free
// UT_Utility.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -17,10 +17,10 @@
namespace Neo.Test
{
[TestClass]
public class UtUtility
public class UT_Utility
{
[TestMethod]
public void SqrtTest()
public void TestSqrtTest()
{
Assert.ThrowsException<InvalidOperationException>(() => BigInteger.MinusOne.Sqrt());

Expand Down Expand Up @@ -49,7 +49,7 @@ private void VerifyGetBitLength(BigInteger value, long expected)
}

[TestMethod]
public void GetBitLengthTest()
public void TestGetBitLength()
{
var random = new Random();

Expand Down Expand Up @@ -91,7 +91,7 @@ public void GetBitLengthTest()
}

[TestMethod]
public void ModInverseTest()
public void TestModInverseTest()
{
Assert.ThrowsException<ArgumentOutOfRangeException>(() => BigInteger.One.ModInverse(BigInteger.Zero));
Assert.ThrowsException<ArgumentOutOfRangeException>(() => BigInteger.One.ModInverse(BigInteger.One));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// UtVMJson.cs file belongs to the neo project and is free
// UT_VMJson.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -19,7 +19,7 @@
namespace Neo.Test
{
[TestClass]
public class UtVMJson : VMJsonTestBase
public class UT_VMJson : VMJsonTestBase
{
[TestMethod]
public void TestOthers() => TestJson("./Tests/Others");
Expand Down

0 comments on commit 7a8b4bf

Please sign in to comment.