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

  uses(
    'unittest.TestCase',
    'util.collections.HashTable'
  );

  /**
   * TestCase for create() core functionality
   *
   * @purpose  Unittest
   */
  class CreateTest extends TestCase {
  
    /**
     * Test create() returns an object passed in, for use in fluent
     * interfaces, e.g.
     *
     * <code>
     *   $c= create(new Criteria())->add('bz_id', 20000, EQUAL);
     * </code>
     *
     * @see   http://xp-framework.info/xml/xp.en_US/news/view?184
     */
    #[@test]
    public function createReturnsObjects() {
      $fixture= new Object();
      $this->assertEquals($fixture, create($fixture));
    }

    /**
     * Test create() using short class names
     *
     */
    #[@test]
    public function createWithShortNames() {
      $h= create('new HashTable<String, String>');
      $this->assertEquals(array('String', 'String'), $h->__generic);
    }

    /**
     * Test create() using fully qualified class names
     *
     */
    #[@test]
    public function createWithQualifiedNames() {
      $h= create('new util.collections.HashTable<lang.types.String, lang.types.String>');
      $this->assertEquals(
        array(xp::reflect('lang.types.String'), xp::reflect('lang.types.String')), 
        $h->__generic
      );
    }

    /**
     * Test create() with non-generic classes
     *
     */
    #[@test, @expect('lang.IllegalArgumentException')]
    public function createWithNonGeneric() {
      create('new lang.Object<String>');
    }
  }
?><commit_msg>- Change link from old to new XP Framework news website - Add test that create() invokes constructors<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses(
    'unittest.TestCase',
    'util.collections.Vector',
    'util.collections.HashTable'
  );

  /**
   * TestCase for create() core functionality
   *
   * @purpose  Unittest
   */
  class CreateTest extends TestCase {
  
    /**
     * Test create() returns an object passed in, for use in fluent
     * interfaces, e.g.
     *
     * <code>
     *   $c= create(new Criteria())->add('bz_id', 20000, EQUAL);
     * </code>
     *
     * @see   http://news.xp-framework.net/article/184/2007/05/06/
     */
    #[@test]
    public function createReturnsObjects() {
      $fixture= new Object();
      $this->assertEquals($fixture, create($fixture));
    }

    /**
     * Test create() using short class names
     *
     */
    #[@test]
    public function createWithShortNames() {
      $h= create('new HashTable<String, String>');
      $this->assertEquals(array('String', 'String'), $h->__generic);
    }

    /**
     * Test create() using short class names
     *
     */
    #[@test]
    public function createInvokesConstructor() {
      $this->assertEquals(
        new String('Hello'), 
        create('new util.collections.Vector<lang.types.String>', array(new String('Hello')))->get(0)
      );
    }

    /**
     * Test create() using fully qualified class names
     *
     */
    #[@test]
    public function createWithQualifiedNames() {
      $h= create('new util.collections.HashTable<lang.types.String, lang.types.String>');
      $this->assertEquals(
        array(xp::reflect('lang.types.String'), xp::reflect('lang.types.String')), 
        $h->__generic
      );
    }

    /**
     * Test create() with non-generic classes
     *
     */
    #[@test, @expect('lang.IllegalArgumentException')]
    public function createWithNonGeneric() {
      create('new lang.Object<String>');
    }
  }
?>
{'fraction_non_alphanumeric': 0.15782122905027932, 'fraction_numerical': 0.006983240223463687, 'mean_word_length': 2.44990366088632, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '4230027', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1093, 'n_words': 240}