[Pkg-javascript-commits] [node-syntax-error] 03/47: turned example into a test

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 19:29:57 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-syntax-error.

commit e6159e24d814908db267e973898eef13204d195e
Author: James Halliday <mail at substack.net>
Date:   Thu Aug 2 00:05:44 2012 -0700

    turned example into a test
---
 test/check.js         | 17 +++++++++++++++++
 test/sources/check.js |  9 +++++++++
 2 files changed, 26 insertions(+)

diff --git a/test/check.js b/test/check.js
new file mode 100644
index 0000000..f28e51e
--- /dev/null
+++ b/test/check.js
@@ -0,0 +1,17 @@
+var test = require('tap').test;
+
+var fs = require('fs');
+var check = require('../');
+
+var file = __dirname + '/sources/check.js';
+var src = fs.readFileSync(file);
+
+test(function (t) {
+    var err = check(src, file);
+    t.ok(err);
+    t.equal(err.line, 5);
+    t.equal(err.column, 30);
+    t.equal(err.message, 'Unexpected identifier');
+    t.ok(String(err).indexOf(file) + ':5');
+    t.end();
+});
diff --git a/test/sources/check.js b/test/sources/check.js
new file mode 100644
index 0000000..51a63e7
--- /dev/null
+++ b/test/sources/check.js
@@ -0,0 +1,9 @@
+module.exports = function (xs, fn) {
+    var res = [];
+    for (var i = 0; i < xs.length; i++) {
+        var x = fn(xs[i], i);
+        if (Array.isArray(x) res.push.apply(res, x);
+        else res.push(x);
+    }
+    return res;
+};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-syntax-error.git



More information about the Pkg-javascript-commits mailing list