2019-11-08 01:52:20 +03:00
|
|
|
First we add some code:
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2019-11-08 01:52:20 +03:00
|
|
|
x = 0
|
|
|
|
y = x + 1
|
|
|
|
z = y + 2
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2019-11-08 01:52:20 +03:00
|
|
|
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`:
|
|
|
|
|
2019-11-14 00:57:51 +03:00
|
|
|
x : Nat
|
|
|
|
y : Nat
|
|
|
|
z : Nat
|
2019-11-08 01:52:20 +03:00
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> add
|
2019-11-08 01:52:20 +03:00
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
|
|
|
|
2019-11-14 00:57:51 +03:00
|
|
|
x : Nat
|
|
|
|
y : Nat
|
|
|
|
z : Nat
|
2019-11-08 01:52:20 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
Now we edit `x` to be `7`, which should make `z` equal `10`:
|
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2019-11-08 01:52:20 +03:00
|
|
|
x = 7
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2019-11-08 01:52:20 +03:00
|
|
|
I found and typechecked these definitions in scratch.u. If you
|
|
|
|
do an `add` or `update`, here's how your codebase would
|
|
|
|
change:
|
|
|
|
|
2020-02-26 00:15:36 +03:00
|
|
|
⍟ These names already exist. You can `update` them to your
|
|
|
|
new definition:
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2019-11-14 00:57:51 +03:00
|
|
|
x : Nat
|
2019-11-08 01:52:20 +03:00
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> update
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2023-11-14 06:36:03 +03:00
|
|
|
Okay, I'm searching the branch for code that needs to be
|
|
|
|
updated...
|
|
|
|
|
|
|
|
That's done. Now I'm making sure everything typechecks...
|
|
|
|
|
|
|
|
Everything typechecks, so I'm saving the results...
|
2023-11-08 19:54:50 +03:00
|
|
|
|
|
|
|
Done.
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> view x y z
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2019-11-14 00:57:51 +03:00
|
|
|
x : Nat
|
2019-11-08 01:52:20 +03:00
|
|
|
x = 7
|
|
|
|
|
2019-11-14 00:57:51 +03:00
|
|
|
y : Nat
|
2019-11-08 01:52:20 +03:00
|
|
|
y =
|
2019-11-14 00:57:51 +03:00
|
|
|
use Nat +
|
2019-11-08 01:52:20 +03:00
|
|
|
x + 1
|
|
|
|
|
2019-11-14 00:57:51 +03:00
|
|
|
z : Nat
|
2019-11-08 01:52:20 +03:00
|
|
|
z =
|
2019-11-14 00:57:51 +03:00
|
|
|
use Nat +
|
2019-11-08 01:52:20 +03:00
|
|
|
y + 2
|
|
|
|
|
|
|
|
```
|
2024-07-10 17:46:18 +03:00
|
|
|
Uh oh\! `z` is still referencing the old version. Just to confirm:
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2024-07-10 17:46:18 +03:00
|
|
|
``` unison
|
2019-11-08 01:52:20 +03:00
|
|
|
test> t1 = if z == 3 then [Fail "nooo!!!"] else [Ok "great"]
|
|
|
|
```
|
|
|
|
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2023-12-22 14:55:24 +03:00
|
|
|
Loading changes detected in scratch.u.
|
|
|
|
|
2019-11-08 01:52:20 +03:00
|
|
|
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`:
|
|
|
|
|
2019-11-14 00:57:51 +03:00
|
|
|
t1 : [Result]
|
2020-04-08 21:25:19 +03:00
|
|
|
|
2019-11-08 01:52:20 +03:00
|
|
|
Now evaluating any watch expressions (lines starting with
|
|
|
|
`>`)... Ctrl+C cancels.
|
|
|
|
|
|
|
|
1 | test> t1 = if z == 3 then [Fail "nooo!!!"] else [Ok "great"]
|
|
|
|
|
|
|
|
✅ Passed great
|
|
|
|
|
|
|
|
```
|
2024-07-10 19:17:15 +03:00
|
|
|
``` ucm
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> add
|
2019-11-08 01:52:20 +03:00
|
|
|
|
|
|
|
⍟ I've added these definitions:
|
|
|
|
|
2019-11-14 00:57:51 +03:00
|
|
|
t1 : [Result]
|
2019-11-08 01:52:20 +03:00
|
|
|
|
2024-06-12 01:22:09 +03:00
|
|
|
scratch/main> test
|
2019-11-08 01:52:20 +03:00
|
|
|
|
|
|
|
Cached test results (`help testcache` to learn more)
|
|
|
|
|
2024-06-27 08:14:37 +03:00
|
|
|
1. t1 ◉ great
|
2019-11-08 01:52:20 +03:00
|
|
|
|
|
|
|
✅ 1 test(s) passing
|
|
|
|
|
2024-06-26 23:01:36 +03:00
|
|
|
Tip: Use view 1 to view the source of a test.
|
2019-11-08 01:52:20 +03:00
|
|
|
|
|
|
|
```
|