| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-22 17:33:08 +02:00
										 |  |  | export default class T { | 
					
						
							| 
									
										
										
										
											2021-04-22 03:30:46 +02:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |     constructor(testsuite: string, tests: [string, () => void ][]) { | 
					
						
							| 
									
										
										
										
											2020-08-22 17:33:08 +02:00
										 |  |  |         let failures : string []= []; | 
					
						
							|  |  |  |         for (const [name, test] of tests) { | 
					
						
							|  |  |  |             try { | 
					
						
							|  |  |  |                 test(); | 
					
						
							|  |  |  |             } catch (e) { | 
					
						
							|  |  |  |                 failures.push(name); | 
					
						
							|  |  |  |                 console.warn("Failed test: ", name, "because", e); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (failures.length == 0) { | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |             console.log(`All tests of ${testsuite} done!`) | 
					
						
							| 
									
										
										
										
											2020-08-22 17:33:08 +02:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |             console.warn(failures.length, `tests of ${testsuite} failed :(`) | 
					
						
							| 
									
										
										
										
											2020-08-22 17:33:08 +02:00
										 |  |  |             console.log("Failed tests: ", failures.join(",")) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 01:45:51 +01:00
										 |  |  |     static assertContains(needle: string, actual: string){ | 
					
						
							|  |  |  |         if(actual.indexOf(needle) < 0){ | 
					
						
							|  |  |  |             throw `The substring ${needle} was not found` | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-09 13:59:49 +02:00
										 |  |  |     static isTrue(b: boolean, msg: string) { | 
					
						
							|  |  |  |         if(!b){ | 
					
						
							|  |  |  |             throw "Expected true, but got false: "+msg | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-22 17:33:08 +02:00
										 |  |  | } |