detachArrayBuffer-host-detachArrayBuffer.js (1003B)
1 // Copyright (C) 2017 Rick Waldron. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 description: > 5 Including detachArrayBuffer.js will expose a function: 6 7 $DETACHBUFFER 8 9 $DETACHBUFFER relies on the presence of a host definition for $262.detachArrayBuffer 10 11 includes: [detachArrayBuffer.js] 12 ---*/ 13 14 var $262 = { 15 detachArrayBuffer() { 16 throw new Test262Error('$262.detachArrayBuffer called.'); 17 }, 18 destroy() {} 19 }; 20 21 var ab = new ArrayBuffer(1); 22 var threw = false; 23 24 try { 25 $DETACHBUFFER(ab); 26 } catch(err) { 27 threw = true; 28 if (err.constructor !== Test262Error) { 29 throw new Error( 30 'Expected a Test262Error, but a "' + err.constructor.name + 31 '" was thrown.' 32 ); 33 } 34 if (err.message !== '$262.detachArrayBuffer called.') { 35 throw new Error(`Expected error message: ${err.message}`); 36 } 37 } 38 39 if (threw === false) { 40 throw new Error('Expected a Test262Error, but no error was thrown.'); 41 } 42 43 44 45 reportCompare(0, 0);