mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-17 13:27:30 +03:00
0031542faf
This is for consistency with the `cmark` style. Now the blocks we still pretty-print ourselves will match the bulk of them that `cmark` produces.
5.6 KiB
5.6 KiB
Tests for move.namespace
Moving the Root
I should be able to move the root into a sub-namespace
foo = 1
.> add
⍟ I've added these definitions:
foo : ##Nat
-- Should request confirmation
.> move.namespace . .root.at.path
⚠️
Moves which affect the root branch cannot be undone, are you sure?
Re-run the same command to proceed.
.> move.namespace . .root.at.path
Done.
.> ls
1. root/ (1 term)
.> history
Note: The most recent namespace hash is immediately below this
message.
□ 1. #g97lh1m2v7 (start of history)
.> ls .root.at.path
1. foo (##Nat)
.> history .root.at.path
Note: The most recent namespace hash is immediately below this
message.
□ 1. #08a6hgi6s4 (start of history)
I should be able to move a sub namespace over the root.
-- Should request confirmation
.> move.namespace .root.at.path .
⚠️
Moves which affect the root branch cannot be undone, are you sure?
Re-run the same command to proceed.
.> move.namespace .root.at.path .
Done.
.> ls
1. foo (##Nat)
.> history
Note: The most recent namespace hash is immediately below this
message.
□ 1. #08a6hgi6s4 (start of history)
-- should be empty
.> ls .root.at.path
nothing to show
.> history .root.at.path
☝️ The namespace .root.at.path is empty.
Happy path
Create a namespace and add some history to it
a.termInA = 1
unique type a.T = T
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`:
type a.T
a.termInA : Nat
scratch/happy> add
⍟ I've added these definitions:
type a.T
a.termInA : Nat
a.termInA = 2
unique type a.T = T1 | T2
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 names already exist. You can `update` them to your
new definition:
type a.T
a.termInA : Nat
scratch/happy> update
Okay, I'm searching the branch for code that needs to be
updated...
Done.
Should be able to move the namespace, including its types, terms, and sub-namespaces.
scratch/happy> move.namespace a b
Done.
scratch/happy> ls b
1. T (type)
2. T/ (2 terms)
3. termInA (Nat)
scratch/happy> history b
Note: The most recent namespace hash is immediately below this
message.
⊙ 1. #rkvfe5p8fu
+ Adds / updates:
T T.T1 T.T2 termInA
- Deletes:
T.T
□ 2. #avlnmh0erc (start of history)
Namespace history
Create some namespaces and add some history to them
a.termInA = 1
b.termInB = 10
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`:
a.termInA : Nat
b.termInB : Nat
scratch/history> add
⍟ I've added these definitions:
a.termInA : Nat
b.termInB : Nat
a.termInA = 2
b.termInB = 11
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 names already exist. You can `update` them to your
new definition:
a.termInA : Nat
b.termInB : Nat
scratch/history> update
Okay, I'm searching the branch for code that needs to be
updated...
Done.
Deleting a namespace should not leave behind any history, if we move another to that location we expect the history to simply be the history of the moved namespace.
scratch/history> delete.namespace b
Done.
scratch/history> move.namespace a b
Done.
-- Should be the history from 'a'
scratch/history> history b
Note: The most recent namespace hash is immediately below this
message.
⊙ 1. #j0cjjqepb3
+ Adds / updates:
termInA
□ 2. #m8smmmgjso (start of history)
-- Should be empty
scratch/history> history a
☝️ The namespace a is empty.
Moving over an existing branch
Create some namespace and add some history to them
a.termInA = 1
b.termInB = 10
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`:
a.termInA : Nat
b.termInB : Nat
scratch/existing> add
⍟ I've added these definitions:
a.termInA : Nat
b.termInB : Nat
a.termInA = 2
b.termInB = 11
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 names already exist. You can `update` them to your
new definition:
a.termInA : Nat
b.termInB : Nat
scratch/existing> update
Okay, I'm searching the branch for code that needs to be
updated...
Done.
scratch/existing> move.namespace a b
⚠️
A branch existed at the destination: b so I over-wrote it.
Tip: You can use `undo` or `reflog` to undo this change.
Done.