diff --git a/contracts/assign_unnamed_type/append_named_unnamed_type_filetest.gno b/contracts/assign_unnamed_type/append_named_unnamed_type_filetest.gno new file mode 100644 index 00000000000..f9ebb53eeff --- /dev/null +++ b/contracts/assign_unnamed_type/append_named_unnamed_type_filetest.gno @@ -0,0 +1,38 @@ +package main + + + +type nat []int + +func main() { + + var nlist = nat{0} + var ulist = []int{1} + var n int = 3 + + a := append(nlist, n) + b := append(ulist, n) + + println(a) + println(b) + + a = append(ulist, n) + b = append(nlist, n) + + c := append(nlist, ulist...) + d := append(ulist, nlist...) + + println(a) + println(b) + println(c) + println(d) + +} + +// Output: +// (slice[(0 int),(3 int)] main.nat) +// slice[(1 int),(3 int)] +// (slice[(1 int),(3 int)] main.nat) +// slice[(0 int),(3 int)] +// (slice[(0 int),(1 int)] main.nat) +// slice[(1 int),(0 int)] diff --git a/contracts/assign_unnamed_type/copy_name_unnamed2_type_filetest.gno b/contracts/assign_unnamed_type/copy_name_unnamed2_type_filetest.gno new file mode 100644 index 00000000000..6cad44a4afe --- /dev/null +++ b/contracts/assign_unnamed_type/copy_name_unnamed2_type_filetest.gno @@ -0,0 +1,21 @@ +package main + + +type nat []int +type nat2 []int + +func main() { + + var nlist = nat{0} + var n2list = nat2{1} + + copy(nlist, n2list) + + + println(nlist) + + +} + +// Output: +// (slice[(1 int)] main.nat) diff --git a/contracts/assign_unnamed_type/copy_name_unnamed_type_filetest.gno b/contracts/assign_unnamed_type/copy_name_unnamed_type_filetest.gno new file mode 100644 index 00000000000..6ada04f3a9a --- /dev/null +++ b/contracts/assign_unnamed_type/copy_name_unnamed_type_filetest.gno @@ -0,0 +1,27 @@ +package main + +type nat []int + +func main() { + + var nlist = nat{0} + var ulist = []int{1} + + copy(nlist, ulist) + + println(nlist) + println(ulist) + + nlist = nat{0} + ulist = []int{1} + copy(ulist, nlist) + println(nlist) + println(ulist) + +} + +// Output: +// (slice[(1 int)] main.nat) +// slice[(1 int)] +// (slice[(0 int)] main.nat) +// slice[(0 int)]