source: trip-planner-front/node_modules/call-bind/test/callBound.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[6a3a178]1'use strict';
2
3var test = require('tape');
4
5var callBound = require('../callBound');
6
7test('callBound', function (t) {
8 // static primitive
9 t.equal(callBound('Array.length'), Array.length, 'Array.length yields itself');
10 t.equal(callBound('%Array.length%'), Array.length, '%Array.length% yields itself');
11
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');
17
18 // static function
19 t.equal(callBound('Date.parse'), Date.parse, 'Date.parse yields itself');
20 t.equal(callBound('%Date.parse%'), Date.parse, '%Date.parse% yields itself');
21
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');
25
26 // prototype function
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');
31
32 t['throws'](
33 function () { callBound('does not exist'); },
34 SyntaxError,
35 'nonexistent intrinsic throws'
36 );
37 t['throws'](
38 function () { callBound('does not exist', true); },
39 SyntaxError,
40 'allowMissing arg still throws for unknown intrinsic'
41 );
42
43 /* globals WeakRef: false */
44 t.test('real but absent intrinsic', { skip: typeof WeakRef !== 'undefined' }, function (st) {
45 st['throws'](
46 function () { callBound('WeakRef'); },
47 TypeError,
48 'real but absent intrinsic throws'
49 );
50 st.equal(callBound('WeakRef', true), undefined, 'allowMissing arg avoids exception');
51 st.end();
52 });
53
54 t.end();
55});
Note: See TracBrowser for help on using the repository browser.