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

  /**
   * Indicates an assertion failed
   *
   * @test    xp://net.xp_framework.unittest.tests.AssertionMessagesTest
   */
  class AssertionFailedError extends XPException {
    public
      $actual       = NULL,
      $expect       = NULL;
      
    /**
     * Constructor
     *
     * @param   string message
     * @param   string errorcode
     * @param   var actual default NULL
     * @param   var expect default NULL
     */
    public function __construct($message, $actual= NULL, $expect= NULL) {
      parent::__construct((string)$message);
      $this->actual= $actual;
      $this->expect= $expect;
    }

    /**
     * Creates a string representation of a given value.
     *
     * @param   var value
     * @param   string type NULL if type name should be not included.
     * @return  string
     */
    protected function stringOf($value, $type) {
      return (NULL === $type ? '' : $type.':').xp::stringOf($value);
    }

    /**
     * Return compound message of this exception.
     *
     * @return  string
     */
    public function compoundMessage() {
      $te= xp::typeOf($this->expect);
      $ta= xp::typeOf($this->actual);
      if ($this->expect instanceof Generic && $this->actual instanceof Generic) {
        $include= FALSE;
      } else {
        $include= $te !== $ta;
      }
      return sprintf(
        "%s { expected [%s] but was [%s] (using %s) }\n",
        $this->getClassName(),
        $this->stringOf($this->expect, $include ? $te : NULL),
        $this->stringOf($this->actual, $include ? $ta : NULL),
        $this->message
      );
    }
    
    /**
     * Retrieve string representation
     *
     * @return  string
     */
    public function toString() {
      $s= $this->compoundMessage();
      
      // Slice first stack trace element, this is always unittest.TestCase::fail()
      // Also don't show the arguments
      for ($i= 1, $t= sizeof($this->trace); $i < $t; $i++) {
        $this->trace[$i]->args= NULL;
        $s.= $this->trace[$i]->toString();
      }
      return $s;
    }
  }
?>
<commit_msg>- slightly reformat error message<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  /**
   * Indicates an assertion failed
   *
   * @test    xp://net.xp_framework.unittest.tests.AssertionMessagesTest
   */
  class AssertionFailedError extends XPException {
    public
      $actual       = NULL,
      $expect       = NULL;
      
    /**
     * Constructor
     *
     * @param   string message
     * @param   string errorcode
     * @param   var actual default NULL
     * @param   var expect default NULL
     */
    public function __construct($message, $actual= NULL, $expect= NULL) {
      parent::__construct((string)$message);
      $this->actual= $actual;
      $this->expect= $expect;
    }

    /**
     * Creates a string representation of a given value.
     *
     * @param   var value
     * @param   string type NULL if type name should be not included.
     * @return  string
     */
    protected function stringOf($value, $type) {
      return (NULL === $type ? '' : $type.':').xp::stringOf($value);
    }

    /**
     * Return compound message of this exception.
     *
     * @return  string
     */
    public function compoundMessage() {
      $te= xp::typeOf($this->expect);
      $ta= xp::typeOf($this->actual);
      if ($this->expect instanceof Generic && $this->actual instanceof Generic) {
        $include= FALSE;
      } else {
        $include= $te !== $ta;
      }
      return sprintf(
        "%s { expected [%s] but was [%s] using: '%s' }\n",
        $this->getClassName(),
        $this->stringOf($this->expect, $include ? $te : NULL),
        $this->stringOf($this->actual, $include ? $ta : NULL),
        $this->message
      );
    }
    
    /**
     * Retrieve string representation
     *
     * @return  string
     */
    public function toString() {
      $s= $this->compoundMessage();
      
      // Slice first stack trace element, this is always unittest.TestCase::fail()
      // Also don't show the arguments
      for ($i= 1, $t= sizeof($this->trace); $i < $t; $i++) {
        $this->trace[$i]->args= NULL;
        $s.= $this->trace[$i]->toString();
      }
      return $s;
    }
  }
?>

{'fraction_non_alphanumeric': 0.15021955165241507, 'fraction_numerical': 0.00046221400508435407, 'mean_word_length': 2.052186177715092, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, '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': '4227022', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1294, 'n_words': 350}