function run() { $cases = Lunit::getCases(); $casedata = array(); // Enumerate the cases foreach ($cases as $case) { // Setup report structure $casereport = array(); // Reflect the class to find methods and metadata $r = new ReflectionClass($case); $ml = $r->getMethods(); $skip = false; $meta = LunitUtil::parseDoc($r->getDocComment()); if (!isset($meta['description'])) { $meta['description'] = $case; } $meta['casename'] = $case; if (isset($meta['extensions'])) { $extn = explode(' ', $meta['extensions']); foreach ($extn as $ext) { if (!extension_loaded($ext)) { $skip = true; $skipmsg = "Need extension: " . $ext; } } } $casereport['meta'] = $meta; // Callback if set if ($this->statuscb) { $this->statuscb->onCaseBegin($case, $meta); } if ($this->dblog) { $this->dblog->onCaseBegin($case, $meta); } try { if (!$skip) { $tc = new $case($this); } foreach ($ml as $method) { $methodname = $method->getName(); if ($method->isPublic() && substr($methodname, 0, 1) != '_') { $methodreport = array(); $tmeta = LunitUtil::parseDoc($method->getDocComment()); if (!isset($tmeta['description'])) { $tmeta['description'] = $methodname; } if (!isset($tmeta['repeat'])) { $tmeta['repeat'] = 1; } // Save meta to method report $methodreport['meta'] = $tmeta; // Times to repeat the test $repeat = intval($tmeta['repeat']); // Callback if set, then create timer if ($this->statuscb) { $this->statuscb->onTestBegin($methodname, $tmeta); } if ($this->dblog) { $this->dblog->onTestBegin($methodname, $meta); } $methodreport['skipped'] = false; $tavg = null; $tmax = null; $tmin = null; if (!$skip) { $tm = new Timer(); try { $telapsed = array(); $ttotal = 0; for ($n = 0; $n < $repeat; $n++) { $tm->start(); $tc->{$methodname}(); $tm->stop(); $telapsed[] = $tm->getElapsed() * 1000; $ttotal += $tm->getElapsed() * 1000; } $ttot = math::sum($telapsed); $tavg = math::average($telapsed); $tmin = math::min($telapsed); $tmax = math::max($telapsed); $tdev = math::deviation($telapsed); $methodreport['passed'] = true; $methodreport['message'] = null; if ($repeat > 1) { // console::write('%6.1fms <%6.1fms> %6.1fms ', $tmin, $tavg, $tmax); } else { // console::write('%6.1fms ', $tmax); } if ($this->statuscb) { $this->statuscb->onTestEnd(true, null); } if ($this->dblog) { $this->dblog->onTestEnd(true, null); } } catch (LunitAssertionFailure $f) { $tm->stop(); $methodreport['passed'] = false; $methodreport['message'] = $f->getMessage(); if ($this->statuscb) { $this->statuscb->onTestEnd(false, $f->getMessage()); } if ($this->dblog) { $this->dblog->onTestEnd(false, $f->getMessage()); } } catch (LunitAssertionSkip $f) { $tm->stop(); $methodreport['passed'] = false; $methodreport['skipped'] = true; $methodreport['message'] = 'Skipped'; if ($this->statuscb) { $this->statuscb->onTestEnd(null, $f->getMessage()); } if ($this->dblog) { $this->dblog->onTestEnd(null, $f->getMessage()); } } catch (Exception $e) { $tm->stop(); $methodreport['passed'] = false; $methodreport['message'] = $e->getMessage(); if ($this->statuscb) { $this->statuscb->onTestEnd(false, $e->getMessage()); } if ($this->dblog) { $this->dblog->onTestEnd(false, $f->getMessage()); } } } else { $methodreport['passed'] = false; $methodreport['skipped'] = true; $methodreport['message'] = $skipmsg; $this->statuscb->onTestEnd(null, $skipmsg); if ($this->dblog) { $this->dblog->onTestEnd(null, $skipmsg); } } $methodreport['elapsed'][] = $tm->getElapsed(); $methodreport['average'] = $tavg; $methodreport['minmax'] = array($tmin, $tmax); // Save report $casereport['tests'][$methodname] = $methodreport; } } } catch (Exception $e) { console::writeLn("Skipped due to exception: %s", $e->getMessage()); } $casedata[$case] = $casereport; // Callback if set if ($this->statuscb) { $this->statuscb->onCaseEnd(); } if ($this->dblog) { $this->dblog->onCaseEnd($casereport); } } $this->results = $casedata; }
98158613184731646854608754802513285673669494264747 27227865422124526123045507906391762175841116643793 39850974894692494486368052068371819815910113761040 63490299853191179995399246673356287563758444418220 53154165762550556600954767900019986378970992788078 64797215974157442597089748525751049202572404302198 11405262167097524195464078289767857222196498196134 29687534751215212055058906496964672558760320501154 91133643125025140132825568220788949708373324718483 57376931880125809438719502505545465368409685529830 71223388766326899429481386092863529999034542088544 33995917053899725007399139847689566709529191189337 84790942271541382242627748059894973082898889736963 87206620190357534346248030013849556514356211899613 21043428350991221189032210186899219729536503580454 45921258692976503811486552863113407178171167533442 74150896154954863910644978643565912769523517994679 75951901206636834598184405124056408120655559297841 67644459127085238805625953993846409363249489129468 98499869120140979681802667136467929596221650382127 73907675497041137141887536315127577976650808741634 54192521026103408661173368701953261361195486615212 79435343347066625586018352353537660649186444536550 70517728982618553879543271828187149743971001556862 52973321283417716122503456539069424763416261020226 50641658018819365611278644990768554434421999162162'; // Преобразовать список чисел в массив $array = explode("\r\n", $string); // Вывести сумму чисел массива echo math::sum($array); // 3392787000171382151515600556927976920245731910265213