1. Haskell / Говнокод #24452

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    instance Arbitrary ProjectConfig where
        arbitrary =
          ProjectConfig
            <$> (map getPackageLocationString <$> arbitrary)
            <*> (map getPackageLocationString <$> arbitrary)
            <*> shortListOf 3 arbitrary
            <*> arbitrary
            <*> arbitrary
            <*> arbitrary
            <*> arbitrary
            <*> arbitrary
            <*> arbitrary
            <*> (MapMappend . fmap getNonMEmpty . Map.fromList
                   <$> shortListOf 3 arbitrary)
            -- package entries with no content are equivalent to
            -- the entry not existing at all, so exclude empty
    
        shrink ProjectConfig { projectPackages = x0
                             , projectPackagesOptional = x1
                             , projectPackagesRepo = x2
                             , projectPackagesNamed = x3
                             , projectConfigBuildOnly = x4
                             , projectConfigShared = x5
                             , projectConfigProvenance = x6
                             , projectConfigLocalPackages = x7
                             , projectConfigSpecificPackage = x8
                             , projectConfigAllPackages = x9 } =
          [ ProjectConfig { projectPackages = x0'
                          , projectPackagesOptional = x1'
                          , projectPackagesRepo = x2'
                          , projectPackagesNamed = x3'
                          , projectConfigBuildOnly = x4'
                          , projectConfigShared = x5'
                          , projectConfigProvenance = x6'
                          , projectConfigLocalPackages = x7'
                          , projectConfigSpecificPackage = (MapMappend
                                                             (fmap getNonMEmpty x8'))
                          , projectConfigAllPackages = x9' }
          | ((x0', x1', x2', x3'), (x4', x5', x6', x7', x8', x9'))
              <- shrink ((x0, x1, x2, x3),
                          (x4, x5, x6, x7, fmap NonMEmpty (getMapMappend x8), x9))
          ]

    В хачкеле мало бойлерплейта, говорили они. Это ещё далеко не самый длинный список, см. x43 ниже.

    https://github.com/haskell/cabal/blob/4e0c701a2feb520d369ef506a18288c47f64b06a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs

    Запостил: roman-kashitsyn, 06 Июля 2018

    Комментарии (4) RSS

    Добавить комментарий