mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 10:35:57 +03:00
Basic model of test framework
This commit is contained in:
parent
7637859b90
commit
41baba00ca
@ -2,6 +2,14 @@
|
||||
use Universal == < > >=
|
||||
use Optional None Some
|
||||
|
||||
-- Function composition
|
||||
(.) : (b -> c) -> (a -> b) -> a -> c
|
||||
(.) f g x = f (g x)
|
||||
|
||||
-- Function composition
|
||||
andThen : (a -> b) -> (b -> c) -> a -> c
|
||||
andThen f g x = g (f x)
|
||||
|
||||
namespace Sequence where
|
||||
|
||||
map : (a -> b) -> [a] -> [b]
|
||||
|
48
unison-src/EasyTest.u
Normal file
48
unison-src/EasyTest.u
Normal file
@ -0,0 +1,48 @@
|
||||
type Status = Failed | Expected Success | Unexpected Success | Pending | Indeterminate
|
||||
type Success = Passed Nat | Proved
|
||||
|
||||
use Status Failed Expected Unexpected Pending Indeterminate
|
||||
use Success Passed Proved
|
||||
|
||||
ability Test where
|
||||
finish : Status -> {Test} a
|
||||
path : {Test} [Text]
|
||||
|
||||
Status.combine : Status -> Status -> Status
|
||||
Status.combine s1 s2 = case (s1, s2) of
|
||||
(_, Pending) -> Pending
|
||||
(Pending, _) -> Pending
|
||||
(Failed, _) -> Failed
|
||||
(_, Failed) -> Failed
|
||||
(Indeterminate, _) -> Indeterminate
|
||||
(_, Indeterminate) -> Indeterminate
|
||||
(Expected a, Expected b) -> Expected (combine a b)
|
||||
|
||||
Status.pending : Status -> Status
|
||||
Status.pending s = case s of
|
||||
Failed -> Pending
|
||||
Expected s -> Unexpected s
|
||||
Unexpected s -> Pending
|
||||
Pending -> Pending
|
||||
Indeterminate -> Indeterminate
|
||||
|
||||
getStatus : '{Test} a -> {Test} Status
|
||||
getStatus t =
|
||||
go req = case req of
|
||||
{Test.finish s -> k} -> s
|
||||
{Test.path -> k} -> handle go in k Test.path
|
||||
{a} -> Indeterminate
|
||||
handle go in !t
|
||||
|
||||
(.) : (b -> c) -> (a -> b) -> a -> c
|
||||
(.) f g x = f (g x)
|
||||
|
||||
Test.pending : '{Test} a -> {Test} (Optional a)
|
||||
Test.pending = finish . pending . getStatus
|
||||
|
||||
Success.combine s1 s2 = case (s1, s2) of
|
||||
(Passed n, Passed m) -> Passed (n + m)
|
||||
(Passed n, Proved) -> Passed n
|
||||
(Proved, Passed n) -> Passed n
|
||||
(Proved, Proved) -> Proved
|
||||
|
11
unison-src/errors/poor-error-message/pattern-case-location.u
Normal file
11
unison-src/errors/poor-error-message/pattern-case-location.u
Normal file
@ -0,0 +1,11 @@
|
||||
-- The location of the error is imprecise. It should point to
|
||||
-- the pattern `Bar.Bar`.
|
||||
|
||||
unique type Foo = Foo
|
||||
unique type Bar = Bar
|
||||
|
||||
foo : Foo -> Foo
|
||||
foo x = case x of
|
||||
Foo.Foo -> Foo
|
||||
Bar.Bar -> Foo
|
||||
|
Loading…
Reference in New Issue
Block a user