Hywan / atoum-instrumentation

The atoum\instrumentation library. Instrumentation for PHP (moles, code coverage…)
7 stars 2 forks source link

Instrumentation of closures #3

Closed jubianchi closed 10 years ago

jubianchi commented 10 years ago

Given the following source code:

<?php

$closure = function () {
    return rand(0, PHP_INT_MAX);
};

$closure();

When running the test script, we get the following instrumented code:

<?php

$closure = function  (  { if(\atoum\instrumentation\mole::exists(__CLASS__ . '::')) return \atoum\instrumentation\mole::call(__CLASS__ . '::', func_get_args()); {
    mark_line(__LINE__);return rand(0, PHP_INT_MAX);
};mark_line(__LINE__);

$closure();mark_line(__LINE__);
Hywan commented 10 years ago

Problem solved.