<commit_before><?php

namespace KlassTest {
    class Base extends \Object { }
    class User extends Base { }
    class Module {
        static function static_method() { }
        function test_method() { }
        function another_test_method() { }
    }
    class AnotherModule { }
    class UserWithModules extends Base { }
}

namespace {
    class KlassTest extends ztest\UnitTestCase {

        function setup() {
            $this->user_class = new Klass('KlassTest\User');
            $this->user_class_with_modules = Klass::instance('KlassTest\UserWithModules');
            $this->user_class_with_modules->__include('KlassTest\Module');
            $this->object_class = new Klass('Object');
            Klass::instance('KlassTest\Module')->__include('KlassTest\AnotherModule');
        }

        function test_should_create_a_new_real_class_at_runtime() {
            ensure(!class_exists('KlassTest\RuntimeCreatedClass'));
            $class = new Klass('KlassTest\RuntimeCreatedClass');
            ensure(class_exists('KlassTest\RuntimeCreatedClass'));
        }

        function test_should_not_create_a_new_real_class_at_runtime() {
            ensure(!class_exists('KlassTest\RuntimeCreatedClass2'));
            assert_throws('InvalidArgumentException', function() { new Klass('KlassTest\RuntimeCreatedClass2', null, false); });
            ensure(!class_exists('KlassTest\RuntimeCreatedClass2'));
        }

        function test_should_add_module_to_included_modules() {
            $property = new \ReflectionProperty($this->user_class_with_modules, '_included_modules');
            $property->setAccessible(true);
            assert_equal(array(Klass::instance('KlassTest\Module')), $property->getValue($this->user_class_with_modules));
        }

        function test_should_throw_cyclic_include_error() {
            assert_throws('InvalidArgumentException', function() {
                Klass::instance('KlassTest\AnotherModule')->__include('KlassTest\Module');
            });
        }

        function test_should_return_ancestors() {
            $ancestors = array(Klass::instance('KlassTest\User'), Klass::instance('KlassTest\Base'), Klass::instance('Object\InstanceMethods'), Klass::instance('Object'));
            assert_equal($ancestors, $this->user_class->ancestors());
        }

        function test_should_return_ancestors_with_unique_included_modules() {
            $ancestors = array(Klass::instance('KlassTest\AnotherModule'), Klass::instance('KlassTest\Module'), Klass::instance('KlassTest\UserWithModules'), Klass::instance('KlassTest\Base'), Klass::instance('Object\InstanceMethods'), Klass::instance('Object'));
            assert_equal($ancestors, $this->user_class_with_modules->ancestors());
            Klass::instance('KlassTest\UserWithModules')->__include('KlassTest\AnotherModule');
            assert_equal($ancestors, $this->user_class_with_modules->ancestors());
        }

        function test_should_return_unique_included_modules() {
            $included_modules = array(Klass::instance('KlassTest\AnotherModule'), Klass::instance('KlassTest\Module'), Klass::instance('Object\InstanceMethods'));
            assert_equal($included_modules, $this->user_class_with_modules->included_modules());
            Klass::instance('KlassTest\UserWithModules')->__include('KlassTest\AnotherModule');
            assert_equal($included_modules, $this->user_class_with_modules->included_modules());
        }

        function test_should_return_correct_name() {
            assert_equal('KlassTest\User', $this->user_class->name());
        }

        function test_should_return_class_reflector() {
            assert_identical(ClassReflector::instance('KlassTest\User'), $this->user_class->reflection());
        }

        function test_should_return_superclass() {
            assert_equal(new Klass('KlassTest\Base'), $this->user_class->superclass());
            assert_equal(null, $this->object_class->superclass());
        }

        function test_should_return_same_instance() {
            $object = Klass::instance('Object');
            assert_identical($object, Klass::instance('Object'));
            assert_identical($object, Klass::instance($object));
            assert_throws('InvalidArgumentException', function() { Klass::instance('KlassTest\NonExistentClass'); });
        }

        function test_should_return_to_s() {
            ob_start();
            echo $this->user_class;
            $implicit = ob_get_clean();
            $concatenation = ''.$this->user_class.'';
            assert_all_equal($this->user_class->name(), $this->user_class->to_s(), $implicit, $concatenation);
        }

        function test_should_return_instance_methods() {
            $methods = $this->user_class_with_modules->instance_methods();
            assert_in_array('test_method', $methods);
            assert_not_in_array('static_test_method', $methods);
        }

        function test_should_return_instance_methods_without_super() {
            $methods = $this->user_class_with_modules->instance_methods();
            $methods_without_super = $this->user_class_with_modules->instance_methods(false);
            assert_not_equal($methods, $methods_without_super);
            ensure(count($methods) > count($methods_without_super));
            sort($methods_without_super);
            assert_equal(array('another_test_method', 'test_method'), $methods_without_super);
        }

    }
}<commit_msg>add failing Klass test<commit_after><?php

namespace KlassTest {
    class Base extends \Object { }
    class User extends Base { }
    class Module {
        static function static_method() { }
        function test_method() { }
        function another_test_method() { }
    }
    class AnotherModule { }
    class UserWithModules extends Base {
        static function test_static_method() {
            return true;
        }
    }
}

namespace {
    class KlassTest extends ztest\UnitTestCase {

        function setup() {
            $this->user_class = new Klass('KlassTest\User');
            $this->user_class_with_modules = Klass::instance('KlassTest\UserWithModules');
            $this->user_class_with_modules->__include('KlassTest\Module');
            $this->object_class = new Klass('Object');
            Klass::instance('KlassTest\Module')->__include('KlassTest\AnotherModule');
        }

        function test_should_create_a_new_real_class_at_runtime() {
            ensure(!class_exists('KlassTest\RuntimeCreatedClass'));
            $class = new Klass('KlassTest\RuntimeCreatedClass');
            ensure(class_exists('KlassTest\RuntimeCreatedClass'));
        }

        function test_should_not_create_a_new_real_class_at_runtime() {
            ensure(!class_exists('KlassTest\RuntimeCreatedClass2'));
            assert_throws('InvalidArgumentException', function() { new Klass('KlassTest\RuntimeCreatedClass2', null, false); });
            ensure(!class_exists('KlassTest\RuntimeCreatedClass2'));
        }

        function test_should_add_module_to_included_modules() {
            $property = new \ReflectionProperty($this->user_class_with_modules, '_included_modules');
            $property->setAccessible(true);
            assert_equal(array(Klass::instance('KlassTest\Module')), $property->getValue($this->user_class_with_modules));
        }

        function test_should_throw_cyclic_include_error() {
            assert_throws('InvalidArgumentException', function() {
                Klass::instance('KlassTest\AnotherModule')->__include('KlassTest\Module');
            });
        }

        function test_should_return_ancestors() {
            $ancestors = array(Klass::instance('KlassTest\User'), Klass::instance('KlassTest\Base'), Klass::instance('Object\InstanceMethods'), Klass::instance('Object'));
            assert_equal($ancestors, $this->user_class->ancestors());
        }

        function test_should_return_ancestors_with_unique_included_modules() {
            $ancestors = array(Klass::instance('KlassTest\AnotherModule'), Klass::instance('KlassTest\Module'), Klass::instance('KlassTest\UserWithModules'), Klass::instance('KlassTest\Base'), Klass::instance('Object\InstanceMethods'), Klass::instance('Object'));
            assert_equal($ancestors, $this->user_class_with_modules->ancestors());
            Klass::instance('KlassTest\UserWithModules')->__include('KlassTest\AnotherModule');
            assert_equal($ancestors, $this->user_class_with_modules->ancestors());
        }

        function test_should_return_unique_included_modules() {
            $included_modules = array(Klass::instance('KlassTest\AnotherModule'), Klass::instance('KlassTest\Module'), Klass::instance('Object\InstanceMethods'));
            assert_equal($included_modules, $this->user_class_with_modules->included_modules());
            Klass::instance('KlassTest\UserWithModules')->__include('KlassTest\AnotherModule');
            assert_equal($included_modules, $this->user_class_with_modules->included_modules());
        }

        function test_should_return_correct_name() {
            assert_equal('KlassTest\User', $this->user_class->name());
        }

        function test_should_return_class_reflector() {
            assert_identical(ClassReflector::instance('KlassTest\User'), $this->user_class->reflection());
        }

        function test_should_return_superclass() {
            assert_equal(new Klass('KlassTest\Base'), $this->user_class->superclass());
            assert_equal(null, $this->object_class->superclass());
        }

        function test_should_return_same_instance() {
            $object = Klass::instance('Object');
            assert_identical($object, Klass::instance('Object'));
            assert_identical($object, Klass::instance($object));
            assert_throws('InvalidArgumentException', function() { Klass::instance('KlassTest\NonExistentClass'); });
        }

        function test_should_return_to_s() {
            ob_start();
            echo $this->user_class;
            $implicit = ob_get_clean();
            $concatenation = ''.$this->user_class.'';
            assert_all_equal($this->user_class->name(), $this->user_class->to_s(), $implicit, $concatenation);
        }

        function test_should_return_instance_methods() {
            $methods = $this->user_class_with_modules->instance_methods();
            assert_in_array('test_method', $methods);
            assert_not_in_array('static_test_method', $methods);
        }

        function test_should_return_instance_methods_without_super() {
            $methods = $this->user_class_with_modules->instance_methods();
            $methods_without_super = $this->user_class_with_modules->instance_methods(false);
            assert_not_equal($methods, $methods_without_super);
            ensure(count($methods) > count($methods_without_super));
            sort($methods_without_super);
            assert_equal(array('another_test_method', 'test_method'), $methods_without_super);
        }

        function test_should_call_class_method() {
            ensure(KlassTest\UserWithModules::test_static_method());
            ensure($this->user_class_with_modules->test_static_method());
        }

    }
}
{'fraction_non_alphanumeric': 0.12855366027007817, 'fraction_numerical': 0.0005330490405117271, 'mean_word_length': 3.4162416633974106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 93, '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': '889660', 'n_tokens_mistral': 3102, 'n_tokens_neox': 3042, 'n_words': 350}