<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses(
    'unittest.TestCase',
    'net.xp_framework.unittest.core.generics.Lookup',
    'lang.types.String'
  );

  /**
   * TestCase for definition reflection
   *
   * @see   xp://net.xp_framework.unittest.core.generics.Lookup
   */
  class DefinitionReflectionTest extends TestCase {
    protected $fixture= NULL;
    
    /**
     * Creates fixture, a Lookup class
     *
     */  
    public function setUp() {
      $this->fixture= XPClass::forName('net.xp_framework.unittest.core.generics.Lookup');
    }
  
    /**
     * Test isGenericDefinition()
     *
     */
    #[@test]
    public function isAGenericDefinition() {
      $this->assertTrue($this->fixture->isGenericDefinition());
    }

    /**
     * Test isGenericDefinition()
     *
     */
    #[@test]
    public function isNotAGeneric() {
      $this->assertFalse($this->fixture->isGeneric());
    }

    /**
     * Test genericComponents()
     *
     */
    #[@test]
    public function components() {
      $this->assertEquals(array('K', 'V'), $this->fixture->genericComponents());
    }

    /**
     * Test newGenericType()
     *
     */
    #[@test]
    public function newGenericTypeIsGeneric() {
      $t= $this->fixture->newGenericType(array(
        XPClass::forName('lang.types.String'), 
        XPClass::forName('unittest.TestCase')
      ));
      $this->assertTrue($t->isGeneric());
    }

    /**
     * Test newGenericType()
     *
     */
    #[@test]
    public function newLookupWithStringAndTestCase() {
      $arguments= array(
        XPClass::forName('lang.types.String'), 
        XPClass::forName('unittest.TestCase')
      );
      $this->assertEquals(
        $arguments, 
        $this->fixture->newGenericType($arguments)->genericArguments()
      );
    }

    /**
     * Test newGenericType()
     *
     */
    #[@test]
    public function newLookupWithStringAndObject() {
      $arguments= array(
        XPClass::forName('lang.types.String'), 
        XPClass::forName('lang.Object')
      );
      $this->assertEquals(
        $arguments, 
        $this->fixture->newGenericType($arguments)->genericArguments()
      );
    }

    /**
     * Test classes created via newGenericType() and from an instance
     * instantiated via create() are equal.
     *
     */
    #[@test]
    public function classesFromReflectionAndCreateAreEqual() {
      $this->assertEquals(
        create('new net.xp_framework.unittest.core.generics.Lookup<String, TestCase>()')->getClass(),
        $this->fixture->newGenericType(array(
          XPClass::forName('lang.types.String'), 
          XPClass::forName('unittest.TestCase')
        ))
      );
    }

    /**
     * Test newGenericType()
     *
     */<commit_msg>- Add test for reflective "new T<string, Object>" creation<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses(
    'unittest.TestCase',
    'net.xp_framework.unittest.core.generics.Lookup',
    'lang.types.String'
  );

  /**
   * TestCase for definition reflection
   *
   * @see   xp://net.xp_framework.unittest.core.generics.Lookup
   */
  class DefinitionReflectionTest extends TestCase {
    protected $fixture= NULL;
    
    /**
     * Creates fixture, a Lookup class
     *
     */  
    public function setUp() {
      $this->fixture= XPClass::forName('net.xp_framework.unittest.core.generics.Lookup');
    }
  
    /**
     * Test isGenericDefinition()
     *
     */
    #[@test]
    public function isAGenericDefinition() {
      $this->assertTrue($this->fixture->isGenericDefinition());
    }

    /**
     * Test isGenericDefinition()
     *
     */
    #[@test]
    public function isNotAGeneric() {
      $this->assertFalse($this->fixture->isGeneric());
    }

    /**
     * Test genericComponents()
     *
     */
    #[@test]
    public function components() {
      $this->assertEquals(array('K', 'V'), $this->fixture->genericComponents());
    }

    /**
     * Test newGenericType()
     *
     */
    #[@test]
    public function newGenericTypeIsGeneric() {
      $t= $this->fixture->newGenericType(array(
        XPClass::forName('lang.types.String'), 
        XPClass::forName('unittest.TestCase')
      ));
      $this->assertTrue($t->isGeneric());
    }

    /**
     * Test newGenericType()
     *
     */
    #[@test]
    public function newLookupWithStringAndTestCase() {
      $arguments= array(
        XPClass::forName('lang.types.String'), 
        XPClass::forName('unittest.TestCase')
      );
      $this->assertEquals(
        $arguments, 
        $this->fixture->newGenericType($arguments)->genericArguments()
      );
    }

    /**
     * Test newGenericType()
     *
     */
    #[@test]
    public function newLookupWithStringAndObject() {
      $arguments= array(
        XPClass::forName('lang.types.String'), 
        XPClass::forName('lang.Object')
      );
      $this->assertEquals(
        $arguments, 
        $this->fixture->newGenericType($arguments)->genericArguments()
      );
    }

    /**
     * Test newGenericType()
     *
     */
    #[@test]
    public function newLookupWithPrimitiveStringAndObject() {
      $arguments= array(
        Primitive::$STRING,
        XPClass::forName('lang.Object')
      );
      $this->assertEquals(
        $arguments, 
        $this->fixture->newGenericType($arguments)->genericArguments()
      );
    }

    /**
     * Test classes created via newGenericType() and from an instance
     * instantiated via create() are equal.
     *
     */
    #[@test]
    public function classesFromReflectionAndCreateAreEqual() {
      $this->assertEquals(
        create('new net.xp_framework.unittest.core.generics.Lookup<String, TestCase>()')->getClass(),
        $this->fixture->newGenericType(array(
          XPClass::forName('lang.types.String'), 
          XPClass::forName('unittest.TestCase')
        ))
      );
    }

    /**
     * Test newGenericType()
     *
     */
{'fraction_non_alphanumeric': 0.153628023352794, 'fraction_numerical': 0.0, 'mean_word_length': 2.314538419016031, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 62, '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': '3961141', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1766, 'n_words': 269}