-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test basic block nextBlock in if return
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
tests/Neo.Compiler.CSharp.UnitTests/Optimizer/BasicBlockTests.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,32 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.Optimizer; | ||
using Neo.SmartContract.Testing; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Neo.Compiler.CSharp.UnitTests.Optimizer | ||
{ | ||
[TestClass] | ||
public class BasicBlockTests | ||
{ | ||
[TestMethod] | ||
public void Test_BasicBlockIfReturn() | ||
{ | ||
//public static BigInteger Factorial(BigInteger a) | ||
//{ | ||
// ExecutionEngine.Assert(a >= 0, "Minus number not supported"); | ||
// if (a >= 2) return a * Factorial(a - 1); | ||
// return 1; | ||
//} | ||
ContractInBasicBlocks contract = new(Contract_Recursion.Nef, Contract_Recursion.Manifest); | ||
List<BasicBlock> blocks = contract.sortedBasicBlocks; | ||
Assert.AreEqual(blocks[0].nextBlock, blocks[1]); | ||
Assert.AreEqual(blocks[0].jumpTargetBlocks.Count, 1); | ||
Assert.AreEqual(blocks[0].jumpTargetBlocks.First(), blocks[3]); | ||
Assert.AreEqual(blocks[0].instructions.Last().OpCode, VM.OpCode.JMPIFNOT); | ||
Assert.AreEqual(blocks[1].instructions.Last().OpCode, VM.OpCode.CALL); | ||
Assert.AreEqual(blocks[2].nextBlock, null); | ||
Assert.AreEqual(blocks[2].instructions.Last().OpCode, VM.OpCode.RET); | ||
} | ||
} | ||
} |