mirror of
https://github.com/Smaug123/WoofWare.Whippet
synced 2025-10-05 15:58:39 +00:00
Add type printing for App (#33)
Some checks are pending
.NET / check-dotnet-format (push) Waiting to run
.NET / check-nix-format (push) Waiting to run
.NET / Check links (push) Waiting to run
.NET / Check flake (push) Waiting to run
.NET / nuget-pack (push) Waiting to run
.NET / build (Debug) (push) Waiting to run
.NET / build (Release) (push) Waiting to run
.NET / analyzers (push) Waiting to run
.NET / expected-pack (push) Blocked by required conditions
.NET / check-accurate-generations (push) Waiting to run
.NET / all-required-checks-complete (push) Blocked by required conditions
.NET / nuget-publish (push) Blocked by required conditions
.NET / nuget-publish-core (push) Blocked by required conditions
.NET / nuget-publish-fantomas (push) Blocked by required conditions
.NET / nuget-publish-json-plugin (push) Blocked by required conditions
.NET / nuget-publish-json-attrs (push) Blocked by required conditions
.NET / nuget-publish-argparser-plugin (push) Blocked by required conditions
.NET / nuget-publish-argparser-attrs (push) Blocked by required conditions
.NET / nuget-publish-httpclient-plugin (push) Blocked by required conditions
.NET / nuget-publish-httpclient-attrs (push) Blocked by required conditions
.NET / nuget-publish-interfacemock-plugin (push) Blocked by required conditions
.NET / nuget-publish-interfacemock-attrs (push) Blocked by required conditions
.NET / nuget-publish-swagger-plugin (push) Blocked by required conditions
Some checks are pending
.NET / check-dotnet-format (push) Waiting to run
.NET / check-nix-format (push) Waiting to run
.NET / Check links (push) Waiting to run
.NET / Check flake (push) Waiting to run
.NET / nuget-pack (push) Waiting to run
.NET / build (Debug) (push) Waiting to run
.NET / build (Release) (push) Waiting to run
.NET / analyzers (push) Waiting to run
.NET / expected-pack (push) Blocked by required conditions
.NET / check-accurate-generations (push) Waiting to run
.NET / all-required-checks-complete (push) Blocked by required conditions
.NET / nuget-publish (push) Blocked by required conditions
.NET / nuget-publish-core (push) Blocked by required conditions
.NET / nuget-publish-fantomas (push) Blocked by required conditions
.NET / nuget-publish-json-plugin (push) Blocked by required conditions
.NET / nuget-publish-json-attrs (push) Blocked by required conditions
.NET / nuget-publish-argparser-plugin (push) Blocked by required conditions
.NET / nuget-publish-argparser-attrs (push) Blocked by required conditions
.NET / nuget-publish-httpclient-plugin (push) Blocked by required conditions
.NET / nuget-publish-httpclient-attrs (push) Blocked by required conditions
.NET / nuget-publish-interfacemock-plugin (push) Blocked by required conditions
.NET / nuget-publish-interfacemock-attrs (push) Blocked by required conditions
.NET / nuget-publish-swagger-plugin (push) Blocked by required conditions
This commit is contained in:
38
WoofWare.Whippet.Fantomas.Test/TestSynType.fs
Normal file
38
WoofWare.Whippet.Fantomas.Test/TestSynType.fs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace WoofWare.Whippet.Fantomas.Test
|
||||
|
||||
open Fantomas.FCS.Syntax
|
||||
open Fantomas.FCS.Text
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
open WoofWare.Whippet.Fantomas
|
||||
open Fantomas.FCS
|
||||
|
||||
[<TestFixture>]
|
||||
module TestSynType =
|
||||
let typeToStringCases =
|
||||
[ "string", "string" ; "ResizeArray<int>", "ResizeArray<int32>" ]
|
||||
|> List.map TestCaseData
|
||||
|
||||
[<TestCaseSource(nameof typeToStringCases)>]
|
||||
let ``Snapshot tests for SynType.toHumanReadableString`` (fsharpTypeString : string, expected : string) =
|
||||
let parsed, diags =
|
||||
Parse.parseFile false (SourceText.ofString $"let x : %s{fsharpTypeString} = failwith \"\"") []
|
||||
|
||||
diags |> shouldBeEmpty
|
||||
|
||||
let (SynModuleOrNamespace (decls = parsed)) =
|
||||
match parsed with
|
||||
| ParsedInput.ImplFile parsedImplFileInput -> parsedImplFileInput.Contents.[0]
|
||||
| ParsedInput.SigFile _ -> failwith "logic error"
|
||||
|
||||
let (SynBinding (expr = parsed)) =
|
||||
match List.exactlyOne parsed with
|
||||
| SynModuleDecl.Let (bindings = bindings) -> bindings.[0]
|
||||
| _ -> failwith "logic error"
|
||||
|
||||
let ty =
|
||||
match parsed with
|
||||
| SynExpr.Typed (targetType = targetType) -> targetType
|
||||
| _ -> failwith $"logic error: %O{parsed}"
|
||||
|
||||
SynType.toHumanReadableString ty |> shouldEqual expected
|
@@ -9,10 +9,12 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="TestSurface.fs" />
|
||||
<Compile Include="TestSynType.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ApiSurface" Version="4.1.5" />
|
||||
<PackageReference Include="FsUnit" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
|
||||
<PackageReference Include="NUnit" Version="4.2.2"/>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
|
||||
|
Reference in New Issue
Block a user