Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: test/mjsunit/mjsunit.js

Issue 2421033003: Revert of mjsunit: Fix the error message produced by assertInstanceof. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 200
201 function PrettyPrintArrayElement(value, index, array) { 201 function PrettyPrintArrayElement(value, index, array) {
202 if (value === undefined && !(index in array)) return ""; 202 if (value === undefined && !(index in array)) return "";
203 return PrettyPrint(value); 203 return PrettyPrint(value);
204 } 204 }
205 205
206 206
207 function fail(expectedText, found, name_opt) { 207 function fail(expectedText, found, name_opt) {
208 var message = "Fail" + "ure"; 208 var message = "Fail" + "ure";
209 if (found) { 209 if (name_opt) {
210 message += ": expected <" + expectedText + 210 // Fix this when we ditch the old test runner.
211 "> found <" + PrettyPrint(found) + ">"; 211 message += " (" + name_opt + ")";
212 if (name_opt) {
213 // Fix this when we ditch the old test runner.
214 message += " (" + name_opt + ")";
215 }
216 } else {
217 message += ": " + expectedText;
218 } 212 }
213
214 message += ": expected <" + expectedText +
215 "> found <" + PrettyPrint(found) + ">";
219 throw new MjsUnitAssertionError(message); 216 throw new MjsUnitAssertionError(message);
220 } 217 }
221 218
222 219
223 function deepObjectEquals(a, b) { 220 function deepObjectEquals(a, b) {
224 var aProps = Object.keys(a); 221 var aProps = Object.keys(a);
225 aProps.sort(); 222 aProps.sort();
226 var bProps = Object.keys(b); 223 var bProps = Object.keys(b);
227 bProps.sort(); 224 bProps.sort();
228 if (!deepEquals(aProps, bProps)) { 225 if (!deepEquals(aProps, bProps)) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 389
393 assertInstanceof = function assertInstanceof(obj, type) { 390 assertInstanceof = function assertInstanceof(obj, type) {
394 if (!(obj instanceof type)) { 391 if (!(obj instanceof type)) {
395 var actualTypeName = null; 392 var actualTypeName = null;
396 var actualConstructor = Object.getPrototypeOf(obj).constructor; 393 var actualConstructor = Object.getPrototypeOf(obj).constructor;
397 if (typeof actualConstructor === "function") { 394 if (typeof actualConstructor === "function") {
398 actualTypeName = actualConstructor.name || String(actualConstructor); 395 actualTypeName = actualConstructor.name || String(actualConstructor);
399 } 396 }
400 fail("Object <" + PrettyPrint(obj) + "> is not an instance of <" + 397 fail("Object <" + PrettyPrint(obj) + "> is not an instance of <" +
401 (type.name || type) + ">" + 398 (type.name || type) + ">" +
402 (actualTypeName ? " but of <" + actualTypeName + ">" : "")); 399 (actualTypeName ? " but of < " + actualTypeName + ">" : ""));
403 } 400 }
404 }; 401 };
405 402
406 403
407 assertDoesNotThrow = function assertDoesNotThrow(code, name_opt) { 404 assertDoesNotThrow = function assertDoesNotThrow(code, name_opt) {
408 try { 405 try {
409 if (typeof code === 'function') { 406 if (typeof code === 'function') {
410 code(); 407 code();
411 } else { 408 } else {
412 eval(code); 409 eval(code);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 if (sync_opt === undefined) sync_opt = ""; 455 if (sync_opt === undefined) sync_opt = "";
459 assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt); 456 assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt);
460 } 457 }
461 458
462 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { 459 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) {
463 if (sync_opt === undefined) sync_opt = ""; 460 if (sync_opt === undefined) sync_opt = "";
464 assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt); 461 assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt);
465 } 462 }
466 463
467 })(); 464 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698