On a related thread to this question, what steps can one take to avoid executing obfuscated malicious code (in the unlikely case someone sees fit to post some in a solution.
Is it best to just avoid testing code we don't understand?
On the one hand, it probably is. Though some languages can be sandboxed, and you can test arbitrary programs if the sandbox is set up right, those languages are few and far in between, and security is a question of the "weakest link".
On the other hand, it may not be necessary. Posting malicious code violates section 3(e) of the terms of service, and moderators have the right to take adverse action against such users. Users (especially high-rep ones) usually do not want to jeopardise their hard-earned rep by engaging in such dubious actions.
One option is to run everything from this site in a sandbox. Here are some already available on the internet.