Created test case for type section
This commit is contained in:
parent
a548dcc585
commit
bc9beb0317
@ -109,3 +109,36 @@ data ro object:Obj
|
||||
`, test)
|
||||
}
|
||||
|
||||
func TestType (test *testing.T) {
|
||||
checkTree ("../tests/parser/type",
|
||||
`
|
||||
:arf
|
||||
---
|
||||
type ro Basic:Int
|
||||
|
||||
type ro BasicInit:Int 6
|
||||
|
||||
type ro IntArray:{Int ..}
|
||||
|
||||
type ro IntArrayInit:{Int 3}
|
||||
3298 923 92
|
||||
|
||||
type ro Complex:Obj
|
||||
ro that:Basic
|
||||
ro this:Basic
|
||||
|
||||
type ro ComplexInit:Obj
|
||||
ro that:BasicInit
|
||||
ro this:Basic 23
|
||||
|
||||
type ro ComplexWithComplexInit
|
||||
ro basic:Basic 87
|
||||
ro complex0:Complex
|
||||
.that 98
|
||||
.this 2
|
||||
ro complex1:Complex
|
||||
.that 98902
|
||||
.this 235
|
||||
`, test)
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,27 @@ type DataSection struct {
|
||||
name string
|
||||
|
||||
what Type
|
||||
value Argument
|
||||
permission types.Permission
|
||||
value Argument
|
||||
}
|
||||
|
||||
// TypeMember represents member data
|
||||
type TypeMember struct {
|
||||
location file.Location
|
||||
name string
|
||||
|
||||
what Type
|
||||
permission types.Permission
|
||||
defaultValue Argument
|
||||
}
|
||||
|
||||
// TypeSection represents a type definition.
|
||||
type TypeSection struct {
|
||||
location file.Location
|
||||
name string
|
||||
|
||||
what Type
|
||||
permission types.Permission
|
||||
// this should be 1 dimensional for now.
|
||||
members map[string] TypeMember
|
||||
}
|
||||
|
27
tests/parser/type/main.arf
Normal file
27
tests/parser/type/main.arf
Normal file
@ -0,0 +1,27 @@
|
||||
:arf
|
||||
---
|
||||
type ro Basic:Int
|
||||
|
||||
type ro BasicInit:Int 6
|
||||
|
||||
type ro IntArray:{Int ..}
|
||||
|
||||
type ro IntArrayInit:{Int 3}
|
||||
3298 923 92
|
||||
|
||||
type ro Complex:Obj
|
||||
ro that:Basic
|
||||
ro this:Basic
|
||||
|
||||
type ro ComplexInit:Obj
|
||||
ro that:BasicInit
|
||||
ro this:Basic 23
|
||||
|
||||
type ro ComplexWithComplexInit
|
||||
ro complex0:Complex
|
||||
.that 98
|
||||
.this 2
|
||||
ro complex1:Complex
|
||||
.that 98902
|
||||
.this 235
|
||||
ro basic:Basic 87
|
Reference in New Issue
Block a user