You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
108
external/cecil-legacy/Test/Mono.Cecil.Tests/VariableTests.cs
vendored
Normal file
108
external/cecil-legacy/Test/Mono.Cecil.Tests/VariableTests.cs
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Mono.Cecil.Tests {
|
||||
|
||||
[TestFixture]
|
||||
public class VariableTests : BaseTestFixture {
|
||||
|
||||
[Test]
|
||||
public void AddVariableIndex ()
|
||||
{
|
||||
var object_ref = new TypeReference ("System", "Object", null, null, false);
|
||||
var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref);
|
||||
var body = new MethodBody (method);
|
||||
|
||||
var x = new VariableDefinition ("x", object_ref);
|
||||
var y = new VariableDefinition ("y", object_ref);
|
||||
|
||||
body.Variables.Add (x);
|
||||
body.Variables.Add (y);
|
||||
|
||||
Assert.AreEqual (0, x.Index);
|
||||
Assert.AreEqual (1, y.Index);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveAtVariableIndex ()
|
||||
{
|
||||
var object_ref = new TypeReference ("System", "Object", null, null, false);
|
||||
var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref);
|
||||
var body = new MethodBody (method);
|
||||
|
||||
var x = new VariableDefinition ("x", object_ref);
|
||||
var y = new VariableDefinition ("y", object_ref);
|
||||
var z = new VariableDefinition ("z", object_ref);
|
||||
|
||||
body.Variables.Add (x);
|
||||
body.Variables.Add (y);
|
||||
body.Variables.Add (z);
|
||||
|
||||
Assert.AreEqual (0, x.Index);
|
||||
Assert.AreEqual (1, y.Index);
|
||||
Assert.AreEqual (2, z.Index);
|
||||
|
||||
body.Variables.RemoveAt (1);
|
||||
|
||||
Assert.AreEqual (0, x.Index);
|
||||
Assert.AreEqual (-1, y.Index);
|
||||
Assert.AreEqual (1, z.Index);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveVariableIndex ()
|
||||
{
|
||||
var object_ref = new TypeReference ("System", "Object", null, null, false);
|
||||
var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref);
|
||||
var body = new MethodBody (method);
|
||||
|
||||
var x = new VariableDefinition ("x", object_ref);
|
||||
var y = new VariableDefinition ("y", object_ref);
|
||||
var z = new VariableDefinition ("z", object_ref);
|
||||
|
||||
body.Variables.Add (x);
|
||||
body.Variables.Add (y);
|
||||
body.Variables.Add (z);
|
||||
|
||||
Assert.AreEqual (0, x.Index);
|
||||
Assert.AreEqual (1, y.Index);
|
||||
Assert.AreEqual (2, z.Index);
|
||||
|
||||
body.Variables.Remove (y);
|
||||
|
||||
Assert.AreEqual (0, x.Index);
|
||||
Assert.AreEqual (-1, y.Index);
|
||||
Assert.AreEqual (1, z.Index);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InsertVariableIndex ()
|
||||
{
|
||||
var object_ref = new TypeReference ("System", "Object", null, null, false);
|
||||
var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref);
|
||||
var body = new MethodBody (method);
|
||||
|
||||
var x = new VariableDefinition ("x", object_ref);
|
||||
var y = new VariableDefinition ("y", object_ref);
|
||||
var z = new VariableDefinition ("z", object_ref);
|
||||
|
||||
body.Variables.Add (x);
|
||||
body.Variables.Add (z);
|
||||
|
||||
Assert.AreEqual (0, x.Index);
|
||||
Assert.AreEqual (-1, y.Index);
|
||||
Assert.AreEqual (1, z.Index);
|
||||
|
||||
body.Variables.Insert (1, y);
|
||||
|
||||
Assert.AreEqual (0, x.Index);
|
||||
Assert.AreEqual (1, y.Index);
|
||||
Assert.AreEqual (2, z.Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user