| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | load("test-common.js"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | try { | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   function foo(...a) { | 
					
						
							|  |  |  |     assert(a instanceof Array); | 
					
						
							|  |  |  |     assert(a.length === 0); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   foo(); | 
					
						
							| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   function foo1(...a) { | 
					
						
							|  |  |  |     assert(a instanceof Array); | 
					
						
							|  |  |  |     assert(a.length === 4); | 
					
						
							|  |  |  |     assert(a[0] === "foo"); | 
					
						
							|  |  |  |     assert(a[1] === 123); | 
					
						
							|  |  |  |     assert(a[2] === undefined); | 
					
						
							|  |  |  |     assert(a[3].foo === "bar"); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   foo1("foo", 123, undefined, { foo: "bar" }); | 
					
						
							| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   function foo2(a, b, ...c) { | 
					
						
							|  |  |  |     assert(a === "foo"); | 
					
						
							|  |  |  |     assert(b === 123); | 
					
						
							|  |  |  |     assert(c instanceof Array); | 
					
						
							|  |  |  |     assert(c.length === 0); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   foo2("foo", 123); | 
					
						
							| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   function foo3(a, b, ...c) { | 
					
						
							|  |  |  |     assert(a === "foo"); | 
					
						
							|  |  |  |     assert(b === 123); | 
					
						
							|  |  |  |     assert(c instanceof Array); | 
					
						
							|  |  |  |     assert(c.length === 2); | 
					
						
							|  |  |  |     assert(c[0] === undefined); | 
					
						
							|  |  |  |     assert(c[1].foo === "bar"); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   foo3("foo", 123, undefined, { foo: "bar" }); | 
					
						
							| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   var foo = (...a) => { | 
					
						
							|  |  |  |     assert(a instanceof Array); | 
					
						
							|  |  |  |     assert(a.length === 0); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   foo(); | 
					
						
							| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   var foo = (a, b, ...c) => { | 
					
						
							|  |  |  |     assert(a === "foo"); | 
					
						
							|  |  |  |     assert(b === 123); | 
					
						
							|  |  |  |     assert(c instanceof Array); | 
					
						
							|  |  |  |     assert(c.length === 2); | 
					
						
							|  |  |  |     assert(c[0] === undefined); | 
					
						
							|  |  |  |     assert(c[1].foo === "bar"); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   foo("foo", 123, undefined, { foo: "bar" }); | 
					
						
							| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   console.log("PASS"); | 
					
						
							| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | } catch (e) { | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |   console.log("FAIL: " + e); | 
					
						
							| 
									
										
										
										
											2020-05-04 16:05:13 +01:00
										 |  |  | } |