54 lines
753 B
Go
54 lines
753 B
Go
package analyzer
|
|
|
|
import "testing"
|
|
|
|
func TestLiteralStructMemberUniqueErr (test *testing.T) {
|
|
testStringErr (test,
|
|
"x already listed in struct literal at stream0.fspl:5:3", 7, 3,
|
|
`
|
|
Point: (. x:Int y:Int z:Int)
|
|
[main] = {
|
|
point:Point = (.
|
|
x: 5
|
|
y: 0
|
|
x: 32)
|
|
}
|
|
`)
|
|
}
|
|
|
|
func TestLiteralStructMemberUnique (test *testing.T) {
|
|
testString (test,
|
|
`
|
|
Point: (. x:Int y:Int z:Int)
|
|
[main] = {
|
|
point:Point = (.
|
|
x: 5
|
|
y: 0
|
|
z: 32)
|
|
}
|
|
`)
|
|
}
|
|
|
|
func TestLiteralStructNested (test *testing.T) {
|
|
testString (test,
|
|
`
|
|
[main] = {
|
|
g:(. x:Int y:(. w:F64 z:F64)) = (.
|
|
x: 1
|
|
y: (.
|
|
w: 1.2
|
|
z: 78.5))
|
|
}
|
|
`)
|
|
}
|
|
|
|
func TestLiteralReferenceErr (test *testing.T) {
|
|
testStringErr (test,
|
|
"cannot assign to string literal", 3, 20,
|
|
`
|
|
[main] = {
|
|
byteptr:*Byte = [@'\n']
|
|
}
|
|
`)
|
|
}
|