Skip to content

Commit

Permalink
Fix test case for ArrayUtils.transform
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Jan 2, 2024
1 parent 3fc5c0c commit 8f66e17
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions tests/test_array_utils.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,11 @@ fun testTransform() {
]

// Act
// ArrayUtils.transform(&tokens as auth(Mutate) &[AnyStruct], fun (t: AnyStruct): AnyStruct {
// let token = t as! &Token
// token.setBalance(token.balance * 2)
// return token
// })
// Fails with: error: invalid container update: expected a subtype of `Token`, found `&Token`
// fun transform(_ array: auth(Mutate) &[AnyStruct], _ f: fun(AnyStruct): AnyStruct) {
// for i in self.range(0, array.length) {
// array[i] = f(array[i]) // the error is here
// }
// }
let tokensRef: auth(Mutate) &[Token] = &tokens
for token in tokensRef {
ArrayUtils.transform(&tokens as auth(Mutate) &[AnyStruct], fun (t: AnyStruct): AnyStruct {
let token = t as! &Token
token.setBalance(token.balance * 2)
}
return Token(id: token.id, balance: token.balance)
})

// Assert
let expected = [
Expand Down

0 comments on commit 8f66e17

Please sign in to comment.