mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-10 20:00:27 +03:00
add unison-util-relation test suite
This commit is contained in:
parent
b46f84491a
commit
023a86c585
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -85,3 +85,5 @@ jobs:
|
|||||||
x=`git status --porcelain -uno` bash -c 'if [[ -n $x ]]; then echo "$x" && false; fi'
|
x=`git status --porcelain -uno` bash -c 'if [[ -n $x ]]; then echo "$x" && false; fi'
|
||||||
- name: prettyprint-round-trip
|
- name: prettyprint-round-trip
|
||||||
run: stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md
|
run: stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md
|
||||||
|
- name: other test suites
|
||||||
|
run: stack --no-terminal test union-util-relation
|
||||||
|
28
hie.yaml
28
hie.yaml
@ -1,33 +1,39 @@
|
|||||||
cradle:
|
cradle:
|
||||||
stack:
|
stack:
|
||||||
- path: "codebase2/codebase"
|
- path: "codebase2/codebase/./"
|
||||||
component: "unison-codebase:lib"
|
component: "unison-codebase:lib"
|
||||||
|
|
||||||
- path: "codebase2/codebase-sqlite"
|
- path: "codebase2/codebase-sqlite/./"
|
||||||
component: "unison-codebase-sqlite:lib"
|
component: "unison-codebase-sqlite:lib"
|
||||||
|
|
||||||
- path: "codebase2/codebase-sync"
|
- path: "codebase2/codebase-sync/./"
|
||||||
component: "unison-codebase-sync:lib"
|
component: "unison-codebase-sync:lib"
|
||||||
|
|
||||||
- path: "codebase2/core"
|
- path: "codebase2/core/./"
|
||||||
component: "unison-core:lib"
|
component: "unison-core:lib"
|
||||||
|
|
||||||
- path: "codebase2/util"
|
- path: "codebase2/util/./"
|
||||||
component: "unison-util:lib"
|
component: "unison-util:lib"
|
||||||
|
|
||||||
- path: "codebase2/util-serialization"
|
- path: "codebase2/util-serialization/./"
|
||||||
component: "unison-util-serialization:lib"
|
component: "unison-util-serialization:lib"
|
||||||
|
|
||||||
- path: "codebase2/util-term"
|
- path: "codebase2/util-term/./"
|
||||||
component: "unison-util-term:lib"
|
component: "unison-util-term:lib"
|
||||||
|
|
||||||
|
- path: "lib/unison-prelude/src"
|
||||||
|
component: "unison-prelude:lib"
|
||||||
|
|
||||||
|
- path: "lib/unison-util-relation/src"
|
||||||
|
component: "unison-util-relation:lib"
|
||||||
|
|
||||||
|
- path: "lib/unison-util-relation/test"
|
||||||
|
component: "unison-util-relation:test:tests"
|
||||||
|
|
||||||
- path: "parser-typechecker/src"
|
- path: "parser-typechecker/src"
|
||||||
component: "unison-parser-typechecker:lib"
|
component: "unison-parser-typechecker:lib"
|
||||||
|
|
||||||
- path: "parser-typechecker/prettyprintdemo/Main.hs"
|
- path: "parser-typechecker/prettyprintdemo"
|
||||||
component: "unison-parser-typechecker:exe:prettyprintdemo"
|
|
||||||
|
|
||||||
- path: "parser-typechecker/prettyprintdemo/Paths_unison_parser_typechecker.hs"
|
|
||||||
component: "unison-parser-typechecker:exe:prettyprintdemo"
|
component: "unison-parser-typechecker:exe:prettyprintdemo"
|
||||||
|
|
||||||
- path: "parser-typechecker/tests"
|
- path: "parser-typechecker/tests"
|
||||||
|
@ -5,6 +5,15 @@ copyright: Copyright (C) 2013-2021 Unison Computing, PBC and contributors
|
|||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
|
|
||||||
|
tests:
|
||||||
|
tests:
|
||||||
|
dependencies:
|
||||||
|
- easytest
|
||||||
|
- random
|
||||||
|
- unison-util-relation
|
||||||
|
main: Main.hs
|
||||||
|
source-dirs: test
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- base
|
- base
|
||||||
- containers
|
- containers
|
||||||
|
37
lib/unison-util-relation/test/Main.hs
Normal file
37
lib/unison-util-relation/test/Main.hs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
|
import EasyTest
|
||||||
|
import System.Random (Random)
|
||||||
|
import qualified Unison.Util.Relation as Relation
|
||||||
|
import Unison.Util.Relation3 (Relation3)
|
||||||
|
import qualified Unison.Util.Relation3 as Relation3
|
||||||
|
import Unison.Util.Relation4 (Relation4)
|
||||||
|
import qualified Unison.Util.Relation4 as Relation4
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main =
|
||||||
|
run do
|
||||||
|
scope "Relation3" do
|
||||||
|
scope "d12 works" do
|
||||||
|
r3 <- randomR3 @Char @Char @Char 1000
|
||||||
|
let d12 = Relation.fromList . map (\(a, b, _) -> (a, b)) . Relation3.toList
|
||||||
|
expectEqual (Relation3.d12 r3) (d12 r3)
|
||||||
|
|
||||||
|
scope "d13 works" do
|
||||||
|
r3 <- randomR3 @Char @Char @Char 1000
|
||||||
|
let d13 = Relation.fromList . map (\(a, _, c) -> (a, c)) . Relation3.toList
|
||||||
|
expectEqual (Relation3.d13 r3) (d13 r3)
|
||||||
|
|
||||||
|
scope "Relation4" do
|
||||||
|
scope "d124 works" do
|
||||||
|
r4 <- randomR4 @Char @Char @Char @Char 1000
|
||||||
|
let d124 = Relation3.fromList . map (\(a, b, _, d) -> (a, b, d)) . Relation4.toList
|
||||||
|
expectEqual (Relation4.d124 r4) (d124 r4)
|
||||||
|
|
||||||
|
randomR3 :: (Ord a, Random a, Ord b, Random b, Ord c, Random c) => Int -> Test (Relation3 a b c)
|
||||||
|
randomR3 n =
|
||||||
|
Relation3.fromList <$> listOf n tuple3
|
||||||
|
|
||||||
|
randomR4 :: (Ord a, Random a, Ord b, Random b, Ord c, Random c, Ord d, Random d) => Int -> Test (Relation4 a b c d)
|
||||||
|
randomR4 n =
|
||||||
|
Relation4.fromList <$> listOf n tuple4
|
@ -46,3 +46,36 @@ library
|
|||||||
, extra
|
, extra
|
||||||
, unison-prelude
|
, unison-prelude
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
test-suite tests
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_unison_util_relation
|
||||||
|
hs-source-dirs:
|
||||||
|
test
|
||||||
|
default-extensions:
|
||||||
|
ApplicativeDo
|
||||||
|
BlockArguments
|
||||||
|
DeriveFunctor
|
||||||
|
DerivingStrategies
|
||||||
|
DoAndIfThenElse
|
||||||
|
FlexibleContexts
|
||||||
|
FlexibleInstances
|
||||||
|
LambdaCase
|
||||||
|
MultiParamTypeClasses
|
||||||
|
NamedFieldPuns
|
||||||
|
ScopedTypeVariables
|
||||||
|
TupleSections
|
||||||
|
TypeApplications
|
||||||
|
ViewPatterns
|
||||||
|
ghc-options: -Wall
|
||||||
|
build-depends:
|
||||||
|
base
|
||||||
|
, containers
|
||||||
|
, easytest
|
||||||
|
, extra
|
||||||
|
, random
|
||||||
|
, unison-prelude
|
||||||
|
, unison-util-relation
|
||||||
|
default-language: Haskell2010
|
||||||
|
@ -296,6 +296,21 @@ listsOf sizes gen = sizes `forM` \n -> listOf n gen
|
|||||||
pair :: Test a -> Test b -> Test (a,b)
|
pair :: Test a -> Test b -> Test (a,b)
|
||||||
pair = liftA2 (,)
|
pair = liftA2 (,)
|
||||||
|
|
||||||
|
-- | Alias for 'pair'.
|
||||||
|
tuple2 :: (Random a, Random b) => Test (a, b)
|
||||||
|
tuple2 =
|
||||||
|
(,) <$> random <*> random
|
||||||
|
|
||||||
|
-- | Generate a random 3-tuple.
|
||||||
|
tuple3 :: (Random a, Random b, Random c) => Test (a, b, c)
|
||||||
|
tuple3 =
|
||||||
|
(,,) <$> random <*> random <*> random
|
||||||
|
|
||||||
|
-- | Generate a random 4-tuple.
|
||||||
|
tuple4 :: (Random a, Random b, Random c, Random d) => Test (a, b, c, d)
|
||||||
|
tuple4 =
|
||||||
|
(,,,) <$> random <*> random <*> random <*> random
|
||||||
|
|
||||||
-- | Generate a `Data.Map k v` of the given size.
|
-- | Generate a `Data.Map k v` of the given size.
|
||||||
mapOf :: Ord k => Int -> Test k -> Test v -> Test (Map k v)
|
mapOf :: Ord k => Int -> Test k -> Test v -> Test (Map k v)
|
||||||
mapOf n k v = Map.fromList <$> listOf n (pair k v)
|
mapOf n k v = Map.fromList <$> listOf n (pair k v)
|
||||||
|
Loading…
Reference in New Issue
Block a user