Quines have been around forever. It's a fun challenge: write a program that, when executed, generates its own source code as output. But how do you know it's actually producing its own source code? Generally, you have to look at it and compare it, but with quines generally being composed of tricky and intricate code, this is not always easy.
Comparing two strings, though, is something a computer does very well, so why not make the program validate itself? Your task is to create a program that:
- produces its own source code as output
- compares its output to its own source code
- raises some sort of error, appropriate to the language used, if the output does not match
- If the output does match, it's acceptable to terminate without further output
- it can be hard-coded to know where to look to find its own source code for purposes of comparison. Using this knowledge to actually produce the output in the first place, however, is cheating.
Popularity contest; whoever gets the most upvotes wins. No standard loopholes, etc, you know the drill.