From 92d48ded3a9fae776ba125f7ed6bd38d74a91a48 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Tue, 22 Aug 2023 18:39:08 +0800 Subject: [PATCH] Fsdk,Fsdk.Tests: add new ArgsParsing failing test --- Fsdk.Tests/ArgsParsing.fs | 16 ++++++++++++++++ Fsdk.Tests/Fsdk.Tests-legacy.fsproj | 1 + Fsdk.Tests/Fsdk.Tests.fsproj | 1 + Fsdk/Misc.fs | 7 +++++++ 4 files changed, 25 insertions(+) create mode 100644 Fsdk.Tests/ArgsParsing.fs diff --git a/Fsdk.Tests/ArgsParsing.fs b/Fsdk.Tests/ArgsParsing.fs new file mode 100644 index 00000000..1900d264 --- /dev/null +++ b/Fsdk.Tests/ArgsParsing.fs @@ -0,0 +1,16 @@ +namespace Fsdk.Tests + +open NUnit.Framework + +open Fsdk + +[] +type ArgsParsing() = + + [] + member __.``simplest flags usage``() = + let commandLine = "someProgram --someLongFlag1 -f2".Split(' ') + let res:Misc.ArgsParsed = Misc.ParseArgs commandLine + match res with + | Misc.ArgsParsed.OnlyFlags flags -> Assert.That(Seq.length flags, Is.EqualTo 2) + | _ -> Assert.Fail "res was not ArgsParsing.OnlyFlags subtype" diff --git a/Fsdk.Tests/Fsdk.Tests-legacy.fsproj b/Fsdk.Tests/Fsdk.Tests-legacy.fsproj index 33ebcd3d..e192b144 100644 --- a/Fsdk.Tests/Fsdk.Tests-legacy.fsproj +++ b/Fsdk.Tests/Fsdk.Tests-legacy.fsproj @@ -46,6 +46,7 @@ + diff --git a/Fsdk.Tests/Fsdk.Tests.fsproj b/Fsdk.Tests/Fsdk.Tests.fsproj index 3e9ab5c7..87884262 100644 --- a/Fsdk.Tests/Fsdk.Tests.fsproj +++ b/Fsdk.Tests/Fsdk.Tests.fsproj @@ -8,6 +8,7 @@ + diff --git a/Fsdk/Misc.fs b/Fsdk/Misc.fs index 174a9e74..36a4d7d7 100644 --- a/Fsdk/Misc.fs +++ b/Fsdk/Misc.fs @@ -94,6 +94,13 @@ module Misc = args #endif + type ArgsParsed = + | OnlyFlags of seq + | BothFlags of seq*string*seq + + let ParseArgs (_args: array): ArgsParsed = + failwith "NIE" + let FsxOnlyArguments() = let cmdLineArgs = Environment.GetCommandLineArgs() |> List.ofSeq #if !LEGACY_FRAMEWORK