mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-31 19:53:50 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| //@ runDefault("--useBigInt=true", "--useDFGJIT=false")
 | |
| 
 | |
| function assert(a, message) {
 | |
|     if (!a)
 | |
|         throw new Error(message);
 | |
| }
 | |
| 
 | |
| let a = (1n << 1048575n) - 1n;
 | |
| a = (a << 1n) | 1n;
 | |
| 
 | |
| try {
 | |
|     let b = a + 1n;
 | |
|     assert(false, "Should throw OutOfMemoryError, but executed without exception");
 | |
| } catch(e) {
 | |
|     assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
 | |
| }
 | |
| 
 | |
| try {
 | |
|     let b = a - (-1n);
 | |
|     assert(false, "Should throw OutOfMemoryError, but executed without exception");
 | |
| } catch(e) {
 | |
|     assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
 | |
| }
 | |
| 
 | |
| try {
 | |
|     let b = a * (-1n);
 | |
|     assert(false, "Should throw OutOfMemoryError, but executed without exception");
 | |
| } catch(e) {
 | |
|     assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
 | |
| }
 | |
| 
 | |
| try {
 | |
|     let b = a / a;
 | |
|     assert(false, "Should throw OutOfMemoryError, but executed without exception");
 | |
| } catch(e) {
 | |
|     assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
 | |
| }
 | |
| 
 | |
| try {
 | |
|     let b = -a & -1n;
 | |
|     assert(false, "Should throw OutOfMemoryError, but executed without exception");
 | |
| } catch(e) {
 | |
|     assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
 | |
| }
 | |
| 
 | |
| try {
 | |
|     let b = a ^ -1n;
 | |
|     assert(false, "Should throw OutOfMemoryError, but executed without exception");
 | |
| } catch(e) {
 | |
|     assert(e.message == "Out of memory", "Expected OutOfMemoryError, but got: " + e);
 | |
| }
 | |
| 
 |