| 
									
										
										
										
											2020-10-19 18:01:28 +01:00
										 |  |  | // FIXME: Some of the test cases below are duplicated, presumably to test
 | 
					
						
							|  |  |  | // uppercase as well which then got lowercased by Prettier at some point.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | test("hex literals", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(0xff).toBe(255); | 
					
						
							|  |  |  |     expect(0xff).toBe(255); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-04-13 10:31:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | test("octal literals", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(0o10).toBe(8); | 
					
						
							|  |  |  |     expect(0o10).toBe(8); | 
					
						
							| 
									
										
										
										
											2020-10-19 18:01:28 +01:00
										 |  |  |     expect(010).toBe(8); | 
					
						
							| 
									
										
										
										
											2020-10-27 19:30:27 +00:00
										 |  |  |     expect(089).toBe(89); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-04-05 14:20:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | test("binary literals", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(0b10).toBe(2); | 
					
						
							|  |  |  |     expect(0b10).toBe(2); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-04-13 16:56:20 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | test("exponential literals", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(1e3).toBe(1000); | 
					
						
							|  |  |  |     expect(1e3).toBe(1000); | 
					
						
							|  |  |  |     expect(1e-3).toBe(0.001); | 
					
						
							|  |  |  |     expect(1e1).toBe(10); | 
					
						
							|  |  |  |     expect(0.1e1).toBe(1); | 
					
						
							|  |  |  |     expect(0.1e1).toBe(1); | 
					
						
							|  |  |  |     expect(0.1e1).toBe(1); | 
					
						
							|  |  |  |     expect(0.1e1).toBe(1); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test("decimal numbers", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect(1).toBe(1); | 
					
						
							|  |  |  |     expect(0.1).toBe(0.1); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test("accessing properties of decimal numbers", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     Number.prototype.foo = "foo"; | 
					
						
							|  |  |  |     expect((1).foo).toBe("foo"); | 
					
						
							|  |  |  |     expect((1.1).foo).toBe("foo"); | 
					
						
							|  |  |  |     expect((0.1).foo).toBe("foo"); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:39:25 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-10-18 15:32:50 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | test("invalid numeric literals", () => { | 
					
						
							|  |  |  |     expect("1e").not.toEval(); | 
					
						
							|  |  |  |     expect("0x").not.toEval(); | 
					
						
							|  |  |  |     expect("0b").not.toEval(); | 
					
						
							|  |  |  |     expect("0o").not.toEval(); | 
					
						
							| 
									
										
										
										
											2020-10-19 18:01:28 +01:00
										 |  |  |     expect("'use strict'; 0755").not.toEval(); | 
					
						
							| 
									
										
										
										
											2020-10-22 22:18:31 +01:00
										 |  |  |     expect("1in[]").not.toEval(); | 
					
						
							|  |  |  |     expect("2instanceof foo").not.toEval(); | 
					
						
							| 
									
										
										
										
											2020-10-18 15:32:50 +02:00
										 |  |  | }); |