Skip to content

Commit 45ec74c

Browse files
committed
Add tests for unicode line separators #52
1 parent 5e97799 commit 45ec74c

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

test/files/separators.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var fs = require('fs');
2+
var text = fs.readFileSync(__dirname + '/separators.txt', 'utf8');
3+
console.log(text);

test/files/separators.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
LINE_SEPARATOR: 
 (U+2028)
3+
PARAGRAPH_SEPARATOR: 
 (U+2029)

test/separators.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var test = require('tap').test;
2+
var exec = require('child_process').exec;
3+
4+
var browserify = require('browserify');
5+
var path = require('path');
6+
var vm = require('vm');
7+
var fs = require('fs');
8+
9+
var text = fs.readFileSync(__dirname + '/files/separators.txt', 'utf8');
10+
11+
test('run file with special unicode separators', function (t) {
12+
t.plan(1);
13+
exec(__dirname + '/../bin/cmd.js ' + __dirname + '/files/separators.js',
14+
function (error, stdout, stderr) {
15+
if (error !== null) {
16+
t.fail();
17+
} else {
18+
vm.runInNewContext(stdout, {
19+
require: function () {},
20+
console: { log: log }
21+
});
22+
function log (msg) {
23+
t.equal(text, msg);
24+
};
25+
};
26+
}
27+
);
28+
});
29+
30+
test('bundle file with special unicode separators', function (t) {
31+
t.plan(1);
32+
33+
var b = browserify();
34+
b.add(__dirname + '/files/separators.js');
35+
b.transform(path.dirname(__dirname));
36+
37+
b.bundle(function (err, src) {
38+
if (err) t.fail(err);
39+
vm.runInNewContext(src, { console: { log: log } });
40+
});
41+
42+
function log (msg) {
43+
t.equal(text, msg);
44+
}
45+
});

0 commit comments

Comments
 (0)