| 
									
										
										
										
											2021-06-19 01:34:17 +01:00
										 |  |  | test("length is 1", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(Number).toHaveLength(1); | 
					
						
							| 
									
										
										
										
											2021-06-19 01:34:17 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-04-13 10:31:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-19 01:34:17 +01:00
										 |  |  | test("constructor without new", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(typeof Number()).toBe("number"); | 
					
						
							|  |  |  |     expect(typeof new Number()).toBe("object"); | 
					
						
							| 
									
										
										
										
											2020-05-02 19:18:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(Number()).toBe(0); | 
					
						
							| 
									
										
										
										
											2021-06-19 01:34:17 +01:00
										 |  |  |     expect(Number(123)).toBe(123); | 
					
						
							|  |  |  |     expect(Number(-123)).toBe(-123); | 
					
						
							|  |  |  |     expect(Number(123n)).toBe(123); | 
					
						
							|  |  |  |     expect(Number(-123n)).toBe(-123); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(Number("42")).toBe(42); | 
					
						
							|  |  |  |     expect(Number(null)).toBe(0); | 
					
						
							|  |  |  |     expect(Number(true)).toBe(1); | 
					
						
							|  |  |  |     expect(Number("Infinity")).toBe(Infinity); | 
					
						
							|  |  |  |     expect(Number("+Infinity")).toBe(Infinity); | 
					
						
							|  |  |  |     expect(Number("-Infinity")).toBe(-Infinity); | 
					
						
							|  |  |  |     expect(Number(undefined)).toBeNaN(); | 
					
						
							|  |  |  |     expect(Number({})).toBeNaN(); | 
					
						
							|  |  |  |     expect(Number({ a: 1 })).toBeNaN(); | 
					
						
							|  |  |  |     expect(Number([1, 2, 3])).toBeNaN(); | 
					
						
							|  |  |  |     expect(Number("foo")).toBeNaN(); | 
					
						
							| 
									
										
										
										
											2021-06-19 01:34:17 +01:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test("constructor with new", () => { | 
					
						
							|  |  |  |     expect(typeof new Number()).toBe("object"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect(new Number().valueOf()).toBe(0); | 
					
						
							|  |  |  |     expect(new Number(123).valueOf()).toBe(123); | 
					
						
							|  |  |  |     expect(new Number(-123).valueOf()).toBe(-123); | 
					
						
							|  |  |  |     expect(new Number(123n).valueOf()).toBe(123); | 
					
						
							|  |  |  |     expect(new Number(-123n).valueOf()).toBe(-123); | 
					
						
							|  |  |  |     expect(new Number("42").valueOf()).toBe(42); | 
					
						
							|  |  |  |     expect(new Number(null).valueOf()).toBe(0); | 
					
						
							|  |  |  |     expect(new Number(true).valueOf()).toBe(1); | 
					
						
							|  |  |  |     expect(new Number("Infinity").valueOf()).toBe(Infinity); | 
					
						
							|  |  |  |     expect(new Number("+Infinity").valueOf()).toBe(Infinity); | 
					
						
							|  |  |  |     expect(new Number("-Infinity").valueOf()).toBe(-Infinity); | 
					
						
							|  |  |  |     expect(new Number(undefined).valueOf()).toBeNaN(); | 
					
						
							|  |  |  |     expect(new Number({}).valueOf()).toBeNaN(); | 
					
						
							|  |  |  |     expect(new Number({ a: 1 }).valueOf()).toBeNaN(); | 
					
						
							|  |  |  |     expect(new Number([1, 2, 3]).valueOf()).toBeNaN(); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(new Number("foo").valueOf()).toBeNaN(); | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | }); |