<p>By this, I don't mean PC-based development environments (like Visual Studio) for developing and deploying Windows Mobile applications.  Rather, I mean an IDE that runs on Windows Mobile devices and lets you write and test code there.</p>

I know of no such thing, and I doubt it would be a good idea; as such I don't think any such thing exists.
It would be a cool project for you to write though, I can't imagine it would be that hard. You would just need a compiler that runs on the WM platform.
Wait; I found this:
http://www.freewarepocketpc.net/ppc-download-c-ide-mobile-v9-0.html