ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci / checks (push) Successful in 21m57s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 23m31s
21 lines
535 B
Go
21 lines
535 B
Go
package refs
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"aego/core/ids"
|
|
"aego/schema"
|
|
)
|
|
|
|
func TestRewriteNested(t *testing.T) {
|
|
a, b := ids.AssetID{Hi: 1, Lo: 1}, ids.AssetID{Hi: 2, Lo: 2}
|
|
v := schema.Value{Kind: schema.KindList, List: []schema.Value{schema.Asset(ids.AssetID{}), schema.Asset(a)}}
|
|
nv, ok := rewrite(v, swapAsset(a, b))
|
|
if !ok || nv.List[1].Asset != b || v.List[1].Asset != a {
|
|
t.Fatal("rewrite must replace inside lists without touching the original")
|
|
}
|
|
if leafAny(nv, isAsset(a)) {
|
|
t.Fatal("no old reference may remain")
|
|
}
|
|
}
|