Skip to content

Commit

Permalink
chore: add simple tests for checking plugin version
Browse files Browse the repository at this point in the history
  • Loading branch information
MangelMaxime committed Nov 25, 2024
1 parent ef18e21 commit aa1a3aa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Fable.Transforms/Global/Compiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type InlineExprLazy(f: Compiler -> InlineExpr) =

[<AutoOpen>]
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+))?")

Expand Down
24 changes: 24 additions & 0 deletions tests/Integration/Compiler/CompilerHelpersTests.fs
Original file line number Diff line number Diff line change
@@ -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
]
3 changes: 2 additions & 1 deletion tests/Integration/Compiler/Fable.Tests.Compiler.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<Compile Include="Util/Compiler.fs" />
<Compile Include="CompilerMessagesTests.fs" />
<Compile Include="AnonRecordInInterfaceTests.fs" />
<Compile Include="CompilerHelpersTests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions tests/Integration/Compiler/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let allTests =
[
CompilerMessages.tests
AnonRecordInInterface.tests
CompilerHelpers.tests
]


Expand Down

0 comments on commit aa1a3aa

Please sign in to comment.