caller.js
836 Bytes
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
'use strict';
var test = require('tape'),
caller = require('../');
test('caller', function (t) {
t.test('determine caller', function (t) {
var actual, expected;
actual = caller();
expected = require.resolve('tape/lib/test');
t.equal(actual, expected);
t.end();
});
t.test('determine caller at runtime', function (t) {
var callee, actual, expected;
callee = require('./fixtures/callee');
actual = callee(caller);
expected = __filename;
t.equal(actual, expected);
t.end();
});
t.test('determine caller at initialization time', function (t) {
var actual, expected;
actual = require('./fixtures/init');
expected = __filename;
t.equal(actual, expected);
t.end();
});
});