-
-
Notifications
You must be signed in to change notification settings - Fork 809
/
Copy pathtest.js
62 lines (53 loc) · 1.18 KB
/
test.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* eslint-disable func-names */
'use strict';
// MODULES //
var tape = require( 'tape' );
var RE_NATIVE_FUNCTION = require( './../lib' );
// TESTS //
tape( 'main export is a regular expression', function test( t ) {
t.ok( true, __filename );
t.strictEqual( RE_NATIVE_FUNCTION instanceof RegExp, true, 'main export is a regular expression' );
t.end();
});
tape( 'the regular expression matches native functions', function test( t ) {
var values;
var bool;
var i;
values = [
Date,
Boolean,
String,
Number,
Function,
RegExp,
Number,
Int8Array,
Math.sqrt,
Math.pow
];
for ( i = 0; i < values.length; i++ ) {
bool = RE_NATIVE_FUNCTION.test( values[ i ].toString() );
t.strictEqual( bool, true, 'returns true for '+values[ i ] );
}
t.end();
});
tape( 'the regular expression does not match non-native functions', function test( t ) {
var values;
var bool;
var i;
values = [
function () {},
function noop() {},
test,
tape,
t.strictEqual,
t.ok,
t.fail,
t.pass
];
for ( i = 0; i < values.length; i++ ) {
bool = RE_NATIVE_FUNCTION.test( values[ i ].toString() );
t.strictEqual( bool, false, 'returns false for '+values[ i ] );
}
t.end();
});