<commit_before>{-# LANGUAGE OverloadedStrings #-}
module Futhark.Pkg.SolveTests (tests) where

import qualified Data.Map as M
import qualified Data.Text as T
import Data.Monoid

import Test.Tasty
import Test.Tasty.HUnit

import Futhark.Pkg.Types
import Futhark.Pkg.Solve

semverE :: T.Text -> SemVer
semverE s = case semver s of
              Left err -> error $ T.unpack s <>
                          " is not a valid version number: " <>
                          parseErrorPretty err
              Right x -> x

-- | A world of packages and interdependencies for testing the solver
-- without touching the outside world.
testEnv :: PkgRevDepInfo
testEnv = M.fromList $ concatMap frob
  [ ("athas", [ ("foo", [ ("0.1.0", [])
                        , ("0.2.0", [("athas/bar", "1.0.0")])
                        , ("0.3.0", [])])
              , ("foo@v2", [ ("2.0.0", [("athas/quux", "0.1.0")])])
              , ("bar", [ ("1.0.0", [])])
              , ("baz", [ ("0.1.0", [("athas/foo", "0.3.0")])])
              , ("quux", [ ("0.1.0", [ ("athas/foo", "0.2.0")
                                     , ("athas/baz", "0.1.0") ])])<commit_msg>Fix solver tests.<commit_after>{-# LANGUAGE OverloadedStrings #-}
module Futhark.Pkg.SolveTests (tests) where

import qualified Data.Map as M
import qualified Data.Text as T
import Data.Monoid

import Test.Tasty
import Test.Tasty.HUnit

import Futhark.Pkg.Types
import Futhark.Pkg.Solve

import Prelude

semverE :: T.Text -> SemVer
semverE s = case parseVersion s of
              Left err -> error $ T.unpack s <>
                          " is not a valid version number: " <>
                          parseErrorPretty err
              Right x -> x

-- | A world of packages and interdependencies for testing the solver
-- without touching the outside world.
testEnv :: PkgRevDepInfo
testEnv = M.fromList $ concatMap frob
  [ ("athas", [ ("foo", [ ("0.1.0", [])
                        , ("0.2.0", [("athas/bar", "1.0.0")])
                        , ("0.3.0", [])])
              , ("foo@v2", [ ("2.0.0", [("athas/quux", "0.1.0")])])
              , ("bar", [ ("1.0.0", [])])
              , ("baz", [ ("0.1.0", [("athas/foo", "0.3.0")])])
              , ("quux", [ ("0.1.0", [ ("athas/foo", "0.2.0")
                                     , ("athas/baz", "0.1.0") ])])
{'fraction_non_alphanumeric': 0.18593615185504744, 'fraction_numerical': 0.03192407247627265, 'mean_word_length': 1.7839135654261704, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5268775', 'n_tokens_mistral': 818, 'n_tokens_neox': 792, 'n_words': 196}