mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 10:35:57 +03:00
cleanup
This commit is contained in:
parent
a987756b41
commit
5a7e3b4932
@ -1,12 +1,3 @@
|
|||||||
|
|
||||||
```ucm:hide
|
|
||||||
.> builtins.merge
|
|
||||||
.> builtins.mergeio
|
|
||||||
.> load unison-src/transcripts-using-base/base.u
|
|
||||||
.> add
|
|
||||||
.> find
|
|
||||||
```
|
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
unique type EncDec = EncDec Text (Nat -> Bytes) (Bytes -> Optional (Nat, Bytes))
|
unique type EncDec = EncDec Text (Nat -> Bytes) (Bytes -> Optional (Nat, Bytes))
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
```unison
|
```unison
|
||||||
unique type EncDec = EncDec Text (Nat -> Bytes) (Bytes -> Optional (Nat, Bytes))
|
unique type EncDec = EncDec Text (Nat -> Bytes) (Bytes -> Optional (Nat, Bytes))
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
|
|
||||||
Test for code serialization operations.
|
Test for code serialization operations.
|
||||||
|
|
||||||
```ucm:hide
|
|
||||||
.> builtins.merge
|
|
||||||
```
|
|
||||||
|
|
||||||
Define a function, serialize it, then deserialize it back to an actual
|
Define a function, serialize it, then deserialize it back to an actual
|
||||||
function. Also ask for its dependencies for display later.
|
function. Also ask for its dependencies for display later.
|
||||||
|
|
||||||
@ -138,8 +134,8 @@ verified name link =
|
|||||||
with handleTest ("verified " ++ name)
|
with handleTest ("verified " ++ name)
|
||||||
|
|
||||||
rejected : Text -> [(Link.Term,Code)] ->{io2.IO} Result
|
rejected : Text -> [(Link.Term,Code)] ->{io2.IO} Result
|
||||||
rejected name rco =
|
rejected name rco =
|
||||||
handle verify name rco
|
handle verify name rco
|
||||||
with expectFailure ("rejected " ++ name)
|
with expectFailure ("rejected " ++ name)
|
||||||
|
|
||||||
missed : Text -> Link.Term -> Result
|
missed : Text -> Link.Term -> Result
|
||||||
|
@ -134,8 +134,8 @@ verified name link =
|
|||||||
with handleTest ("verified " ++ name)
|
with handleTest ("verified " ++ name)
|
||||||
|
|
||||||
rejected : Text -> [(Link.Term,Code)] ->{io2.IO} Result
|
rejected : Text -> [(Link.Term,Code)] ->{io2.IO} Result
|
||||||
rejected name rco =
|
rejected name rco =
|
||||||
handle verify name rco
|
handle verify name rco
|
||||||
with expectFailure ("rejected " ++ name)
|
with expectFailure ("rejected " ++ name)
|
||||||
|
|
||||||
missed : Text -> Link.Term -> Result
|
missed : Text -> Link.Term -> Result
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
# Computable documents in Unison
|
# Computable documents in Unison
|
||||||
|
|
||||||
```ucm:hide
|
|
||||||
.> builtins.mergeio
|
|
||||||
```
|
|
||||||
|
|
||||||
Unison documentation is written in Unison and has some neat features:
|
Unison documentation is written in Unison and has some neat features:
|
||||||
|
|
||||||
* The documentation type provides a rich vocabulary of elements that go beyond markdown, including asides, callouts, tooltips, and more.
|
* The documentation type provides a rich vocabulary of elements that go beyond markdown, including asides, callouts, tooltips, and more.
|
||||||
|
@ -6,10 +6,6 @@ Exception ability directly, and the last is code validation. I don't
|
|||||||
have an easy way to test the last at the moment, but the other two are
|
have an easy way to test the last at the moment, but the other two are
|
||||||
tested here.
|
tested here.
|
||||||
|
|
||||||
```ucm:hide
|
|
||||||
.> builtins.mergeio
|
|
||||||
```
|
|
||||||
|
|
||||||
```unison
|
```unison
|
||||||
test1 : '{IO, Exception} [Result]
|
test1 : '{IO, Exception} [Result]
|
||||||
test1 = do
|
test1 = do
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
```ucm:hide
|
|
||||||
.> builtins.mergeio
|
|
||||||
```
|
|
||||||
|
|
||||||
Tests some capabilities for catching runtime exceptions.
|
|
||||||
|
|
||||||
```unison
|
|
||||||
catcher : '{IO} () ->{IO} Result
|
|
||||||
catcher act =
|
|
||||||
handle tryEval act with cases
|
|
||||||
{ raise _ -> _ } -> Ok "caught"
|
|
||||||
{ _ } -> Fail "nothing to catch"
|
|
||||||
|
|
||||||
tests _ =
|
|
||||||
[ catcher do
|
|
||||||
_ = 1/0
|
|
||||||
()
|
|
||||||
, catcher '(bug "testing")
|
|
||||||
, handle tryEval (do 1+1) with cases
|
|
||||||
{ raise _ -> _ } -> Fail "1+1 failed"
|
|
||||||
{ 2 } -> Ok "got the right answer"
|
|
||||||
{ _ } -> Fail "got the wrong answer"
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
```ucm
|
|
||||||
.> add
|
|
||||||
.> io.test tests
|
|
||||||
```
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
|||||||
Tests some capabilities for catching runtime exceptions.
|
|
||||||
|
|
||||||
```unison
|
|
||||||
catcher : '{IO} () ->{IO} Result
|
|
||||||
catcher act =
|
|
||||||
handle tryEval act with cases
|
|
||||||
{ raise _ -> _ } -> Ok "caught"
|
|
||||||
{ _ } -> Fail "nothing to catch"
|
|
||||||
|
|
||||||
tests _ =
|
|
||||||
[ catcher do
|
|
||||||
_ = 1/0
|
|
||||||
()
|
|
||||||
, catcher '(bug "testing")
|
|
||||||
, handle tryEval (do 1+1) with cases
|
|
||||||
{ raise _ -> _ } -> Fail "1+1 failed"
|
|
||||||
{ 2 } -> Ok "got the right answer"
|
|
||||||
{ _ } -> Fail "got the wrong answer"
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
```ucm
|
|
||||||
|
|
||||||
Loading changes detected in scratch.u.
|
|
||||||
|
|
||||||
I found and typechecked these definitions in scratch.u. If you
|
|
||||||
do an `add` or `update`, here's how your codebase would
|
|
||||||
change:
|
|
||||||
|
|
||||||
⍟ These new definitions are ok to `add`:
|
|
||||||
|
|
||||||
catcher : '{IO} () ->{IO} Result
|
|
||||||
tests : ∀ _. _ ->{IO} [Result]
|
|
||||||
|
|
||||||
```
|
|
||||||
```ucm
|
|
||||||
.> add
|
|
||||||
|
|
||||||
⍟ I've added these definitions:
|
|
||||||
|
|
||||||
catcher : '{IO} () ->{IO} Result
|
|
||||||
tests : ∀ _. _ ->{IO} [Result]
|
|
||||||
|
|
||||||
.> io.test tests
|
|
||||||
|
|
||||||
New test results:
|
|
||||||
|
|
||||||
◉ tests caught
|
|
||||||
◉ tests caught
|
|
||||||
◉ tests got the right answer
|
|
||||||
|
|
||||||
✅ 3 test(s) passing
|
|
||||||
|
|
||||||
Tip: Use view tests to view the source of a test.
|
|
||||||
|
|
||||||
```
|
|
@ -1,12 +1,5 @@
|
|||||||
# Tests for TLS builtins
|
# Tests for TLS builtins
|
||||||
|
|
||||||
```ucm:hide
|
|
||||||
.> builtins.merge
|
|
||||||
.> builtins.mergeio
|
|
||||||
.> load unison-src/transcripts-using-base/base.u
|
|
||||||
.> add
|
|
||||||
```
|
|
||||||
|
|
||||||
```unison:hide
|
```unison:hide
|
||||||
-- generated with:
|
-- generated with:
|
||||||
-- openssl req -newkey rsa:2048 -subj '/CN=test.unison.cloud/O=Unison/C=US' -nodes -keyout key.pem -x509 -days 3650 -out cert.pem
|
-- openssl req -newkey rsa:2048 -subj '/CN=test.unison.cloud/O=Unison/C=US' -nodes -keyout key.pem -x509 -days 3650 -out cert.pem
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
Test for new Text -> Bytes conversions explicitly using UTF-8 as the encoding
|
Test for new Text -> Bytes conversions explicitly using UTF-8 as the encoding
|
||||||
|
|
||||||
```ucm:hide
|
|
||||||
.> builtins.merge
|
|
||||||
```
|
|
||||||
|
|
||||||
Unison has function for converting between `Text` and a UTF-8 `Bytes` encoding of the Text.
|
Unison has function for converting between `Text` and a UTF-8 `Bytes` encoding of the Text.
|
||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
```ucm:hide
|
```ucm:hide
|
||||||
.> builtins.mergeio
|
.> builtins.merge
|
||||||
```
|
```
|
||||||
|
|
||||||
```unison
|
```unison
|
@ -54,33 +54,29 @@ myServer = unsafeRun! '(hello "127.0.0.1" "0")
|
|||||||
do an `add` or `update`, here's how your codebase would
|
do an `add` or `update`, here's how your codebase would
|
||||||
change:
|
change:
|
||||||
|
|
||||||
⊡ Previously added definitions will be ignored: Exception
|
|
||||||
|
|
||||||
⍟ These new definitions are ok to `add`:
|
⍟ These new definitions are ok to `add`:
|
||||||
|
|
||||||
structural type Either a b
|
structural type Either a b
|
||||||
(also named builtin.Either)
|
(also named builtin.Either)
|
||||||
bugFail : Failure -> r
|
structural ability Exception
|
||||||
hello : Text -> Text ->{IO, Exception} ()
|
(also named builtin.Exception)
|
||||||
myServer : '{IO} ()
|
|
||||||
putText : Handle -> Text ->{IO, Exception} ()
|
|
||||||
reraise : Either Failure b ->{Exception} b
|
|
||||||
(also named Exception.reraise)
|
|
||||||
socketSend : Socket -> Bytes ->{IO, Exception} ()
|
|
||||||
toException : Either Failure a ->{Exception} a
|
|
||||||
(also named Exception.reraise)
|
|
||||||
|
|
||||||
⍟ These names already exist. You can `update` them to your
|
|
||||||
new definition:
|
|
||||||
|
|
||||||
Exception.unsafeRun! : '{g, Exception} a -> '{g} a
|
Exception.unsafeRun! : '{g, Exception} a -> '{g} a
|
||||||
|
bugFail : Failure -> r
|
||||||
closeSocket : Socket ->{IO, Exception} ()
|
closeSocket : Socket ->{IO, Exception} ()
|
||||||
|
hello : Text -> Text ->{IO, Exception} ()
|
||||||
|
myServer : '{IO} ()
|
||||||
putBytes : Handle
|
putBytes : Handle
|
||||||
-> Bytes
|
-> Bytes
|
||||||
->{IO, Exception} ()
|
->{IO, Exception} ()
|
||||||
|
putText : Handle -> Text ->{IO, Exception} ()
|
||||||
|
reraise : Either Failure b ->{Exception} b
|
||||||
serverSocket : Optional Text
|
serverSocket : Optional Text
|
||||||
-> Text
|
-> Text
|
||||||
->{IO, Exception} Socket
|
->{IO, Exception} Socket
|
||||||
|
socketSend : Socket
|
||||||
|
-> Bytes
|
||||||
|
->{IO, Exception} ()
|
||||||
|
toException : Either Failure a ->{Exception} a
|
||||||
|
|
||||||
```
|
```
|
||||||
```ucm
|
```ucm
|
@ -51,3 +51,29 @@ Fold.Stream.fold =
|
|||||||
res = Fold.Stream.fold (folds.all pred) (Stream.range 1 5)
|
res = Fold.Stream.fold (folds.all pred) (Stream.range 1 5)
|
||||||
!res Universal.== false
|
!res Universal.== false
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Tests some capabilities for catching runtime exceptions.
|
||||||
|
|
||||||
|
```unison
|
||||||
|
catcher : '{IO} () ->{IO} Result
|
||||||
|
catcher act =
|
||||||
|
handle tryEval act with cases
|
||||||
|
{ raise _ -> _ } -> Ok "caught"
|
||||||
|
{ _ } -> Fail "nothing to catch"
|
||||||
|
|
||||||
|
tests _ =
|
||||||
|
[ catcher do
|
||||||
|
_ = 1/0
|
||||||
|
()
|
||||||
|
, catcher '(bug "testing")
|
||||||
|
, handle tryEval (do 1+1) with cases
|
||||||
|
{ raise _ -> _ } -> Fail "1+1 failed"
|
||||||
|
{ 2 } -> Ok "got the right answer"
|
||||||
|
{ _ } -> Fail "got the wrong answer"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
```ucm
|
||||||
|
.> add
|
||||||
|
.> io.test tests
|
||||||
|
```
|
||||||
|
@ -85,3 +85,59 @@ Fold.Stream.fold =
|
|||||||
true
|
true
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Tests some capabilities for catching runtime exceptions.
|
||||||
|
|
||||||
|
```unison
|
||||||
|
catcher : '{IO} () ->{IO} Result
|
||||||
|
catcher act =
|
||||||
|
handle tryEval act with cases
|
||||||
|
{ raise _ -> _ } -> Ok "caught"
|
||||||
|
{ _ } -> Fail "nothing to catch"
|
||||||
|
|
||||||
|
tests _ =
|
||||||
|
[ catcher do
|
||||||
|
_ = 1/0
|
||||||
|
()
|
||||||
|
, catcher '(bug "testing")
|
||||||
|
, handle tryEval (do 1+1) with cases
|
||||||
|
{ raise _ -> _ } -> Fail "1+1 failed"
|
||||||
|
{ 2 } -> Ok "got the right answer"
|
||||||
|
{ _ } -> Fail "got the wrong answer"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
```ucm
|
||||||
|
|
||||||
|
Loading changes detected in scratch.u.
|
||||||
|
|
||||||
|
I found and typechecked these definitions in scratch.u. If you
|
||||||
|
do an `add` or `update`, here's how your codebase would
|
||||||
|
change:
|
||||||
|
|
||||||
|
⍟ These new definitions are ok to `add`:
|
||||||
|
|
||||||
|
catcher : '{IO} () ->{IO} Result
|
||||||
|
tests : ∀ _. _ ->{IO} [Result]
|
||||||
|
|
||||||
|
```
|
||||||
|
```ucm
|
||||||
|
.> add
|
||||||
|
|
||||||
|
⍟ I've added these definitions:
|
||||||
|
|
||||||
|
catcher : '{IO} () ->{IO} Result
|
||||||
|
tests : ∀ _. _ ->{IO} [Result]
|
||||||
|
|
||||||
|
.> io.test tests
|
||||||
|
|
||||||
|
New test results:
|
||||||
|
|
||||||
|
◉ tests caught
|
||||||
|
◉ tests caught
|
||||||
|
◉ tests got the right answer
|
||||||
|
|
||||||
|
✅ 3 test(s) passing
|
||||||
|
|
||||||
|
Tip: Use view tests to view the source of a test.
|
||||||
|
|
||||||
|
```
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
```ucm
|
```ucm
|
||||||
.> display List.map
|
.> display List.map
|
||||||
```
|
```
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
```unison
|
```unison
|
||||||
lexicalScopeEx: [Text]
|
lexicalScopeEx: [Text]
|
||||||
lexicalScopeEx =
|
lexicalScopeEx =
|
||||||
parent = "outer"
|
parent = "outer"
|
||||||
inner1 = let
|
inner1 = let
|
||||||
child1 = "child1"
|
child1 = "child1"
|
||||||
inner2 : [Text]
|
inner2 : [Text]
|
||||||
inner2 = let
|
inner2 = let
|
||||||
child2 = "child2"
|
child2 = "child2"
|
||||||
[parent, child1, child2]
|
[parent, child1, child2]
|
||||||
inner2
|
inner2
|
||||||
|
@ -11,4 +11,3 @@ Ensure closing token is emitted by closing brace in doc eval block.
|
|||||||
```ucm:hide
|
```ucm:hide
|
||||||
.> add
|
.> add
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue
Block a user