mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-11 15:30:07 +00:00
1fb66d6b73
GolangCI complained: testArray is unused (from deadcode) But this function was actually wrong being a copy-paste of testMakeStackMap(), it also didn't conform to testMake... naming scheme, so this fixes it. To make thing more uniform NewArray() was also changed to return error, map_test.go code adjusted to this changes and finally array_test.go was added as a stub for future Array testing.
36 lines
695 B
Go
36 lines
695 B
Go
package stack
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// Array represents an Array of stackItems on the stack
|
|
type Array struct {
|
|
*abstractItem
|
|
val []Item
|
|
}
|
|
|
|
// Array overrides the default implementation
|
|
// by the abstractItem, returning an Array struct
|
|
func (a *Array) Array() (*Array, error) {
|
|
return a, nil
|
|
}
|
|
|
|
//Value returns the underlying Array's value
|
|
func (a *Array) Value() []Item {
|
|
return a.val
|
|
}
|
|
|
|
// NewArray returns a new Array.
|
|
func NewArray(val []Item) (*Array, error) {
|
|
return &Array{
|
|
&abstractItem{},
|
|
val,
|
|
}, nil
|
|
}
|
|
|
|
// Hash overrides the default abstract hash method.
|
|
func (a *Array) Hash() (string, error) {
|
|
data := fmt.Sprintf("%T %v", a, a.Value())
|
|
return KeyGenerator([]byte(data))
|
|
}
|