Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional tests #190

Merged
merged 1 commit into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/Ubiquity.NET.Llvm.Tests/DebugInfo/DebugStructTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Ubiquity.NET.Llvm.DebugInfo;
using Ubiquity.NET.Llvm.Types;

namespace Ubiquity.NET.Llvm.Tests.DebugInfo
{
Expand Down Expand Up @@ -65,21 +66,34 @@ public void DebugStructType_constructing_empty_anonymous_struct_succeeds( )
Assert.AreEqual( sourceName, structType.SourceName );
}

#if NOT_YET_READY_GENERATED
[TestMethod]
public void SetBody_StateUnderTest_ExpectedBehavior( )
public void SetBody_with_native_elements_succeeds( )
{
var debugStructType = new DebugStructType( TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO, TODO );
using var context = new Context( );
using var testModule = context.CreateBitcodeModule( "test" );

var file = testModule.DIBuilder.CreateFile( "test.foo" );
uint line = 1234;
string sourceName = string.Empty;
string linkageName = string.Empty;

var debugStructType = new DebugStructType( testModule, linkageName, file, sourceName, file, line );
bool packed = false;
ITypeRef[ ] elements = null;
var elements = new ITypeRef[] { context.Float128Type, context.Int32Type, context.Int64Type };

debugStructType.SetBody(
packed,
elements );

Assert.Inconclusive( );
Assert.AreEqual( elements.Length, debugStructType.Members.Count );
for(int i =0; i < elements.Length; ++i )
{
Assert.AreSame( elements[ i ], debugStructType.Members[ i ] );
}
}

#if NOT_YET_READY_GENERATED

[TestMethod]
public void SetBody_StateUnderTest_ExpectedBehavior1( )
{
Expand Down
4 changes: 2 additions & 2 deletions src/Ubiquity.NET.Llvm/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public Constant CreateNamedConstantStruct( IStructType type, IEnumerable<Constan
}

/// <summary>Create an opaque structure type (e.g. a forward reference)</summary>
/// <param name="name">Name of the type</param>
/// <param name="name">Name of the type (use <see cref="string.Empty"/> for anonymous types)</param>
/// <remarks>
/// This method creates an opaque type. The <see cref="IStructType.SetBody(bool, ITypeRef[])"/>
/// method provides a means to add a body, including indication of packed status, to an opaque
Expand All @@ -406,7 +406,7 @@ public Constant CreateNamedConstantStruct( IStructType type, IEnumerable<Constan
/// <returns>New type</returns>
public IStructType CreateStructType( string name )
{
name.ValidateNotNullOrWhiteSpace( nameof( name ) );
name.ValidateNotNull( nameof( name ) );
var handle = LLVMStructCreateNamed( ContextHandle, name );
return TypeRef.FromHandle<IStructType>( handle.ThrowIfInvalid( ) )!;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Ubiquity.NET.Llvm/IOperandCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public interface IOperandCollection<T>
bool Contains( T item );

/// <summary>Creates a slice of the collection</summary>
/// <param name="start">inclusive start index for the slice</param>
/// <param name="start">Inclusive start index for the slice</param>
/// <param name="end">Exclusive end index for the slice</param>
/// <returns>Slice of the collection</returns>
[SuppressMessage( "Naming", "CA1716:Identifiers should not match keywords", Justification = "Name is consistent with System.Range parameters" )]
[SuppressMessage( "Naming", "CA1716:Identifiers should not match keywords", Justification = "Naming is consistent with System.Range parameters" )]
IOperandCollection<T> Slice( int start, int end )
{
return new OperandCollectionSlice<T>( this, new Range( start, end ) );
Expand Down
43 changes: 0 additions & 43 deletions src/Ubiquity.NET.Llvm/IOperandContainer.cs

This file was deleted.