assert-throws-null.js (638B)
1 // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: > 6 Functions that throw the `null` value do not satisfy the assertion. 7 ---*/ 8 9 var threw = false; 10 11 try { 12 assert.throws(Error, function() { 13 throw null; 14 }); 15 } catch(err) { 16 threw = true; 17 if (err.constructor !== Test262Error) { 18 throw new Error( 19 'Expected a Test262Error, but a "' + err.constructor.name + 20 '" was thrown.' 21 ); 22 } 23 } 24 25 if (threw === false) { 26 throw new Error('Expected a Test262Error, but no error was thrown.'); 27 } 28 29 reportCompare(0, 0);