1 | 'use strict';
|
---|
2 |
|
---|
3 | var test = require('tape');
|
---|
4 |
|
---|
5 | var $Object = require('../');
|
---|
6 | var isObject = require('../isObject');
|
---|
7 | var ToObject = require('../ToObject');
|
---|
8 | var RequireObjectCoercible = require('..//RequireObjectCoercible');
|
---|
9 |
|
---|
10 | test('errors', function (t) {
|
---|
11 | t.equal($Object, Object);
|
---|
12 | // @ts-expect-error
|
---|
13 | t['throws'](function () { ToObject(null); }, TypeError);
|
---|
14 | // @ts-expect-error
|
---|
15 | t['throws'](function () { ToObject(undefined); }, TypeError);
|
---|
16 | // @ts-expect-error
|
---|
17 | t['throws'](function () { RequireObjectCoercible(null); }, TypeError);
|
---|
18 | // @ts-expect-error
|
---|
19 | t['throws'](function () { RequireObjectCoercible(undefined); }, TypeError);
|
---|
20 |
|
---|
21 | t.deepEqual(RequireObjectCoercible(true), true);
|
---|
22 | t.deepEqual(ToObject(true), Object(true));
|
---|
23 | t.deepEqual(ToObject(42), Object(42));
|
---|
24 | var f = function () {};
|
---|
25 | t.equal(ToObject(f), f);
|
---|
26 |
|
---|
27 | t.equal(isObject(undefined), false);
|
---|
28 | t.equal(isObject(null), false);
|
---|
29 | t.equal(isObject({}), true);
|
---|
30 | t.equal(isObject([]), true);
|
---|
31 | t.equal(isObject(function () {}), true);
|
---|
32 |
|
---|
33 | var obj = {};
|
---|
34 | t.equal(RequireObjectCoercible(obj), obj);
|
---|
35 | t.equal(ToObject(obj), obj);
|
---|
36 |
|
---|
37 | t.end();
|
---|
38 | });
|
---|