Created test case for type section

This commit is contained in:
Sasha Koshka 2022-08-18 16:56:42 -04:00
parent a548dcc585
commit bc9beb0317
3 changed files with 82 additions and 1 deletions

View File

@ -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)
}

View File

@ -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
}

View 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