Play

Check-in [28d1fb8fd8]
Login
Overview
Comment:On second thought, better be strict with semantic versioning.
Timelines: family | ancestors | descendants | both | modules
Files: files | file ages | folders
SHA3-256: 28d1fb8fd8ae0539b15c164f0b8720b576007e23b8737cca1cf226441264f940
User & Date: robin.hansen on 2021-02-14 10:43:07
Other Links: branch diff | manifest | tags
Context
2021-02-14
10:59
SemanticVersion now returns descriptive error messages. check-in: 635fab0eeb user: robin.hansen tags: modules
10:43
On second thought, better be strict with semantic versioning. check-in: 28d1fb8fd8 user: robin.hansen tags: modules
2021-02-13
10:20
Implement conversion from String to ModuleName. check-in: ddeb331151 user: robin.hansen tags: modules
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified src/Play/Data/SemanticVersion.elm from [8d8ba8498e] to [92b365e1e7].

     7      7   type SemanticVersion
     8      8       = SemanticVersion Int Int Int
     9      9   
    10     10   
    11     11   fromString : String -> Result () SemanticVersion
    12     12   fromString str =
    13     13       case String.split "." str of
    14         -        [ major ] ->
    15         -            toInt major Nothing Nothing
    16         -
    17         -        [ major, minor ] ->
    18         -            toInt major (Just minor) Nothing
    19         -
    20     14           [ major, minor, patch ] ->
    21         -            toInt major (Just minor) (Just patch)
           15  +            toInt major minor patch
    22     16   
    23     17           _ ->
    24     18               Err ()
    25     19   
    26     20   
    27         -toInt : String -> Maybe String -> Maybe String -> Result () SemanticVersion
    28         -toInt majorStr maybeMinorStr maybePatchStr =
           21  +toInt : String -> String -> String -> Result () SemanticVersion
           22  +toInt majorStr minorStr patchStr =
    29     23       let
    30         -        minorStr =
    31         -            Maybe.withDefault "0" maybeMinorStr
    32         -
    33         -        patchStr =
    34         -            Maybe.withDefault "0" maybePatchStr
    35         -
    36     24           intVersions =
    37     25               [ majorStr, minorStr, patchStr ]
    38     26                   |> List.filterMap String.toInt
    39     27       in
    40     28       case intVersions of
    41     29           [ major, minor, patch ] ->
    42     30               if major < 0 || minor < 0 || patch < 0 then

Modified tests/Test/Data/SemanticVersion.elm from [8794572d0d] to [7aa88bfaa0].

     8      8   
     9      9   suite : Test
    10     10   suite =
    11     11       describe "SemanticVersion"
    12     12           [ test "Valid versions" <|
    13     13               \_ ->
    14     14                   PlayExpect.allOk SemanticVersion.fromString
    15         -                    [ "1"
    16         -                    , "1.2"
    17         -                    , "1.2.3"
           15  +                    [ "1.2.3"
    18     16                       , "10.100.1000"
    19     17                       , "0.0.1"
    20     18                       , "0.1.0"
    21     19                       ]
    22     20           , test "Cannot contain more than three parts" <|
    23     21               \_ ->
    24     22                   SemanticVersion.fromString "1.2.3.4"
    25     23                       |> Expect.err
           24  +        , test "Cannot contain less than three parts" <|
           25  +            \_ ->
           26  +                PlayExpect.allErr SemanticVersion.fromString
           27  +                    [ "1"
           28  +                    , "1.2"
           29  +                    ]
    26     30           , test "Cannot be empty string" <|
    27     31               \_ ->
    28     32                   SemanticVersion.fromString ""
    29     33                       |> Expect.err
    30     34           , test "Must be numbers" <|
    31     35               \_ ->
    32     36                   PlayExpect.allErr SemanticVersion.fromString
    33     37                       [ "A"
    34     38                       , "*"
    35     39                       , "~"
    36     40                       , "1.0.x"
           41  +                    , "1.0.~"
    37     42                       , "~1.0.0"
    38     43                       , "1.0.0-alpha1"
    39     44                       , "alpha.1"
    40     45                       ]
    41     46           , test "Minimum version is 0.0.1" <|
    42     47               \_ ->
    43     48                   SemanticVersion.fromString "0.0.0"
    44     49                       |> Expect.err
    45     50           , test "Cannot contain negative versions" <|
    46     51               \_ ->
    47     52                   PlayExpect.allErr SemanticVersion.fromString
    48         -                    [ "-1"
    49         -                    , "-1.2"
           53  +                    [ "-1.0.0"
    50     54                       , "1.-2.0"
           55  +                    , "1.2.-1"
    51     56                       ]
    52     57           ]