<?php
/*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return;
}
- if (is_array($expect)) {
- $expect = print_r($expect, true);
+ $expect = PhutilReadableSerializer::printableValue($expect);
+ $result = PhutilReadableSerializer::printableValue($result);
+
+ $where = debug_backtrace();
+ $where = array_shift($where);
+
+ $line = idx($where, 'line');
+ $file = basename(idx($where, 'file'));
+
+ $output = "Assertion failed at line {$line} in {$file}";
+
+ if ($message) {
+ $output .= ": {$message}";
+ }
+
+ $output .= "\n";
+
+ if (strpos($expect, "\n") !== false) {
+ $expect = "\n{$expect}";
}
- if (is_array($result)) {
- $result = print_r($result, true);
+ if (strpos($result, "\n") !== false) {
+ $result = "\n{$result}";
}
- $message = "Values {$expect} and {$result} differ: {$message}";
- $this->failTest($message);
- throw new ArcanistPhutilTestTerminatedException($message);
+ $output .= "Expected: {$expect}\n";
+ $output .= "Actual: {$result}";
+
+ $this->failTest($output);
+ throw new ArcanistPhutilTestTerminatedException($output);
}
phutil_require_module('arcanist', 'unit/engine/phutil/testcase/exception');
phutil_require_module('arcanist', 'unit/result');
+phutil_require_module('phutil', 'readableserializer');
+phutil_require_module('phutil', 'utils');
+
phutil_require_source('ArcanistPhutilTestCase.php');