diff --git a/src/Fable.Transforms/Global/Compiler.fs b/src/Fable.Transforms/Global/Compiler.fs index a850b4ecc..ce425ec84 100644 --- a/src/Fable.Transforms/Global/Compiler.fs +++ b/src/Fable.Transforms/Global/Compiler.fs @@ -99,7 +99,7 @@ type InlineExprLazy(f: Compiler -> InlineExpr) = [] module CompilerExt = - let private expectedVersionMatchesActual (expected: string) (actual: string) = + let expectedVersionMatchesActual (expected: string) (actual: string) = try let r = System.Text.RegularExpressions.Regex(@"^(\d+)\.(\d+)(?:\.(\d+))?") diff --git a/tests/Integration/Compiler/CompilerHelpersTests.fs b/tests/Integration/Compiler/CompilerHelpersTests.fs new file mode 100644 index 000000000..edda34abc --- /dev/null +++ b/tests/Integration/Compiler/CompilerHelpersTests.fs @@ -0,0 +1,24 @@ +module Fable.Tests.Compiler.CompilerHelpers + +open Fable.Core +open Util.Testing +open Fable.Tests.Compiler.Util +open Fable.Tests.Compiler.Util.Compiler + +let tests = + testList "Compiler Helpers" [ + testCase "expectedVersionMatchesActual works for same major version" <| fun _ -> + Fable.CompilerExt.expectedVersionMatchesActual "5.0.0" "5.0.0" |> equal true + Fable.CompilerExt.expectedVersionMatchesActual "5.0.1" "5.0.0" |> equal true + Fable.CompilerExt.expectedVersionMatchesActual "5.1.0" "5.0.0" |> equal true + + testCase "expectedVersionMatchesActual works if actual version is highter than expected version" <| fun _ -> + Fable.CompilerExt.expectedVersionMatchesActual "4.0.0" "5.0.0" |> equal true + Fable.CompilerExt.expectedVersionMatchesActual "4.0.1" "5.0.0" |> equal true + Fable.CompilerExt.expectedVersionMatchesActual "4.1.0" "5.0.0" |> equal true + + testCase "expectedVersionMatchesActual reject if actual version is highter than expected version" <| fun _ -> + Fable.CompilerExt.expectedVersionMatchesActual "4.0.0" "3.0.0" |> equal true + Fable.CompilerExt.expectedVersionMatchesActual "4.0.1" "3.0.0" |> equal true + Fable.CompilerExt.expectedVersionMatchesActual "4.1.0" "3.0.0" |> equal true + ] diff --git a/tests/Integration/Compiler/Fable.Tests.Compiler.fsproj b/tests/Integration/Compiler/Fable.Tests.Compiler.fsproj index 096a4285c..573d04010 100644 --- a/tests/Integration/Compiler/Fable.Tests.Compiler.fsproj +++ b/tests/Integration/Compiler/Fable.Tests.Compiler.fsproj @@ -22,6 +22,7 @@ + - \ No newline at end of file + diff --git a/tests/Integration/Compiler/Main.fs b/tests/Integration/Compiler/Main.fs index 4011447b3..fbed235b9 100644 --- a/tests/Integration/Compiler/Main.fs +++ b/tests/Integration/Compiler/Main.fs @@ -7,6 +7,7 @@ let allTests = [ CompilerMessages.tests AnonRecordInInterface.tests + CompilerHelpers.tests ]