| 
									
										
										
										
											2015-02-15 19:56:03 -08:00
										 |  |  | import {describe, it, expect, iit} from 'angular2/test_lib'; | 
					
						
							| 
									
										
										
										
											2014-10-02 11:51:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | var inc = x => x + 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var objLiteral = val => ({'key': val}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var max = (a, b) => { | 
					
						
							|  |  |  |   if (a > b) { | 
					
						
							|  |  |  |     return a; | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     return b; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-15 19:56:03 -08:00
										 |  |  | var namedFn = function({fn}) { | 
					
						
							|  |  |  |   return fn(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-02 11:51:10 +02:00
										 |  |  | class LexicalThis { | 
					
						
							| 
									
										
										
										
											2014-11-21 21:19:23 -08:00
										 |  |  |   zero; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-02 11:51:10 +02:00
										 |  |  |   constructor() { | 
					
						
							|  |  |  |     this.zero = 0; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   getZero() { | 
					
						
							|  |  |  |     return (() => this.zero)(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('arrow functions', function() { | 
					
						
							|  |  |  |     it('should support implicit return', function() { | 
					
						
							|  |  |  |       expect(inc(0)).toBe(1); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-15 19:56:03 -08:00
										 |  |  |     it('should support implicit return in named arguments', function() { | 
					
						
							|  |  |  |       expect(namedFn({fn: () => 1})).toBe(1); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-02 11:51:10 +02:00
										 |  |  |     it('should support object literal', function() { | 
					
						
							|  |  |  |       var o = objLiteral('val'); | 
					
						
							|  |  |  |       expect(o['key']).toBe('val'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should support complex body', function() { | 
					
						
							|  |  |  |       expect(max(0, 1)).toBe(1); | 
					
						
							|  |  |  |       expect(max(1, 0)).toBe(1); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-15 19:56:03 -08:00
										 |  |  |     it('should support complex body in named arguments', function() { | 
					
						
							|  |  |  |       expect(namedFn({fn: () => { | 
					
						
							|  |  |  |         return 1; | 
					
						
							|  |  |  |       }})).toBe(1); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-02 11:51:10 +02:00
										 |  |  |     it('should support lexical this', function() { | 
					
						
							|  |  |  |       var lthis = new LexicalThis(); | 
					
						
							|  |  |  |       expect(lthis.getZero()).toBe(0); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-02-15 19:56:03 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-02 11:51:10 +02:00
										 |  |  |   }); | 
					
						
							|  |  |  | } |