Add more test cases for restricted typedefs in units
This commit is contained in:
parent
f93c9b26c8
commit
eb9444dad3
|
@ -39,6 +39,18 @@ testUnitsErr (test,
|
|||
- T.[x]:Int = 5`,
|
||||
)}
|
||||
|
||||
func TestUnitAssignRestricted (test *testing.T) {
|
||||
testUnits (test,
|
||||
`[main] = {
|
||||
x:other::RestrictedInt
|
||||
y:other::RestrictedInt
|
||||
x = y
|
||||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestUnitAssignLiteralRestrictedErr (test *testing.T) {
|
||||
testUnitsErr (test,
|
||||
"main.fspl", "type RestrictedInt is restricted", 0, 0,
|
||||
|
@ -48,6 +60,12 @@ testUnitsErr (test,
|
|||
`~ RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestAssignLiteralRestricted (test *testing.T) {
|
||||
testString (test,
|
||||
`~ RestrictedInt:Int
|
||||
[main]:RestrictedInt = 5`,
|
||||
)}
|
||||
|
||||
func TestUnitMemberAccessRestrictedErr (test *testing.T) {
|
||||
testUnitsErr (test,
|
||||
"main.fspl", "type RestrictedStruct is restricted", 0, 0,
|
||||
|
@ -60,6 +78,59 @@ testUnitsErr (test,
|
|||
`~ RestrictedStruct:(. x:Int y:Int)`,
|
||||
)}
|
||||
|
||||
func TestMemberAccessRestricted (test *testing.T) {
|
||||
testString (test,
|
||||
`~ RestrictedStruct:(. x:Int y:Int)
|
||||
[main] = {
|
||||
x:RestrictedStruct
|
||||
x.x = 5
|
||||
}`,
|
||||
)}
|
||||
|
||||
func TestUnitSubscriptRestrictedErr (test *testing.T) {
|
||||
testUnitsErr (test,
|
||||
"main.fspl", "type RestrictedArr is restricted", 0, 0,
|
||||
`[main] = {
|
||||
x:other::RestrictedArr
|
||||
[.x 0] = 5
|
||||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedArr:5:Int`,
|
||||
)}
|
||||
|
||||
func TestSubscriptRestricted (test *testing.T) {
|
||||
testString (test,
|
||||
`~ RestrictedArr:5:Int
|
||||
[main] = {
|
||||
x:RestrictedArr
|
||||
[.x 0] = 5
|
||||
}`,
|
||||
)}
|
||||
|
||||
func TestUnitMathRestrictedErr (test *testing.T) {
|
||||
testUnitsErr (test,
|
||||
"main.fspl", "type RestrictedInt is restricted", 0, 0,
|
||||
`[main] = {
|
||||
x:other::RestrictedInt = [+
|
||||
y:other::RestrictedInt
|
||||
z:other::RestrictedInt]
|
||||
}`,
|
||||
|
||||
"other.fspl",
|
||||
`~ RestrictedInt:Int`,
|
||||
)}
|
||||
|
||||
func TestMathRestricted (test *testing.T) {
|
||||
testString (test,
|
||||
`~ RestrictedInt:Int
|
||||
[main] = {
|
||||
x:RestrictedInt = [+
|
||||
y:RestrictedInt
|
||||
z:RestrictedInt]
|
||||
}`,
|
||||
)}
|
||||
|
||||
func TestNestedUnitTypedef (test *testing.T) {
|
||||
testUnits (test,
|
||||
`[main]:layer1::X = 5`,
|
||||
|
|
Loading…
Reference in New Issue