<commit_before><?php
use Peridot\Core\Spec;
use Peridot\Core\SpecResult;
use Peridot\Core\Suite;
use Peridot\Test\ItWasRun;

describe("Suite", function() {

    describe('->run()', function() {
        it("should run multiple specs", function () {
            $suite = new Suite("Suite", function() {});
            $suite->addSpec(new ItWasRun("should pass", function () {}));
            $suite->addSpec(new ItWasRun('should fail', function () {
                throw new \Exception('woooooo!');
            }));

            $result = new SpecResult();
            $suite->run($result);
            assert('2 run, 1 failed' == $result->getSummary(), "result summary should show 2/1");
        });

        it("should pass setup functions to specs", function() {
            $suite = new Suite("Suite", function() {});
            $suite->addSetUpFunction(function() {
                $this->log = "setup";
            });

            $fn = function() {
                assert($this->log == "setup", "should have setup in log");
            };

            $suite->addSpec(new ItWasRun("should have log", $fn));
            $suite->addSpec(new ItWasRun("should also have log", $fn));

            $result = new SpecResult();
            $suite->run($result);
            assert('2 run, 0 failed' == $result->getSummary(), "result summary should show 2/0");
        });

        it("should pass teardown functions to specs", function() {
            $suite = new Suite("Suite", function() {});
            $suite->addTearDownFunction(function() {
                $this->log = "torn";
            });

            $fn = function() {};

            $spec1 = new ItWasRun("should have log", $fn);
            $spec2 = new ItWasRun("should have log too", $fn);
            $suite->addSpec($spec1);
            $suite->addSpec($spec2);

            $result = new SpecResult();
            $suite->run($result);

            assert('torntorn' == $spec1->log . $spec2->log, "tear down should have run for both specs");
        });

        it("should emit a suite:start event", function() {
            $suite = new Suite("Suite", function() {});
            $emitted = null;
            $suite->on('suite:start', function($s) use (&$emitted) {
                $emitted = $s;
            });
            $suite->run(new SpecResult());
            assert($suite === $emitted, 'suite start event should have been emitted');
        });

        it("should emit a suite:end event", function() {
            $suite = new Suite("Suite", function() {});
            $emitted = null;
            $suite->on('suite:end', function($s) use (&$emitted) {
                $emitted = $s;
            });
            $suite->run(new SpecResult());
            assert($suite === $emitted, 'suite end event should have been emitted');
        });
    });

    describe("->addSpec()", function() {

        it("should set parent property on child spec", function() {
            $suite = new Suite("test suite", function() {});
            $spec = new Spec("test spec", function() {});
            $suite->addSpec($spec);
            assert($spec->getParent() === $suite, "added spec should have parent property set");
        });

    });
});
<commit_msg>test suite pending status is transferred<commit_after><?php
use Peridot\Core\Spec;
use Peridot\Core\SpecResult;
use Peridot\Core\Suite;
use Peridot\Test\ItWasRun;

describe("Suite", function() {

    describe('->run()', function() {
        it("should run multiple specs", function () {
            $suite = new Suite("Suite", function() {});
            $suite->addSpec(new ItWasRun("should pass", function () {}));
            $suite->addSpec(new ItWasRun('should fail', function () {
                throw new \Exception('woooooo!');
            }));

            $result = new SpecResult();
            $suite->run($result);
            assert('2 run, 1 failed' == $result->getSummary(), "result summary should show 2/1");
        });

        it("should pass setup functions to specs", function() {
            $suite = new Suite("Suite", function() {});
            $suite->addSetUpFunction(function() {
                $this->log = "setup";
            });

            $fn = function() {
                assert($this->log == "setup", "should have setup in log");
            };

            $suite->addSpec(new ItWasRun("should have log", $fn));
            $suite->addSpec(new ItWasRun("should also have log", $fn));

            $result = new SpecResult();
            $suite->run($result);
            assert('2 run, 0 failed' == $result->getSummary(), "result summary should show 2/0");
        });

        it("should pass teardown functions to specs", function() {
            $suite = new Suite("Suite", function() {});
            $suite->addTearDownFunction(function() {
                $this->log = "torn";
            });

            $fn = function() {};

            $spec1 = new ItWasRun("should have log", $fn);
            $spec2 = new ItWasRun("should have log too", $fn);
            $suite->addSpec($spec1);
            $suite->addSpec($spec2);

            $result = new SpecResult();
            $suite->run($result);

            assert('torntorn' == $spec1->log . $spec2->log, "tear down should have run for both specs");
        });

        it("should set pending status on specs if not null", function() {
            $suite = new Suite("Suite", function() {});
            $suite->setPending(true);
            $fn = function() {};

            $spec1 = new ItWasRun("should have log", $fn);
            $suite->addSpec($spec1);

            $result = new SpecResult();
            $suite->run($result);

            assert($spec1->getPending(), "spec should be pending");
        });

        it("should emit a suite:start event", function() {
            $suite = new Suite("Suite", function() {});
            $emitted = null;
            $suite->on('suite:start', function($s) use (&$emitted) {
                $emitted = $s;
            });
            $suite->run(new SpecResult());
            assert($suite === $emitted, 'suite start event should have been emitted');
        });

        it("should emit a suite:end event", function() {
            $suite = new Suite("Suite", function() {});
            $emitted = null;
            $suite->on('suite:end', function($s) use (&$emitted) {
                $emitted = $s;
            });
            $suite->run(new SpecResult());
            assert($suite === $emitted, 'suite end event should have been emitted');
        });
    });

    describe("->addSpec()", function() {

        it("should set parent property on child spec", function() {
            $suite = new Suite("test suite", function() {});
            $spec = new Spec("test spec", function() {});
            $suite->addSpec($spec);
            assert($spec->getParent() === $suite, "added spec should have parent property set");
        });

    });
});

{'fraction_non_alphanumeric': 0.17007194244604318, 'fraction_numerical': 0.004460431654676259, 'mean_word_length': 1.9616531742650192, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7517357', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1844, 'n_words': 496}