This version passes basic tests:
mat <- matrix(c(1,2,3,4), nrow=2, ncol=2)
cm <- makeCacheMatrix(mat)
cm$get() # mat
cm$getcache() # NULL
cacheSolve(cm) # inverse of mat (computed)
cacheSolve(cm) # inverse of mat (cached)
cm$set(mat)
cm$getcache() # NULL (cache was reset)
cacheSolve(cm) # inverse of mat (computed)
cacheSolve(cm) # inverse of mat (cached)