2018-02-22 03:06:23 +00:00
|
|
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
// Extensions to mjsunit and other test harnesses added between harness and
|
|
|
|
// fuzzing code.
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Scope for utility functions.
|
|
|
|
(function() {
|
|
|
|
// Same as in mjsunit.js.
|
|
|
|
function classOf(object) {
|
|
|
|
// Argument must not be null or undefined.
|
|
|
|
var string = Object.prototype.toString.call(object);
|
|
|
|
// String has format [object <ClassName>].
|
|
|
|
return string.substring(8, string.length - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Override prettyPrinted with a version that also recusively prints object
|
|
|
|
// properties (with a depth of 3).
|
2018-03-08 08:12:05 +00:00
|
|
|
let origPrettyPrinted = prettyPrinted;
|
|
|
|
prettyPrinted = function prettyPrinted(value, depth=3) {
|
2018-02-22 03:06:23 +00:00
|
|
|
if (depth == 0) {
|
|
|
|
return "...";
|
|
|
|
}
|
|
|
|
switch (typeof value) {
|
|
|
|
case "object":
|
|
|
|
if (value === null) return "null";
|
|
|
|
var objectClass = classOf(value);
|
|
|
|
switch (objectClass) {
|
|
|
|
case "Object":
|
|
|
|
var name = value.constructor.name;
|
|
|
|
if (!name)
|
|
|
|
name = "Object";
|
|
|
|
return name + "{" + Object.keys(value).map(function(key, index) {
|
|
|
|
return (
|
|
|
|
prettyPrinted(key, depth - 1) +
|
|
|
|
": " +
|
|
|
|
prettyPrinted(value[key], depth - 1)
|
|
|
|
);
|
|
|
|
}).join(",") + "}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Fall through to original version for all other types.
|
|
|
|
return origPrettyPrinted(value);
|
|
|
|
}
|
2018-02-23 17:08:52 +00:00
|
|
|
|
|
|
|
// We're not interested in stack traces.
|
2018-03-08 08:12:05 +00:00
|
|
|
MjsUnitAssertionError = function MjsUnitAssertionError(message) {}
|
2018-02-23 17:08:52 +00:00
|
|
|
MjsUnitAssertionError.prototype.toString = function () { return ""; };
|
|
|
|
|
|
|
|
// Do more printing in assertions for more correctness coverage.
|
2018-03-08 08:12:05 +00:00
|
|
|
failWithMessage = function failWithMessage(message) {
|
2018-02-23 17:08:52 +00:00
|
|
|
print(prettyPrinted(message))
|
|
|
|
}
|
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
assertSame = function assertSame(expected, found, name_opt) {
|
2018-02-23 17:08:52 +00:00
|
|
|
print(prettyPrinted(found));
|
|
|
|
}
|
2018-02-24 01:36:40 +00:00
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
assertNotSame = function assertNotSame(expected, found, name_opt) {
|
2018-02-24 01:36:40 +00:00
|
|
|
print(prettyPrinted(found));
|
|
|
|
}
|
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
assertEquals = function assertEquals(expected, found, name_opt) {
|
2018-02-24 01:36:40 +00:00
|
|
|
print(prettyPrinted(found));
|
|
|
|
}
|
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
assertNotEquals = function assertNotEquals(expected, found, name_opt) {
|
2018-02-24 01:36:40 +00:00
|
|
|
print(prettyPrinted(found));
|
|
|
|
}
|
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
assertNull = function assertNull(value, name_opt) {
|
2018-02-24 01:36:40 +00:00
|
|
|
print(prettyPrinted(value));
|
|
|
|
}
|
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
assertNotNull = function assertNotNull(value, name_opt) {
|
2018-02-24 01:36:40 +00:00
|
|
|
print(prettyPrinted(value));
|
|
|
|
}
|
2018-02-24 18:29:14 +00:00
|
|
|
|
|
|
|
// Suppress optimization status as it leads to false positives.
|
2018-03-08 08:12:05 +00:00
|
|
|
assertUnoptimized = function assertUnoptimized() {}
|
2018-02-24 18:29:14 +00:00
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
assertOptimized = function assertOptimized() {}
|
2018-02-24 18:29:14 +00:00
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
isNeverOptimize = function isNeverOptimize() {}
|
2018-02-24 18:29:14 +00:00
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
isAlwaysOptimize = function isAlwaysOptimize() {}
|
2018-02-24 18:29:14 +00:00
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
isInterpreted = function isInterpreted() {}
|
2018-02-24 18:29:14 +00:00
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
isOptimized = function isOptimized() {}
|
2018-02-24 18:29:14 +00:00
|
|
|
|
2018-03-08 08:12:05 +00:00
|
|
|
isTurboFanned = function isTurboFanned() {}
|
2018-02-22 03:06:23 +00:00
|
|
|
})();
|
|
|
|
} catch(e) { }
|