| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | describe("non-syntax errors", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("super reference inside nested-but-same |this| scope with no base class", () => { | 
					
						
							|  |  |  |         expect(`
 | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  |     class A { | 
					
						
							|  |  |  |       foo() { | 
					
						
							|  |  |  |         () => { super.bar; } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }`).toEval();
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("super reference property lookup with no base class", () => { | 
					
						
							|  |  |  |         expect(`
 | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  |     class A { | 
					
						
							|  |  |  |       constructor() { | 
					
						
							|  |  |  |         super.foo; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }`).toEval();
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe("reference errors", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("derived class doesn't call super in constructor before using this", () => { | 
					
						
							|  |  |  |         class Parent {} | 
					
						
							|  |  |  |         class Child extends Parent { | 
					
						
							|  |  |  |             constructor() { | 
					
						
							|  |  |  |                 this; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         expect(() => { | 
					
						
							|  |  |  |             new Child(); | 
					
						
							|  |  |  |         }).toThrowWithMessage(ReferenceError, "|this| has not been initialized"); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("derived class calls super twice in constructor", () => { | 
					
						
							|  |  |  |         class Parent {} | 
					
						
							|  |  |  |         class Child extends Parent { | 
					
						
							|  |  |  |             constructor() { | 
					
						
							|  |  |  |                 super(); | 
					
						
							|  |  |  |                 super(); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         expect(() => { | 
					
						
							|  |  |  |             new Child(); | 
					
						
							|  |  |  |         }).toThrowWithMessage(ReferenceError, "|this| is already initialized"); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe("syntax errors", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("getter with argument", () => { | 
					
						
							|  |  |  |         expect(`
 | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  |     class A { | 
					
						
							|  |  |  |       get foo(v) { | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }`).not.toEval();
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("setter with no arguments", () => { | 
					
						
							|  |  |  |         expect(`
 | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  |     class A { | 
					
						
							|  |  |  |       set foo() { | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }`).not.toEval();
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("setter with more than one argument", () => { | 
					
						
							|  |  |  |         expect(`
 | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  |     class A { | 
					
						
							|  |  |  |       set foo(bar, baz) { | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-10-20 18:43:58 +01:00
										 |  |  |     }`).not.toEval();
 | 
					
						
							|  |  |  |         expect(`
 | 
					
						
							|  |  |  |     class A { | 
					
						
							|  |  |  |       set foo(...bar) { | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  |     }`).not.toEval();
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("super reference inside different |this| scope", () => { | 
					
						
							|  |  |  |         expect(`
 | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  |     class Parent {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     class Child extends Parent { | 
					
						
							|  |  |  |       foo() { | 
					
						
							|  |  |  |         function f() { super.foo; } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }`).not.toEval();
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test("super reference call with no base class", () => { | 
					
						
							|  |  |  |         expect(`
 | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  |     class A { | 
					
						
							|  |  |  |       constructor() { | 
					
						
							|  |  |  |         super(); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }`).not.toEval();
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-05 17:26:26 -07:00
										 |  |  | }); |