Repository: jquery/jquery
File: test/unit/deferred.js (JavaScript)

Code before:
	assert.expect( 4 );

	var value1, value2, value3,
		defer = jQuery.Deferred(),
		piped = defer.catch(function( a, b ) {
			return a * b;
		}),
		done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );

	piped.done(function( result ) {
		value3 = result;
	});

	defer.fail(function( a, b ) {
		value1 = a;
		value2 = b;
	});

	defer.reject( 2, 3 ).catch(function() {
		assert.strictEqual( value1, 2, "first reject value ok" );
		assert.strictEqual( value2, 3, "second reject value ok" );
		assert.strictEqual( value3, 6, "result of filter ok" );
		done.pop().call();
	});

	jQuery.Deferred().resolve().catch(function() {
		assert.ok( false, "then should not be called on resolve" );
	}).then( done.pop() );

	jQuery.Deferred().reject().catch(jQuery.noop ).done(function( value ) {
		assert.strictEqual( value, undefined, "then fail callback can return undefined/null" );
		done.pop().call();
	});
});

test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) {

	assert.expect( 4 );

	var value1, value2, value3,
		defer = jQuery.Deferred(),
		piped = defer.pipe( null, function( a, b ) {
			return a * b;
		}),
		done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );

	piped.fail(function( result ) {
		value3 = result;
	});

	defer.fail(function( a, b ) {

Review comment (suggestion):
In my understanding, it is all jquery people who choose to participate in the possible ticket of the contribute repo, so we would document that style and show it to contributors when needed.

From the beginning, i said lots of times that this style is no good, showed new styled code, propose compromises, no one seems to notice. And funny thing is, many of us knew that style is horrible, but choose it anyway. My hypotheses is, that some of us just didn't want to argue about such a thing or wanted to "avoid exceptions".

And now, it seems, we are considering to diverge from the official guide lines and create new  `core` set of rules. And going with new debate further, changing and creating new code styles, rewriting perfectly working code... we do this again and again. So much discussions, ideas and arguing, all for nothing in my opinion. 

Code style discussions are always time consuming and really pointless, we can do something more radical and choose to deprecate jquery code style altogether and choose one of the most popular code style out there, like airbnb or google.

If that would be the case, we would never spend another second debating space there, tabs here, or newline before something, because one of the other subjective feeling. 

Following other people subjective feeling, while doing real work.


Code after:
	assert.expect( 4 );

	var value1, value2, value3,
		defer = jQuery.Deferred(),
		piped = defer.catch(function( a, b ) {
			return a * b;
		}),
		done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );

	piped.done(function( result ) {
		value3 = result;
	});

	defer.fail(function( a, b ) {
		value1 = a;
		value2 = b;
	});

	defer.reject( 2, 3 ).catch(function() {
		assert.strictEqual( value1, 2, "first reject value ok" );
		assert.strictEqual( value2, 3, "second reject value ok" );
		assert.strictEqual( value3, 6, "result of filter ok" );
		done.pop().call();
	});

	jQuery.Deferred().resolve().catch(function() {
		assert.ok( false, "then should not be called on resolve" );
	}).then( done.pop() );

	jQuery.Deferred().reject().catch( jQuery.noop ).done(function( value ) {
		assert.strictEqual( value, undefined, "then fail callback can return undefined/null" );
		done.pop().call();
	});
});

test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) {

	assert.expect( 4 );

	var value1, value2, value3,
		defer = jQuery.Deferred(),
		piped = defer.pipe( null, function( a, b ) {
			return a * b;
		}),
		done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );

	piped.fail(function( result ) {
		value3 = result;
	});

	defer.fail(function( a, b ) {