-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4413 from unisonweb/fix/update-tests
fix #4405
- Loading branch information
Showing
10 changed files
with
243 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
```ucm:hide | ||
.> builtins.mergeio | ||
``` | ||
|
||
```unison:hide | ||
test> foo : [Test.Result] | ||
foo = [] | ||
``` | ||
|
||
Apparently when we add a test watch, we add a type annotation to it, even if it already has one. We don't want this to happen though! | ||
|
||
```ucm | ||
.> add | ||
.> view foo | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
```unison | ||
test> foo : [Test.Result] | ||
foo = [] | ||
``` | ||
|
||
Apparently when we add a test watch, we add a type annotation to it, even if it already has one. We don't want this to happen though! | ||
|
||
```ucm | ||
.> add | ||
⍟ I've added these definitions: | ||
foo : [Result] | ||
.> view foo | ||
foo : [Result] | ||
foo : [Result] | ||
foo = [] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
```ucm | ||
.> builtins.mergeio | ||
``` | ||
|
||
```unison | ||
test> foo = [] | ||
``` | ||
|
||
After adding the test `foo`, we expect `view` to render it like a test. (Bug: It doesn't.) | ||
|
||
```ucm | ||
.> add | ||
.> view foo | ||
``` | ||
|
||
```unison | ||
foo = 1 | ||
``` | ||
|
||
After updating `foo` to not be a test, we expect `view` to not render it like a test. | ||
|
||
```ucm | ||
.> update | ||
.> view foo | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
```ucm | ||
.> builtins.mergeio | ||
Done. | ||
``` | ||
```unison | ||
test> foo = [] | ||
``` | ||
|
||
```ucm | ||
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`: | ||
foo : [Result] | ||
Now evaluating any watch expressions (lines starting with | ||
`>`)... Ctrl+C cancels. | ||
1 | test> foo = [] | ||
``` | ||
After adding the test `foo`, we expect `view` to render it like a test. (Bug: It doesn't.) | ||
|
||
```ucm | ||
.> add | ||
⍟ I've added these definitions: | ||
foo : [Result] | ||
.> view foo | ||
foo : [Result] | ||
foo = [] | ||
``` | ||
```unison | ||
foo = 1 | ||
``` | ||
|
||
```ucm | ||
I found and typechecked these definitions in scratch.u. If you | ||
do an `add` or `update`, here's how your codebase would | ||
change: | ||
⍟ These names already exist. You can `update` them to your | ||
new definition: | ||
foo : Nat | ||
``` | ||
After updating `foo` to not be a test, we expect `view` to not render it like a test. | ||
|
||
```ucm | ||
.> update | ||
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... | ||
Done. | ||
.> view foo | ||
foo : Nat | ||
foo = 1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
```ucm:hide | ||
.> builtins.mergeio | ||
``` | ||
|
||
Given a test that depends on another definition, | ||
|
||
```unison:hide | ||
foo n = n + 1 | ||
test> mynamespace.foo.test = | ||
n = 2 | ||
if (foo n) == 2 then [ Ok "passed" ] else [ Fail "wat" ] | ||
``` | ||
|
||
```ucm | ||
.> add | ||
``` | ||
|
||
if we change the type of the dependency, the test should show in the scratch file as a test watch. | ||
|
||
```unison | ||
foo n = "hello, world!" | ||
``` | ||
|
||
```ucm:error | ||
.> update | ||
``` |
57 changes: 57 additions & 0 deletions
57
unison-src/transcripts/update-test-watch-roundtrip.output.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
Given a test that depends on another definition, | ||
|
||
```unison | ||
foo n = n + 1 | ||
test> mynamespace.foo.test = | ||
n = 2 | ||
if (foo n) == 2 then [ Ok "passed" ] else [ Fail "wat" ] | ||
``` | ||
|
||
```ucm | ||
.> add | ||
⍟ I've added these definitions: | ||
foo : Nat -> Nat | ||
mynamespace.foo.test : [Result] | ||
``` | ||
if we change the type of the dependency, the test should show in the scratch file as a test watch. | ||
|
||
```unison | ||
foo n = "hello, world!" | ||
``` | ||
|
||
```ucm | ||
I found and typechecked these definitions in scratch.u. If you | ||
do an `add` or `update`, here's how your codebase would | ||
change: | ||
⍟ These names already exist. You can `update` them to your | ||
new definition: | ||
foo : n -> Text | ||
``` | ||
```ucm | ||
.> update | ||
Okay, I'm searching the branch for code that needs to be | ||
updated... | ||
That's done. Now I'm making sure everything typechecks... | ||
test> mynamespace.foo.test = | ||
n = 2 | ||
if foo n == 2 then [Ok "passed"] else [Fail "wat"] | ||
foo n = "hello, world!" | ||
Typechecking failed. I've updated your scratch file with the | ||
definitions that need fixing. Once the file is compiling, try | ||
`update` again. | ||
``` |