forked from es-shims/Array.prototype.every
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
implementation.js
43 lines (32 loc) · 1.03 KB
/
implementation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var every = require('../implementation');
var callBind = require('es-abstract/helpers/callBind');
var test = require('tape');
var runTests = require('./tests');
var hasStrictMode = require('has-strict-mode')();
test('as a function', function (t) {
t.test('bad array/this value', function (st) {
st['throws'](callBind(every, null, undefined, 'a'), TypeError, 'undefined is not an object');
st['throws'](callBind(every, null, null, 'a'), TypeError, 'null is not an object');
st.end();
});
t.test('receiver boxing', function (st) {
st.plan(hasStrictMode ? 3 : 2);
var context = 'x';
every.call('foo', function () {
st.equal(typeof this, 'object');
st.equal(String.prototype.toString.call(this), context);
}, context);
st.test('strict mode', { skip: !hasStrictMode }, function (sst) {
sst.plan(2);
every.call('foo', function () {
'use strict';
sst.equal(typeof this, 'string');
sst.equal(this, context);
}, context);
sst.end();
});
st.end();
});
runTests(callBind(every), t);
t.end();
});