From 759ad854e9a71549b10ca328c558b708239e12a9 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Fri, 23 Jun 2017 11:08:50 -0400 Subject: [PATCH] harness test: detachArrayBuffer.js Signed-off-by: Rick Waldron --- ...etachArrayBuffer-$262.detachArrayBuffer.js | 42 +++++++++++++++++++ test/harness/detachArrayBuffer.js | 34 +++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 test/harness/detachArrayBuffer-$262.detachArrayBuffer.js create mode 100644 test/harness/detachArrayBuffer.js diff --git a/test/harness/detachArrayBuffer-$262.detachArrayBuffer.js b/test/harness/detachArrayBuffer-$262.detachArrayBuffer.js new file mode 100644 index 0000000000..2d1d0a433c --- /dev/null +++ b/test/harness/detachArrayBuffer-$262.detachArrayBuffer.js @@ -0,0 +1,42 @@ +// Copyright (C) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Including detachArrayBuffer.js will expose a function: + + $DETACHBUFFER + + $DETACHBUFFER relies on the presence of a definition for $262.detachArrayBuffer + +includes: [detachArrayBuffer.js,sta.js] +---*/ + +var $262 = { + detachArrayBuffer() { + throw new Test262Error('$262.detachArrayBuffer called.'); + } +}; + +var ab = new ArrayBuffer(1); +var threw = false; + +try { + $DETACHBUFFER(ab); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } + if (err.message !== '$262.detachArrayBuffer called.') { + $ERROR(`Expected error message: ${err.message}`); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} + + diff --git a/test/harness/detachArrayBuffer.js b/test/harness/detachArrayBuffer.js new file mode 100644 index 0000000000..22d3b6c11a --- /dev/null +++ b/test/harness/detachArrayBuffer.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Including detachArrayBuffer.js will expose a function: + + $DETACHBUFFER + + $DETACHBUFFER relies on the presence of a definition for $262.detachArrayBuffer. + Without a definition, calling $DETACHBUFFER will result in a ReferenceError + +includes: [detachArrayBuffer.js,sta.js] +---*/ + +var ab = new ArrayBuffer(1); +var threw = false; + +try { + $DETACHBUFFER(ab); +} catch(err) { + threw = true; + if (err.constructor !== ReferenceError) { + $ERROR( + 'Expected a ReferenceError, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a ReferenceError, but no error was thrown.'); +} + +