Skip to content

Commit

Permalink
fix: add testing cases for copy() and append()
Browse files Browse the repository at this point in the history
  • Loading branch information
piux2 committed Sep 20, 2023
1 parent 6709920 commit eaae59b
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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)]
21 changes: 21 additions & 0 deletions contracts/assign_unnamed_type/copy_name_unnamed2_type_filetest.gno
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 27 additions & 0 deletions contracts/assign_unnamed_type/copy_name_unnamed_type_filetest.gno
Original file line number Diff line number Diff line change
@@ -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)]

0 comments on commit eaae59b

Please sign in to comment.