1 var test = require('tape')
2 var isFunction = require('./index.js')
4 test('isFunction', function (t) {
5 t.ok(!isFunction(), 'undefined is not a function')
6 t.ok(!isFunction(null), 'null is not a function')
7 t.ok(!isFunction(''), 'string is not a function')
8 t.ok(!isFunction(/a/), 'regex is not a function')
9 t.ok(!isFunction(true), 'true is not a function')
10 t.ok(!isFunction(false), 'false is not a function')
11 t.ok(!isFunction(NaN), 'NaN is not a function')
12 t.ok(!isFunction(42), '42 is not a function')
13 t.ok(isFunction(function () {}), 'function is a function')
14 t.ok(isFunction(setTimeout), 'setTimeout is a function')
18 if (typeof window !== 'undefined') {
19 test('browser quirks', function (t) {
22 t.ok(isFunction(window.alert), 'alert is a function')
24 window.testRegExpFromIframe = function (regexp) {
25 t.ok(!isFunction(regexp))
28 var iframe = document.createElement('iframe')
29 document.body.appendChild(iframe)
31 iframe.contentWindow.document.write([
32 "<html><body><script type=\"text/javascript\">",
33 "parent.testRegExpFromIframe(/a/)",
34 "</script></body></html>"