56 lines
930 B
Go
56 lines
930 B
Go
package analyzer
|
|
|
|
import "testing"
|
|
|
|
func TestMethodUniqueErr (test *testing.T) {
|
|
testStringErr (test,
|
|
"Bird.fly already declared at stream0.fspl:3:1", 4, 1,
|
|
`
|
|
Bird: Int
|
|
Bird.[fly] = { }
|
|
Bird.[fly distance:Int] = { }
|
|
`)
|
|
}
|
|
|
|
func TestMethodUnique (test *testing.T) {
|
|
testString (test,
|
|
`
|
|
Bird: Int
|
|
Bird.[fly] = { }
|
|
Bird.[land] = { }
|
|
Bird.[walk distance:Int] = { }
|
|
Bat: Int
|
|
Bat.[fly] = { }
|
|
[fly] = { }
|
|
`)
|
|
}
|
|
|
|
func TestMethodArgumentUniqueErr (test *testing.T) {
|
|
testStringErr (test,
|
|
"x already listed as argument at stream0.fspl:3:12", 3, 18,
|
|
`
|
|
Bird: Int
|
|
Bird.[main x:Int x:U8 y:Int] = { }
|
|
`)
|
|
}
|
|
|
|
func TestMethodArgumentUnique (test *testing.T) {
|
|
testString (test,
|
|
`
|
|
Bird: Int
|
|
Bird.[main x:Int y:U8 z:Int] = { }
|
|
`)
|
|
}
|
|
|
|
func TestMethodThis (test *testing.T) {
|
|
testString (test,
|
|
`
|
|
Number: Int
|
|
Number.[add x:Number]:Number = [++[.this] x]
|
|
StringHolder: (string:String)
|
|
StringHolder.[setString string:String] = {
|
|
this.string = string
|
|
}
|
|
`)
|
|
}
|