-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
67 lines (59 loc) · 1.38 KB
/
test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import . "fmt"
import . "./array"
type A struct{}
func init() {
RegisterType(A{})
RegisterType(&A{})
}
func main() {
var array = ArrayOfType("int")
array.Append(1)
array.Append(2)
array.Append(3)
Println(array)
array.InsertAtIndex(42, 0)
array.InsertAtIndex(99, 10)
Println(array)
Println(array.RemoveFirst())
Println(array.RemoveLast())
Println(array)
array.RemoveAll()
array.RemoveFirst()
array.RemoveLast()
Println(array)
array.Append(44)
Println(array)
array.SetAtIndex(55, 0)
Println(array)
Println(array.Count())
Println(array.IsEmpty())
Println(array.ElementAtIndex(0))
Println(array.ElementAtIndex(-1))
Println(array.ElementAtIndex(1))
Println(array.IndexForElement(55))
Println(array.IndexForElement(-55))
array.Remove(55)
Println(array)
Println()
Println(IsTypeRegistered("typeName"))
Println(IsTypeRegistered("A"))
var pointer = new(A)
Println(GetTypeName(pointer))
RegisteredTypes()[0] = "xxx"
Println(RegisteredTypes())
Println(IsTypeRegistered("*A"))
Println()
var newArray = new(Array)
newArray.SetType("string")
newArray.Append("newElement")
Println(newArray)
Println(newArray.ContainsElement("newElement"))
Println(newArray.IndexForElement("newElement"))
newArray.Remove("newElement")
Println(newArray)
newArray.InsertAtIndex("test", 0)
newArray.InsertAtIndex("foo", -100)
newArray.InsertAtIndex("boo", 0)
Println(newArray)
}