The API docs are incorrect.
You should test with if ($val->test()) {}
as in Jake's example. Comparing it to 0
is essentially saying == false
(false and 0 are both falsey), and if you look at the code, it returns true or false based on success or failure:
return count($this->fieldsInvalid) == 0;
Though, now that I've also read mkly's post, he's right too. You don't need to check the token in a block action. However, it's important to remember the correct $val->test()
usage in general.
James