1 // find *Spec.js files in the src directory next to the corresponding source file
3 var test = window.test = {};
5 test.cb = (function( jasmine ) {
12 createSpy: function( name, arg, data, context ) {
13 return jasmine.createSpy( name ).and.callFake( function() {
14 callbacks.push( { cb: arguments[ arg || 0 ], data: data, context: context } );
18 var exec = callbacks.shift();
19 exec.cb.apply( exec.context, exec.data );
22 while( callbacks.length ) {
30 test.clock = ( function() {
31 var id = 0, timers, saved;
32 var names = [ "setTimeout", "setInterval", "clearTimeout", "clearInterval" ];
33 var byNext = function( a, b ) { return a.next - b.next; };
35 setTimeout: function( fn, t ) {
36 timers.push( { id: id, fn: fn, next: t, t: t, type: "t" } );
39 clearTimeout: function( id ) {
40 timers = timers.filter( function( timer ) { return timer.id !== id; } );
42 setInterval: function( fn, t ) {
43 timers.push( { id: id, fn: fn, next: t, t: t, type: "i" } );
46 clearInterval: function( id ) {
47 timers = timers.filter( function( timer ) { return timer.id !== id; } );
55 names.forEach( function( n ) {
61 names.forEach( function( n ) {
69 timers.sort( byNext );
71 if( t0.type === "t" ) {