<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */
 
  uses('unittest.TestCase', 'lang.types.String', 'lang.types.ArrayList');

  /**
   * Test assertion methods
   *
   * @purpose  Unit Test
   */
  class AssertionsTest extends TestCase {

    /**
     * Test assertTrue()
     *
     */    
    #[@test]
    public function trueIsTrue() {
      $this->assertTrue(TRUE);
    }

    /**
     * Test assertTrue()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function falseIsNotTrue() {
      $this->assertTrue(FALSE);
    }

    /**
     * Test assertFalse()
     *
     */    
    #[@test]
    public function falseIsFalse() {
      $this->assertFalse(FALSE);
    }

    /**
     * Test assertFalse()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function trueIsNotFalse() {
      $this->assertFalse(TRUE);
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test]
    public function NullIsNull() {
      $this->assertNull(NULL);
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function falseIsNotNull() {
      $this->assertNull(FALSE);
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function zeroIsNotNull() {
      $this->assertNull(0);
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function emptyStringIsNotNull() {
      $this->assertNull('');
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function emptyArrayIsNotNull() {
      $this->assertNull(array());
    }

    /**
     * Test assertEquals() and assertNotEquals() invoke equals() methods 
     * on objects.
     *
     */    
    #[@test]
    public function equalsMethodIsInvoked() {
      $instance= newinstance('lang.Object', array(), '{
         public $equalsInvoked= 0;

        function equals($other) {
          $r= (
            is(get_class($this), $other) && 
            $this->equalsInvoked == $other->equalsInvoked
          );
          $this->equalsInvoked++;
          return $r;
        }
      }');
     
      $this->assertEquals($instance, $instance);
      $this->assertNotEquals($instance, NULL);
      $this->assertEquals(2, $instance->equalsInvoked);
    }
<commit_msg>- QA: Simplify source inside equalsMethodIsInvoked() test<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */
 
  uses('unittest.TestCase', 'lang.types.String', 'lang.types.ArrayList');

  /**
   * Test assertion methods
   *
   * @purpose  Unit Test
   */
  class AssertionsTest extends TestCase {

    /**
     * Test assertTrue()
     *
     */    
    #[@test]
    public function trueIsTrue() {
      $this->assertTrue(TRUE);
    }

    /**
     * Test assertTrue()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function falseIsNotTrue() {
      $this->assertTrue(FALSE);
    }

    /**
     * Test assertFalse()
     *
     */    
    #[@test]
    public function falseIsFalse() {
      $this->assertFalse(FALSE);
    }

    /**
     * Test assertFalse()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function trueIsNotFalse() {
      $this->assertFalse(TRUE);
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test]
    public function NullIsNull() {
      $this->assertNull(NULL);
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function falseIsNotNull() {
      $this->assertNull(FALSE);
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function zeroIsNotNull() {
      $this->assertNull(0);
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function emptyStringIsNotNull() {
      $this->assertNull('');
    }

    /**
     * Test assertNull()
     *
     */    
    #[@test, @expect('unittest.AssertionFailedError')]
    public function emptyArrayIsNotNull() {
      $this->assertNull(array());
    }

    /**
     * Test assertEquals() and assertNotEquals() invoke equals() methods 
     * on objects.
     *
     */    
    #[@test]
    public function equalsMethodIsInvoked() {
      $instance= newinstance('lang.Object', array(), '{
        public $equalsInvoked= 0;

        public function equals($other) {
          $this->equalsInvoked++;
          return $other instanceof self && $this->equalsInvoked == $other->equalsInvoked;
        }
      }');
     
      $this->assertEquals($instance, $instance);
      $this->assertNotEquals($instance, NULL);
      $this->assertEquals(2, $instance->equalsInvoked);
    }

{'fraction_non_alphanumeric': 0.15765131711240699, 'fraction_numerical': 0.0012065151819827067, 'mean_word_length': 2.062807881773399, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '2371444', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1498, 'n_words': 260}