CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
index.js62 linesDownload Raw Back to test
1'use strict';2 3var test = require('tape');4 5var callBound = require('../');6 7/** @template {true} T @template U @typedef {T extends U ? T : never} AssertType */8 9test('callBound', function (t) {10	// static primitive11	t.equal(callBound('Array.length'), Array.length, 'Array.length yields itself');12	t.equal(callBound('%Array.length%'), Array.length, '%Array.length% yields itself');13 14	// static non-function object15	t.equal(callBound('Array.prototype'), Array.prototype, 'Array.prototype yields itself');16	t.equal(callBound('%Array.prototype%'), Array.prototype, '%Array.prototype% yields itself');17	t.equal(callBound('Array.constructor'), Array.constructor, 'Array.constructor yields itself');18	t.equal(callBound('%Array.constructor%'), Array.constructor, '%Array.constructor% yields itself');19 20	// static function21	t.equal(callBound('Date.parse'), Date.parse, 'Date.parse yields itself');22	t.equal(callBound('%Date.parse%'), Date.parse, '%Date.parse% yields itself');23 24	// prototype primitive25	t.equal(callBound('Error.prototype.message'), Error.prototype.message, 'Error.prototype.message yields itself');26	t.equal(callBound('%Error.prototype.message%'), Error.prototype.message, '%Error.prototype.message% yields itself');27 28	var x = callBound('Object.prototype.toString');29	var y = callBound('%Object.prototype.toString%');30 31	// prototype function32	t.notEqual(x, Object.prototype.toString, 'Object.prototype.toString does not yield itself');33	t.notEqual(y, Object.prototype.toString, '%Object.prototype.toString% does not yield itself');34	t.equal(x(true), Object.prototype.toString.call(true), 'call-bound Object.prototype.toString calls into the original');35	t.equal(y(true), Object.prototype.toString.call(true), 'call-bound %Object.prototype.toString% calls into the original');36 37	t['throws'](38		// @ts-expect-error39		function () { callBound('does not exist'); },40		SyntaxError,41		'nonexistent intrinsic throws'42	);43	t['throws'](44		// @ts-expect-error45		function () { callBound('does not exist', true); },46		SyntaxError,47		'allowMissing arg still throws for unknown intrinsic'48	);49 50	t.test('real but absent intrinsic', { skip: typeof WeakRef !== 'undefined' }, function (st) {51		st['throws'](52			function () { callBound('WeakRef'); },53			TypeError,54			'real but absent intrinsic throws'55		);56		st.equal(callBound('WeakRef', true), undefined, 'allowMissing arg avoids exception');57		st.end();58	});59 60	t.end();61});62 
basant307/AI_Governance_Project · CoolFace