>> I just ran into a similar "problem" in POE::Driver::SysRW. For >> portability I have a couple lines similar to >> >> $! = 0 if $! == EAGAIN or $! == EWOULDBLOCK; >> >> EAGAIN and EWOULDBLOCK are identical on most systems. In fact, one is >> usually defined in terms of the other. They differ on a few platforms, >> however, and it's important to check both. > > Redefine EAGAIN and EWOULDBLOCK (they're just perl constants), and rerun > that code, after setting $!. (Your code probably isn't written so that > is in one callable place, but it could be.) > > This is probably a good example of where it's too silly to force it to > test all the possibilities, but it is possible.
I don't think it's silly at all - if "it's important to check both" then you would want to have tests that cover situations which can occur on platforms other than your own, otherwise you can't really be sure that you have provided the logic you seek. as you mention, local-style redefinition is just the solution for code like this - I, for one, always get confused about operator precidence in cases just slightly more complex than the one above, and prefer to use tests (and parens :) to make sure I got it right. --Geoff