Pass TestUnitPrivateMethod Err
This commit is contained in:
parent
d2cb1f78c4
commit
95db63b1b8
@ -163,7 +163,7 @@ func (this *Tree) analyzeMethodCall (
|
|||||||
// since this is a method, check access permissions
|
// since this is a method, check access permissions
|
||||||
if method.Acc == entity.AccessPrivate && method.Unit != this.unit {
|
if method.Acc == entity.AccessPrivate && method.Unit != this.unit {
|
||||||
return nil, errors.Errorf (
|
return nil, errors.Errorf (
|
||||||
method.Position, "method %v.[%v] is private",
|
call.Position, "method %v.[%v] is private",
|
||||||
method.TypeName, method.Signature.Name)
|
method.TypeName, method.Signature.Name)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -123,7 +123,6 @@ func (this *Tree) analyzeMethodOrBehaviorInternal (
|
|||||||
Unit: ty.Unit,
|
Unit: ty.Unit,
|
||||||
Name: ty.Name,
|
Name: ty.Name,
|
||||||
}
|
}
|
||||||
println(typeKey.String())
|
|
||||||
if this.methodExists(this.methodKey(typeKey, name)) {
|
if this.methodExists(this.methodKey(typeKey, name)) {
|
||||||
method, err := this.analyzeMethod(pos, typeKey, name)
|
method, err := this.analyzeMethod(pos, typeKey, name)
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
|
72
analyzer/multiunit_test.go
Normal file
72
analyzer/multiunit_test.go
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package analyzer
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestTwoUnit (test *testing.T) {
|
||||||
|
testUnits (test,
|
||||||
|
`[main]:something::X = 5`,
|
||||||
|
|
||||||
|
"something.fspl",
|
||||||
|
`+ X:Int`,
|
||||||
|
)}
|
||||||
|
|
||||||
|
func TestUnitPrivateTypeErr (test *testing.T) {
|
||||||
|
testUnitsErr (test,
|
||||||
|
"main.fspl", "type other::X is private", 1, 8,
|
||||||
|
`[main]:other::X = 5`,
|
||||||
|
|
||||||
|
"other.fspl",
|
||||||
|
`- X:Int`,
|
||||||
|
)}
|
||||||
|
|
||||||
|
func TestUnitPrivateFunctionErr (test *testing.T) {
|
||||||
|
testUnitsErr (test,
|
||||||
|
"main.fspl", "function other::[x] is private", 1, 11,
|
||||||
|
`[y]:Int = other::[x]`,
|
||||||
|
|
||||||
|
"other.fspl",
|
||||||
|
`- [x]:Int = 5`,
|
||||||
|
)}
|
||||||
|
|
||||||
|
func TestUnitPrivateMethodErr (test *testing.T) {
|
||||||
|
testUnitsErr (test,
|
||||||
|
"main.fspl", "method T.[x] is private", 1, 21,
|
||||||
|
`[y]:Int = z:other::T.[x]`,
|
||||||
|
|
||||||
|
"other.fspl",
|
||||||
|
`
|
||||||
|
+ T:Int
|
||||||
|
- T.[x]:Int = 5`,
|
||||||
|
)}
|
||||||
|
|
||||||
|
func TestUnitAssignLiteralRestrictedErr (test *testing.T) {
|
||||||
|
testUnitsErr (test,
|
||||||
|
"main.fspl", "type RestrictedInt is restricted", 0, 0,
|
||||||
|
`[main]:other::RestrictedInt = 5`,
|
||||||
|
|
||||||
|
"other.fspl",
|
||||||
|
`~ RestrictedInt:Int`,
|
||||||
|
)}
|
||||||
|
|
||||||
|
func TestUnitMemberAccessRestrictedErr (test *testing.T) {
|
||||||
|
testUnitsErr (test,
|
||||||
|
"main.fspl", "type RestrictedStruct is restricted", 0, 0,
|
||||||
|
`[main] = {
|
||||||
|
x:other::RestrictedStruct
|
||||||
|
x.x = 5
|
||||||
|
}`,
|
||||||
|
|
||||||
|
"other.fspl",
|
||||||
|
`~ RestrictedStruct:(. x:Int y:Int)`,
|
||||||
|
)}
|
||||||
|
|
||||||
|
func TestNestedUnitTypedef (test *testing.T) {
|
||||||
|
testUnits (test,
|
||||||
|
`[main]:layer1::X = 5`,
|
||||||
|
|
||||||
|
"layer0.fspl",
|
||||||
|
`+ X:Int`,
|
||||||
|
|
||||||
|
"layer1.fspl",
|
||||||
|
`+ X:layer0::X`,
|
||||||
|
)}
|
Loading…
Reference in New Issue
Block a user