Security update for permissions_by_term
[yaffs-website] / node_modules / is-function / test.js
1 var test = require('tape')
2 var isFunction = require('./index.js')
3
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')
15     t.end()
16 })
17
18 if (typeof window !== 'undefined') {
19     test('browser quirks', function (t) {
20         t.plan(2)
21         
22         t.ok(isFunction(window.alert), 'alert is a function')
23
24         window.testRegExpFromIframe = function (regexp) {
25             t.ok(!isFunction(regexp))
26         }
27         
28         var iframe = document.createElement('iframe')
29         document.body.appendChild(iframe)
30         
31         iframe.contentWindow.document.write([
32             "<html><body><script type=\"text/javascript\">",
33             "parent.testRegExpFromIframe(/a/)",
34             "</script></body></html>"
35         ].join("\n"));
36     })
37 }