web/test/testutils.js
changeset 0 b97547f5f1fa
equal deleted inserted replaced
-1:000000000000 0:b97547f5f1fa
       
     1 function datetuple(d) {
       
     2     return [d.getFullYear(), d.getMonth()+1, d.getDate(), 
       
     3 	    d.getHours(), d.getMinutes()];
       
     4 }
       
     5     
       
     6 function pprint(obj) {
       
     7     print('{');
       
     8     for(k in obj) {
       
     9 	print('  ' + k + ' = ' + obj[k]);
       
    10     }
       
    11     print('}');
       
    12 }
       
    13 
       
    14 function arrayrepr(array) {
       
    15     return '[' + array.join(', ') + ']';
       
    16 }
       
    17     
       
    18 function assertArrayEquals(array1, array2) {
       
    19     if (array1.length != array2.length) {
       
    20 	throw new crosscheck.AssertionFailure(array1.join(', ') + ' != ' + array2.join(', '));
       
    21     }
       
    22     for (var i=0; i<array1.length; i++) {
       
    23 	if (array1[i] != array2[i]) {
       
    24 	    
       
    25 	    throw new crosscheck.AssertionFailure(arrayrepr(array1) + ' and ' + arrayrepr(array2)
       
    26 						 + ' differs at index ' + i);
       
    27 	}
       
    28     }
       
    29 }