-
-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create & Test Namespace Symbol (#912)
- Loading branch information
1 parent
5f5d836
commit 5e609aa
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/generators/Silk.NET.SilkTouch.Symbols/NamespaceSymbol.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,13 @@ | ||
// 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; | ||
|
||
namespace Silk.NET.SilkTouch.Symbols; | ||
|
||
/// <summary> | ||
/// A <see cref="Symbol"/> representing a <c>namespace</c> | ||
/// </summary> | ||
public sealed record NamespaceSymbol(IdentifierSymbol Identifier, ImmutableArray<TypeSymbol> Types) : Symbol | ||
{ | ||
} |
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
47 changes: 47 additions & 0 deletions
47
tests/Silk.NET.SilkTouch.Symbols.Tests/SymbolVisitorTests/NamespaceTests.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,47 @@ | ||
// 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 Moq; | ||
using Moq.Protected; | ||
using Xunit; | ||
|
||
namespace Silk.NET.SilkTouch.Symbols.Tests.SymbolVisitorTests; | ||
|
||
public class NamespaceTests | ||
{ | ||
[Fact] | ||
public void NamespaceIdentifierIsVisited() | ||
{ | ||
var symbol = new NamespaceSymbol(new IdentifierSymbol(""), ImmutableArray<TypeSymbol>.Empty); | ||
|
||
var visitor = new Mock<SymbolVisitor> | ||
{ | ||
CallBase = true | ||
}; | ||
|
||
visitor.Object.Visit(symbol); | ||
|
||
visitor.Protected() | ||
.Verify<IdentifierSymbol>("VisitIdentifier", Times.Once(), ItExpr.IsAny<IdentifierSymbol>()); | ||
} | ||
|
||
[Fact] | ||
public void NamespaceMemberIsVisited() | ||
{ | ||
var symbol = new NamespaceSymbol(new IdentifierSymbol(""), new [] | ||
{ | ||
(TypeSymbol)new StructSymbol(new IdentifierSymbol(""), StructLayout.Empty) | ||
}.ToImmutableArray()); | ||
|
||
var visitor = new Mock<SymbolVisitor> | ||
{ | ||
CallBase = true | ||
}; | ||
|
||
visitor.Object.Visit(symbol); | ||
|
||
visitor.Protected() | ||
.Verify<StructSymbol>("VisitStruct", Times.Once(), ItExpr.IsAny<StructSymbol>()); | ||
} | ||
} |