Alien-Web-ExtJS-V3
view release on metacpan or search on metacpan
share/test/unit/Function.js view on Meta::CPAN
Y.Assert.areEqual(scope, this, 'Test if "this" is correct');
Y.Assert.areEqual('bar', this.foo, 'Test if property matches');
Y.Assert.areEqual('a', a, 'Test passed param');
Y.Assert.areEqual('b', b, 'Test passed param');
return z === undefined;
}, scope);
// intercepted, but allowed to continue
rt = cb('a', 'b'); // n 2
Y.Assert.areEqual('x', rt, 'Test the return value');
// intercepted, and cancelled
cb('a', 'b', 'z');
Y.Assert.areEqual(2, scope.n, 'Test the interceptor call count');
},
// 16
test_createSequence: function(){
var scope = {
foo: 'bar',
seq: 0
};
var fn = function(a, b){
Y.Assert.areEqual(scope, this, 'Test if "this" is correct');
Y.Assert.areEqual('bar', this.foo, 'Test if property matches');
Y.Assert.areEqual('a', a, 'Test passed param');
Y.Assert.areEqual('b', b, 'Test passed param');
this.seq++;
return 'x';
};
var rt = fn.call(scope, 'a', 'b'); // seq 1
Y.Assert.areEqual('x', rt, 'Test the return value');
Y.Assert.areEqual(1, scope.seq, 'Test the counter');
var cb = fn.createDelegate(scope).createSequence(fn, scope);
rt = cb('a', 'b'); // seq 2, 3
Y.Assert.areEqual('x', rt, 'Test the return value');
Y.Assert.areEqual(3, scope.seq, 'Test the number of times the sequence was called');
},
// 9
test_defer: function(){
var scope = {
foo: 'bar',
n: 0
};
var fn = function(a, b){
Y.Assert.areEqual(scope, this, 'Test if "this" is correct');
Y.Assert.areEqual('bar', this.foo, 'Test if property matches');
Y.Assert.areEqual('a', a, 'Test passed param');
Y.Assert.areEqual('b', b, 'Test passed param');
this.n++;
};
fn.defer(1, scope, ['a', 'b']);
fn.defer(2, scope, ['a', 'b']);
setTimeout(function(){
Y.Assert.areEqual(2, scope.n, 'Test if the counter matches the call timer count');
}, 4);
}
});
( run in 1.160 second using v1.01-cache-2.11-cpan-70e19b8f4f1 )