test262/test/harness/wellKnownIntrinsicObjects.js
Philip Chimento 2af27af915 harness: Add a function to get well-known intrinsic objects
wellKnownIntrinsicObjects.js now exposes a getWellKnownIntrinsicObject()
function which returns the object corresponding to a key like %Array%. If
the object is not provided by the implementation, or not accessible, it
throws a Test262Error. This is so that tests depending on that intrinsic
object can easily fail.
2025-03-11 18:14:55 -07:00

22 lines
722 B
JavaScript

// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Basic tests for getWellKnownIntrinsicObject harness function
includes: [wellKnownIntrinsicObjects.js]
---*/
// Accessible in every implementation
var intrinsicArray = getWellKnownIntrinsicObject('%Array%');
assert(Object.is(Array, intrinsicArray));
assert.throws(Test262Error, function () {
// Exists but is not accessible in any implementation
getWellKnownIntrinsicObject('%AsyncFromSyncIteratorPrototype%');
});
assert.throws(Test262Error, function () {
// Does not exist in any implementation
getWellKnownIntrinsicObject('%NotSoWellKnownIntrinsicObject%');
});