3 var test = require('tape');
5 var callBound = require('../callBound');
7 test('callBound', function (t) {
9 t.equal(callBound('Array.length'), Array.length, 'Array.length yields itself');
10 t.equal(callBound('%Array.length%'), Array.length, '%Array.length% yields itself');
12 // static non-function object
13 t.equal(callBound('Array.prototype'), Array.prototype, 'Array.prototype yields itself');
14 t.equal(callBound('%Array.prototype%'), Array.prototype, '%Array.prototype% yields itself');
15 t.equal(callBound('Array.constructor'), Array.constructor, 'Array.constructor yields itself');
16 t.equal(callBound('%Array.constructor%'), Array.constructor, '%Array.constructor% yields itself');
19 t.equal(callBound('Date.parse'), Date.parse, 'Date.parse yields itself');
20 t.equal(callBound('%Date.parse%'), Date.parse, '%Date.parse% yields itself');
22 // prototype primitive
23 t.equal(callBound('Error.prototype.message'), Error.prototype.message, 'Error.prototype.message yields itself');
24 t.equal(callBound('%Error.prototype.message%'), Error.prototype.message, '%Error.prototype.message% yields itself');
27 t.notEqual(callBound('Object.prototype.toString'), Object.prototype.toString, 'Object.prototype.toString does not yield itself');
28 t.notEqual(callBound('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% does not yield itself');
29 t.equal(callBound('Object.prototype.toString')(true), Object.prototype.toString.call(true), 'call-bound Object.prototype.toString calls into the original');
30 t.equal(callBound('%Object.prototype.toString%')(true), Object.prototype.toString.call(true), 'call-bound %Object.prototype.toString% calls into the original');
33 function () { callBound('does not exist'); },
35 'nonexistent intrinsic throws'
38 function () { callBound('does not exist', true); },
40 'allowMissing arg still throws for unknown intrinsic'
43 /* globals WeakRef: false */
44 t.test('real but absent intrinsic', { skip: typeof WeakRef !== 'undefined' }, function (st) {
46 function () { callBound('WeakRef'); },
48 'real but absent intrinsic throws'
50 st.equal(callBound('WeakRef', true), undefined, 'allowMissing arg avoids exception');