Controller.getViews(), the documentation says it returns an Array, so I expected it to have a length property, it doesn't. It's really a hash of id's to views. Please fix either the documentation or the method so they agree.
Controller.getTopLevelViews(), is documented the same way, but the return value actually behaves like an array.
You can drop the attached files into a fresh project to see how they behave.