Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brzuchal/5aeec672207bc9df4898ba99d6f7b369 to your computer and use it in GitHub Desktop.
Save brzuchal/5aeec672207bc9df4898ba99d6f7b369 to your computer and use it in GitHub Desktop.
A unit testing framework in a tweet.
<?php
require_once 'TestFrameworkInATweet.php';
it("should sum two numbers", 1+1==2);
it("should display an X for a failing test", 1+1==3);
<?php function it($m,$p){echo"\e[3".($p?"2m✔︎":"1m✘")."\e[0m It $m\n";if(!$p){$GLOBALS['e']=1;$d=debug_backtrace()[0];echo"ERROR {$d['file']}@{$d['line']}\n";}}register_shutdown_function(function(){echo"\e[1;3".(($e=@$GLOBALS['e'])?"7;41mFAIL":"2mOK")."\e[0m\n";die($e);});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment