Skip to content

Instantly share code, notes, and snippets.

@speedmax
Created August 20, 2008 06:25
Show Gist options
  • Save speedmax/6328 to your computer and use it in GitHub Desktop.
Save speedmax/6328 to your computer and use it in GitHub Desktop.
<?php
require 'lib/Lambda.php';
require 'lib/shortcuts.php';
function describe($context, $examples) {
$instance = new stdClass;
if (isset($examples['before']) && $before = $examples['before'])
unset($examples['before']);
if (isset($examples['after']) && $after = $examples['after'])
unset($examples['after']);
$before->call($instance);
foreach ($examples as $description => $example) {
$example->call($instance);
}
$after->call($instance);
print_r($instance);
}
class EmulateStatement { function expect() {} }
function with() {
return new EmulateStatement;
}
describe('string', array(
'before' => def(& $self)?
$self = 'your mum'
:fed(),
'should have a length' => def(& $self)?
print_r($self)
:fed(),
));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment