summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKiko Beats <josefrancisco.verdu@gmail.com>2016-06-02 12:10:13 +0200
committerKiko Beats <josefrancisco.verdu@gmail.com>2016-06-02 12:10:13 +0200
commit9fc2948a4fc429cbc73b5b0ddadda3279764c7af (patch)
treec120e8bf86c0a35fc1746d6691bef1f22d3d0dec
parentaf6c5956da1d98855a63d34e9c7aa3bb90b4140d (diff)
downloadasync-9fc2948a4fc429cbc73b5b0ddadda3279764c7af.tar.gz
Add .gitattributes
Fix CRLF problems across OS
-rw-r--r--.gitattributes2
-rw-r--r--mocha_test/ensureAsync.js170
2 files changed, 87 insertions, 85 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..4cab1f4
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Set the default behavior, in case people don't have core.autocrlf set.
+* text=auto
diff --git a/mocha_test/ensureAsync.js b/mocha_test/ensureAsync.js
index fd8cc3f..89659e2 100644
--- a/mocha_test/ensureAsync.js
+++ b/mocha_test/ensureAsync.js
@@ -1,85 +1,85 @@
-var async = require('../lib');
-var expect = require('chai').expect;
-var assert = require('assert');
-
-describe('ensureAsync', function() {
- var passContext = function(cb) {
- cb(this);
- };
-
- it('defer sync functions', function(done) {
- var sync = true;
- async.ensureAsync(function (arg1, arg2, cb) {
- expect(arg1).to.equal(1);
- expect(arg2).to.equal(2);
- cb(null, 4, 5);
- })(1, 2, function (err, arg4, arg5) {
- expect(err).to.equal(null);
- expect(arg4).to.equal(4);
- expect(arg5).to.equal(5);
- assert(!sync, 'callback called on same tick');
- done();
- });
- sync = false;
- });
-
- it('do not defer async functions', function(done) {
- var sync = false;
- async.ensureAsync(function (arg1, arg2, cb) {
- expect(arg1).to.equal(1);
- expect(arg2).to.equal(2);
- async.setImmediate(function () {
- sync = true;
- cb(null, 4, 5);
- sync = false;
- });
- })(1, 2, function (err, arg4, arg5) {
- expect(err).to.equal(null);
- expect(arg4).to.equal(4);
- expect(arg5).to.equal(5);
- assert(sync, 'callback called on next tick');
- done();
- });
- });
-
- it('double wrapping', function(done) {
- var sync = true;
- async.ensureAsync(async.ensureAsync(function (arg1, arg2, cb) {
- expect(arg1).to.equal(1);
- expect(arg2).to.equal(2);
- cb(null, 4, 5);
- }))(1, 2, function (err, arg4, arg5) {
- expect(err).to.equal(null);
- expect(arg4).to.equal(4);
- expect(arg5).to.equal(5);
- assert(!sync, 'callback called on same tick');
- done();
- });
- sync = false;
- });
-
-
- it('should propely bind context to the wrapped function', function(done) {
-
- // call bind after wrapping with ensureAsync
- var context = {context: "post"};
- var postBind = async.ensureAsync(passContext);
- postBind = postBind.bind(context);
- postBind(function(ref) {
- expect(ref).to.equal(context);
- done();
- });
- });
-
- it('should not override the bound context of a function when wrapping', function(done) {
-
- // call bind before wrapping with ensureAsync
- var context = {context: "pre"};
- var preBind = passContext.bind(context);
- preBind = async.ensureAsync(preBind);
- preBind(function(ref) {
- expect(ref).to.equal(context);
- done();
- });
- });
-});
+var async = require('../lib');
+var expect = require('chai').expect;
+var assert = require('assert');
+
+describe('ensureAsync', function() {
+ var passContext = function(cb) {
+ cb(this);
+ };
+
+ it('defer sync functions', function(done) {
+ var sync = true;
+ async.ensureAsync(function (arg1, arg2, cb) {
+ expect(arg1).to.equal(1);
+ expect(arg2).to.equal(2);
+ cb(null, 4, 5);
+ })(1, 2, function (err, arg4, arg5) {
+ expect(err).to.equal(null);
+ expect(arg4).to.equal(4);
+ expect(arg5).to.equal(5);
+ assert(!sync, 'callback called on same tick');
+ done();
+ });
+ sync = false;
+ });
+
+ it('do not defer async functions', function(done) {
+ var sync = false;
+ async.ensureAsync(function (arg1, arg2, cb) {
+ expect(arg1).to.equal(1);
+ expect(arg2).to.equal(2);
+ async.setImmediate(function () {
+ sync = true;
+ cb(null, 4, 5);
+ sync = false;
+ });
+ })(1, 2, function (err, arg4, arg5) {
+ expect(err).to.equal(null);
+ expect(arg4).to.equal(4);
+ expect(arg5).to.equal(5);
+ assert(sync, 'callback called on next tick');
+ done();
+ });
+ });
+
+ it('double wrapping', function(done) {
+ var sync = true;
+ async.ensureAsync(async.ensureAsync(function (arg1, arg2, cb) {
+ expect(arg1).to.equal(1);
+ expect(arg2).to.equal(2);
+ cb(null, 4, 5);
+ }))(1, 2, function (err, arg4, arg5) {
+ expect(err).to.equal(null);
+ expect(arg4).to.equal(4);
+ expect(arg5).to.equal(5);
+ assert(!sync, 'callback called on same tick');
+ done();
+ });
+ sync = false;
+ });
+
+
+ it('should propely bind context to the wrapped function', function(done) {
+
+ // call bind after wrapping with ensureAsync
+ var context = {context: "post"};
+ var postBind = async.ensureAsync(passContext);
+ postBind = postBind.bind(context);
+ postBind(function(ref) {
+ expect(ref).to.equal(context);
+ done();
+ });
+ });
+
+ it('should not override the bound context of a function when wrapping', function(done) {
+
+ // call bind before wrapping with ensureAsync
+ var context = {context: "pre"};
+ var preBind = passContext.bind(context);
+ preBind = async.ensureAsync(preBind);
+ preBind(function(ref) {
+ expect(ref).to.equal(context);
+ done();
+ });
+ });
+});