Debian Codegraph @

test/unary.js

raw
1 var test = require('tape');
2 var concat = require('concat-stream');
3 var staticModule = require('../');
4 var fs = require('fs');
5 var path = require('path');
6
7 test('supported unary operator', function (t) {
8 t.plan(1);
9
10 var expected = [ false ];
11 var sm = staticModule({
12 beep: { x: 42 }
13 });
14 readStream('supported.js').pipe(sm).pipe(concat(function (body) {
15 Function(['console'],body)({ log: log });
16 function log (msg) { t.equal(msg, expected.shift()) }
17 }));
18 });
19
20 test('unsupported unary operator', function (t) {
21 t.plan(1)
22
23 var sm = staticModule({
24 beep: { x: 42 }
25 });
26 readStream('unsupported.js').pipe(sm).on('error', function (error) {
27 t.equal(error.message, 'unsupported unary operator: typeof')
28 })
29 })
30
31 function readStream (file) {
32 return fs.createReadStream(path.join(__dirname, 'unary', file));
33 }