Skip to content

Commit

Permalink
other test
Browse files Browse the repository at this point in the history
  • Loading branch information
dsainati1 committed Oct 4, 2023
1 parent 251f6e3 commit 1be5126
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions runtime/tests/checker/entitlements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7320,7 +7320,11 @@ func TestCheckEntitlementMissingInMap(t *testing.T) {

t.Parallel()

_, err := ParseAndCheck(t, `
t.Run("missing type", func(t *testing.T) {

t.Parallel()

_, err := ParseAndCheck(t, `
access(all) entitlement X
access(all) entitlement mapping M {
X -> X
Expand All @@ -7336,7 +7340,32 @@ func TestCheckEntitlementMissingInMap(t *testing.T) {
}
`)

errors := RequireCheckerErrors(t, err, 2)
require.IsType(t, errors[0], &sema.NotDeclaredError{})
require.IsType(t, errors[1], &sema.InvalidNonEntitlementTypeInMapError{})
errors := RequireCheckerErrors(t, err, 2)
require.IsType(t, errors[0], &sema.NotDeclaredError{})
require.IsType(t, errors[1], &sema.InvalidNonEntitlementTypeInMapError{})
})

t.Run("non entitlement type", func(t *testing.T) {

t.Parallel()

_, err := ParseAndCheck(t, `
access(all) entitlement X
access(all) entitlement mapping M {
X -> X
Int -> X
}
access(all) struct S {
access(M) var foo: auth(M) &Int
init() {
self.foo = &3 as auth(X) &Int
var selfRef = &self as auth(X) &S;
selfRef.foo;
}
}
`)

errors := RequireCheckerErrors(t, err, 1)
require.IsType(t, errors[0], &sema.InvalidNonEntitlementTypeInMapError{})
})
}

0 comments on commit 1be5126

Please sign in to comment.