cvs: pear(ZEND_ENGINE_2) /PHPUnit package.xml /PHPUnit/Framework Assert.php ComparisonFailure.php
| From: | Sebastian Bergmann | Date: | Sun, 08 Jun 2003 09:08:56 +0000 |
| Subject: | cvs: pear(ZEND_ENGINE_2) /PHPUnit package.xml /PHPUnit/Framework Assert.php ComparisonFailure.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-10762@lists.php.net to get a copy of this message | ||
sebastian Sun Jun 8 05:08:56 2003 EDT
Added files: (Branch: ZEND_ENGINE_2)
/pear/PHPUnit/Framework ComparisonFailure.php
Modified files:
/pear/PHPUnit package.xml
/pear/PHPUnit/Framework Assert.php
Log:
Introduce ComparisonFailure.
Index: pear/PHPUnit/package.xml
diff -u pear/PHPUnit/package.xml:1.22.2.15 pear/PHPUnit/package.xml:1.22.2.16
--- pear/PHPUnit/package.xml:1.22.2.15 Sun Jun 8 04:37:13 2003
+++ pear/PHPUnit/package.xml Sun Jun 8 05:08:56 2003
@@ -48,6 +48,7 @@
<dir name="Framework">
<file role="php">Assert.php</file>
<file role="php">AssertionFailedError.php</file>
+ <file role="php">ComparisonFailure.php</file>
<file role="php">Test.php</file>
<file role="php">TestCase.php</file>
<file role="php">TestFailure.php</file>
Index: pear/PHPUnit/Framework/Assert.php
diff -u pear/PHPUnit/Framework/Assert.php:1.1.2.2 pear/PHPUnit/Framework/Assert.php:1.1.2.3
--- pear/PHPUnit/Framework/Assert.php:1.1.2.2 Sat Jun 7 02:25:59 2003
+++ pear/PHPUnit/Framework/Assert.php Sun Jun 8 05:08:56 2003
@@ -12,10 +12,11 @@
// | license@php.net so we can mail you a copy immediately. |
// +------------------------------------------------------------------------+
//
-// $Id: Assert.php,v 1.1.2.2 2003/06/07 06:25:59 sebastian Exp $
+// $Id: Assert.php,v 1.1.2.3 2003/06/08 09:08:56 sebastian Exp $
//
require_once 'PHPUnit/Framework/AssertionFailedError.php';
+require_once 'PHPUnit/Framework/ComparisonFailure.php';
/**
* A set of assert methods.
@@ -86,7 +87,7 @@
}
}
- elseif (is_numeric($actual) && is_numeric($expected)) {
+ else if (is_numeric($actual) && is_numeric($expected)) {
$message = sprintf(
'%sexpected %s%s, actual %s',
@@ -102,18 +103,14 @@
}
}
- else {
- $message = sprintf(
- '%sexpected %s, actual %s',
-
- !empty($message) ? $message . ' ' : '',
- $expected,
- $actual
- );
-
+ else if (is_string($actual) && is_string($expected)) {
if ($actual != $expected) {
- self::fail($message);
+ throw new ComparisonFailure($message, $expected, $actual);
}
+ }
+
+ else {
+ // ...
}
}
Index: pear/PHPUnit/Framework/ComparisonFailure.php
+++ pear/PHPUnit/Framework/ComparisonFailure.php