-
-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05085c5
commit 585a0bd
Showing
9 changed files
with
229 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/Silk.NET.SilkTouch.Emitter.Tests/ExternalTypeReferenceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.ComponentModel; | ||
using System.Security.Cryptography.X509Certificates; | ||
using Silk.NET.SilkTouch.Symbols; | ||
using Xunit; | ||
|
||
namespace Silk.NET.SilkTouch.Emitter.Tests; | ||
|
||
public class ExternalTypeReferenceTests : EmitterTest | ||
{ | ||
[Fact, Trait("Category", "Symbols"), | ||
Trait("Target Language", "C#")] | ||
public void StringTestNoNamespace() | ||
{ | ||
var symbol = new ExternalTypeReference(null, new IdentifierSymbol("ETR1")); | ||
|
||
var transformed = Transform(symbol); | ||
|
||
Assert.Equal("ETR1", transformed.ToFullString()); | ||
} | ||
|
||
[Fact, Trait("Category", "Symbols"), | ||
Trait("Target Language", "C#")] | ||
public void StringTestWithNamespace() | ||
{ | ||
var symbol = new ExternalTypeReference(new IdentifierSymbol("Namespace"), new IdentifierSymbol("ETR1")); | ||
|
||
var transformed = Transform(symbol); | ||
|
||
Assert.Equal("Namespace.ETR1", transformed.ToFullString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/Silk.NET.SilkTouch.Emitter.Tests/InternalTypeReferenceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Immutable; | ||
using System.ComponentModel; | ||
using Silk.NET.SilkTouch.Symbols; | ||
using Xunit; | ||
|
||
namespace Silk.NET.SilkTouch.Emitter.Tests; | ||
|
||
public class InternalTypeReferenceTests : EmitterTest | ||
{ | ||
[Fact, Trait("Category", "Type Resolution"), Trait("Category", "Symbols")] | ||
public void StringTest() | ||
{ | ||
var typeStore = new TypeStore(); | ||
|
||
var typeId = TypeId.CreateNew(); | ||
var actualType = new StructSymbol | ||
(typeId, new IdentifierSymbol("Identifier"), ImmutableArray<FieldSymbol>.Empty); | ||
typeStore.Store(actualType); | ||
var symbol = new InternalTypeReference(typeId); | ||
|
||
var transformed = Transform(symbol, typeStore); | ||
|
||
Assert.Equal("Identifier", transformed.ToFullString()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/Silk.NET.SilkTouch.Emitter.Tests/PointerTypeReferenceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Silk.NET.SilkTouch.Symbols; | ||
using Xunit; | ||
|
||
namespace Silk.NET.SilkTouch.Emitter.Tests; | ||
|
||
public class PointerTypeReferenceTests : EmitterTest | ||
{ | ||
[Fact, Trait("Category", "Symbols")] | ||
public void StringTest() | ||
{ | ||
var symbol = new PointerTypeReference(new ExternalTypeReference(null, new IdentifierSymbol("ETR1"))); | ||
|
||
var transformed = Transform(symbol); | ||
|
||
Assert.Equal("ETR1*", transformed.ToFullString()); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
tests/Silk.NET.SilkTouch.Symbols.Tests/SymbolVisitorTests/InternalTypeReferenceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.ComponentModel; | ||
using Moq; | ||
using Moq.Protected; | ||
using Xunit; | ||
|
||
namespace Silk.NET.SilkTouch.Symbols.Tests.SymbolVisitorTests; | ||
|
||
public class InternalTypeReferenceTests | ||
{ | ||
[Fact, Trait("Category", "Symbols")] | ||
public void VisitedAsSelf() | ||
{ | ||
var symbol = new InternalTypeReference(TypeId.CreateNew()); | ||
|
||
var visitor = new Mock<MockSymbolVisitor> { CallBase = true }; | ||
|
||
visitor.Object.Visit(symbol); | ||
|
||
visitor.Protected() | ||
.Verify<InternalTypeReference> | ||
("VisitInternalTypeReference", Times.Once(), ItExpr.IsAny<InternalTypeReference>()); | ||
} | ||
|
||
[Fact, Trait("Category", "Symbols")] | ||
public void VisitedAsParent() | ||
{ | ||
var symbol = new InternalTypeReference(TypeId.CreateNew()); | ||
|
||
var visitor = new Mock<MockSymbolVisitor> { CallBase = true }; | ||
|
||
visitor.Object.Visit(symbol); | ||
|
||
visitor.Protected() | ||
.Verify<TypeReference> | ||
("VisitTypeReference", Times.Once(), ItExpr.IsAny<TypeReference>()); | ||
} | ||
|
||
|
||
[Fact, Trait("Category", "Symbols")] | ||
public void TypeIdIsVisited() | ||
{ | ||
var id = TypeId.CreateNew(); | ||
var symbol = new InternalTypeReference(id); | ||
|
||
var visitor = new Mock<MockSymbolVisitor> { CallBase = true }; | ||
|
||
visitor.Object.Visit(symbol); | ||
|
||
visitor.Protected().Verify<TypeId>("VisitTypeId", Times.Once(), ItExpr.Is<TypeId>(x => x == id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters