| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-13 16:32:21 -08:00
										 |  |  | // The functions in this file verify that the assumptions we are making
 | 
					
						
							|  |  |  | // about state in an instruction are correct before implementing any logic.
 | 
					
						
							|  |  |  | // They are meant only to be called in dev mode as sanity checks.
 | 
					
						
							| 
									
										
										
										
											2017-12-13 11:00:28 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-12 22:46:15 -08:00
										 |  |  | export function assertNumber(actual: any, msg: string) { | 
					
						
							|  |  |  |   if (typeof actual != 'number') { | 
					
						
							|  |  |  |     throwError(msg); | 
					
						
							| 
									
										
										
										
											2018-01-08 21:57:50 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-12 22:46:15 -08:00
										 |  |  | export function assertEqual<T>(actual: T, expected: T, msg: string) { | 
					
						
							|  |  |  |   if (actual != expected) { | 
					
						
							|  |  |  |     throwError(msg); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-12 22:46:15 -08:00
										 |  |  | export function assertNotEqual<T>(actual: T, expected: T, msg: string) { | 
					
						
							|  |  |  |   if (actual == expected) { | 
					
						
							|  |  |  |     throwError(msg); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-12 22:46:15 -08:00
										 |  |  | export function assertSame<T>(actual: T, expected: T, msg: string) { | 
					
						
							|  |  |  |   if (actual !== expected) { | 
					
						
							|  |  |  |     throwError(msg); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-12 22:46:15 -08:00
										 |  |  | export function assertLessThan<T>(actual: T, expected: T, msg: string) { | 
					
						
							|  |  |  |   if (actual >= expected) { | 
					
						
							|  |  |  |     throwError(msg); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-12 22:46:15 -08:00
										 |  |  | export function assertNull<T>(actual: T, msg: string) { | 
					
						
							|  |  |  |   if (actual != null) { | 
					
						
							|  |  |  |     throwError(msg); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-12 22:46:15 -08:00
										 |  |  | export function assertNotNull<T>(actual: T, msg: string) { | 
					
						
							|  |  |  |   if (actual == null) { | 
					
						
							|  |  |  |     throwError(msg); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-12-01 14:23:03 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-12 22:46:15 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function throwError(msg: string): never { | 
					
						
							|  |  |  |   throw new Error(`ASSERTION ERROR: ${msg}`); | 
					
						
							|  |  |  | } |