<commit_before><?php

use PHPUnit\Framework\TestCase;

class TypeTest extends TestCase {

    public function testBuiltinClasses() {
        global $object;
        global $type;

        assertEquals(type($type), $type);
        assertEquals(type($object), $type);

        assertTrue(isinstance($type, $type));

        assertTrue(issubclass($type, $object));
        assertFalse(issubclass($object, $type));
    }

    public function testBasicClassCreation() {
        global $object;
        global $type;

        $A = type('A', [], dict());

        assertEquals($A->__name__, 'A');
        assertEquals($A->__bases__, [$object]);
        assertEquals($A->__mro__, [$A, $object]);
        assertEquals($A->__dict__, dict());
        assertEquals($A->__class__, $type);

        assertTrue($A->__is_class__);
        assertFalse($A->__is_metaclass__);
    }

    public function testAdvancedClassCreation() {
        global $object;
        global $type;
        $A = type('A', [], dict());
        $B = type('B', [], dict());
        $C = type('C', [$A, $B], dict());

        assertEquals($C->__bases__, [$A, $B]);
        assertEquals($C->__mro__, [$C, $A, $B, $object]);
    }

    // public function testClassMetaClassRelations() {
    //     global $object;
    //     global $type;
    //
    //     // this is made sure in previous tests
    //     $A = type('A', [], dict());
    //     assertEquals(type($A), $type);
    //
    //     // TODO: move the following assertions to OopTest
    //     assertTrue(isinstance($A, $type));
    //
    //     assertFalse(issubclass($A, $type));
    //     assertTrue(issubclass($A, $object));
    //
    //
    //     // class A(metaclass=type): pass
    //     // isinstance(A, type) -> True
    //     // a = A()
    //     // isinstance(a, type) -> False
    // }<commit_msg>added metaclass creation test<commit_after><?php

use PHPUnit\Framework\TestCase;

class TypeTest extends TestCase {

    public function testBuiltinClasses() {
        global $object;
        global $type;

        assertEquals(type($type), $type);
        assertEquals(type($object), $type);

        assertTrue(isinstance($type, $type));

        assertTrue(issubclass($type, $object));
        assertFalse(issubclass($object, $type));
    }

    public function testMetaclassCreation() {
        global $type;

        $meta = type('Meta', [$type], dict());
        assertTrue(isinstance($meta, $type));
    }

    public function testBasicClassCreation() {
        global $object;
        global $type;

        $A = type('A', [], dict());

        assertEquals($A->__name__, 'A');
        assertEquals($A->__bases__, [$object]);
        assertEquals($A->__mro__, [$A, $object]);
        assertEquals($A->__dict__, dict());
        assertEquals($A->__class__, $type);

        assertTrue($A->__is_class__);
        assertFalse($A->__is_metaclass__);
    }

    public function testAdvancedClassCreation() {
        global $object;
        global $type;
        $A = type('A', [], dict());
        $B = type('B', [], dict());
        $C = type('C', [$A, $B], dict());

        assertEquals($C->__bases__, [$A, $B]);
        assertEquals($C->__mro__, [$C, $A, $B, $object]);
        assertEquals($C->__class__, $type);
    }

    // public function testClassMetaClassRelations() {
    //     global $object;
    //     global $type;
    //
    //     // this is made sure in previous tests
    //     $A = type('A', [], dict());
    //     assertEquals(type($A), $type);
    //
    //     // TODO: move the following assertions to OopTest
    //     assertTrue(isinstance($A, $type));
    //
    //     assertFalse(issubclass($A, $type));
    //     assertTrue(issubclass($A, $object));
    //
    //
    //     // class A(metaclass=type): pass
    //     // isinstance(A, type) -> True
    //     // a = A()
    //     // isinstance(a, type) -> False
    // }
{'fraction_non_alphanumeric': 0.18321785989222478, 'fraction_numerical': 0.0, 'mean_word_length': 2.146085552865214, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, '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': '5485430', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1160, 'n_words': 248}