public void TestLoadFunction() { var classMetadataProvider = new ClassMetadataProvider(); var typeProvider = new TypeProvider(classMetadataProvider); var functionLoader = new FunctionLoader(typeProvider); var intType = typeProvider.FindPrimitiveType(PrimitiveTypes.Int); var floatType = typeProvider.FindPrimitiveType(PrimitiveTypes.Float); var parsedFunction = new SharpJIT.Loader.Data.Function( "test", new List <string>() { intType.Name }, intType.Name, new List <string>() { floatType.Name }, new List <SharpJIT.Loader.Data.Instruction>() { new SharpJIT.Loader.Data.Instruction(OpCodes.LoadInt, 1337), new SharpJIT.Loader.Data.Instruction(OpCodes.Return) }); var functionDefinition = new FunctionDefinition("test", new List <BaseType>() { intType }, intType); var function = functionLoader.LoadManagedFunction(parsedFunction, functionDefinition); Assert.AreEqual(functionDefinition, function.Definition); Assert.AreEqual(1, function.Locals.Count); Assert.AreEqual(floatType, function.Locals[0]); Assert.AreEqual(2, function.Instructions.Count); Assert.AreEqual(OpCodes.LoadInt, function.Instructions[0].OpCode); Assert.AreEqual(1337, function.Instructions[0].IntValue); Assert.AreEqual(OpCodes.Return, function.Instructions[1].OpCode); }