Skip to content

Commit

Permalink
unittest for staticvar (#65)
Browse files Browse the repository at this point in the history
* shift for bigint

* unittest for static var.

without jsonconfig.

* Fix tests
  • Loading branch information
lightszero committed Jun 16, 2019
1 parent 22981e1 commit 6a042d6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Neo.Compiler.MSIL.TestClasses
{

class Contract_staticvar : SmartContract.Framework.SmartContract
{
static int a1 = 1;

public static object Main(string method, object[] args)
{
testadd();
testmulti();
return a1;
}

static void testadd()
{
a1 += 5;
}
static void testmulti()
{
a1 *= 7;
}
}

}
25 changes: 25 additions & 0 deletions tests/Neo.Compiler.MSIL.UnitTests/UnitTest_StaticVar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Compiler.MSIL.Utils;
using Neo.VM;

namespace Neo.Compiler.MSIL
{
[TestClass]
public class UnitTest_StaticVar
{
[TestMethod]
public void Test_StaticVar()
{
var testengine = new TestEngine();
testengine.AddEntryScript("./TestClasses/Contract_StaticVar.cs");
StackItem[] _params = new StackItem[] { "testfunc", new StackItem[0] };
var result = testengine.ExecuteTestCase(_params);

//test (1+5)*7 == 42
StackItem wantresult = 42;
var bequal = wantresult.Equals(result.Pop());
Assert.IsTrue(bequal);
}

}
}

0 comments on commit 6a042d6

Please sign in to comment.