Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added tests for verifying FunctionPointerSignature writes

  • Loading branch information...
commit af12a33be860b603ae6372a4952f1e378efe3421 1 parent b181b0a
unknown authored
2  src/Tao/Metadata/Signatures/FunctionPointerSignature.n
View
@@ -21,6 +21,8 @@ namespace Tao
{
_reader = reader;
_writer = writer;
+
+ ElementType = ElementType.FnPtr;
}
public MethodSignature : TSignature { get; set; }
23 src/Tests/Signatures/MethodDefSignatureTests.n
View
@@ -283,8 +283,29 @@ namespace Tests
methodSignature.HasThis.ShouldBeFalse("HasThis should be false");
methodSignature.HasExplicitThis.ShouldBeFalse("HasExplicitThis should be false");
}
- public stub ShouldBeAbleToWriteFunctionPointerSignatureAsTypeSignature() : void
+ public ShouldBeAbleToWriteFunctionPointerSignatureAsTypeSignature() : void
{
+ def signatureBytes = CreateSignatureBytes(array[Default], 0, ElementType.Void);
+
+ // The expected type signature should look like: FNPTR DEFAULT (zero parameters) VOID
+ def expectedStream = MemoryStream();
+ def writer = BinaryWriter(expectedStream);
+ writer.Write(ElementType.FnPtr :> byte);
+ writer.Write(signatureBytes);
+
+ expectedStream.Seek(0);
+
+ def methodSignature = MethodDefSignature();
+ methodSignature.ReturnType = RetType(VoidSignature.Instance);
+ methodSignature.UsesDefaultCallingConvention = true;
+
+ def typeSignature = MethodDefFunctionPointerSignature();
+ typeSignature.MethodSignature = methodSignature;
+
+ def outputStream = MemoryStream();
+ typeSignature.Write(outputStream);
+
+ outputStream.ShouldMatch(expectedStream);
}
private CreateGenericSignatureBytes(conventions: IEnumerable.[CallingConvention], genericParameterCount : uint, parameterCount : uint, returnType : ElementType) : array[byte]
{
Please sign in to comment.
Something went wrong with that request. Please try again.