mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:32:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			47 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="../include.js"></script>
 | |
| <script>
 | |
|     test(() => {
 | |
|         println(structuredClone(new Boolean(true)));
 | |
|         println(structuredClone(new Boolean(false)));
 | |
|         println(structuredClone(new Number(123)));
 | |
|         println(structuredClone(new Number(123.456)));
 | |
|         println(structuredClone(new String("This is a String object")));
 | |
|         println(structuredClone(BigInt("0x1fffffffffffff")));
 | |
|         println(structuredClone(Date.UTC(2023, 7, 23)));
 | |
|         println(structuredClone(/abc/gimsuy));
 | |
|         println(structuredClone(new Error()));
 | |
|         println(structuredClone(new URIError("hello")));
 | |
|         println(structuredClone(JSON.stringify({"a": "b", 1: 2})));
 | |
|         println(structuredClone([1, 4, "aaaa"]));
 | |
|         println(structuredClone(new Set(["a", "b", "c"])).has("b"));
 | |
|         println(structuredClone(new Map([["a", 0], ["b", 1], ["c", 2]])).get("b"));
 | |
| 
 | |
|         const obj = {"a": 1, "c": 3};
 | |
|         obj["b"] = obj;
 | |
|         const result = structuredClone(obj);
 | |
|         println(result === result["b"]);
 | |
| 
 | |
|         {
 | |
|             let arrayBuffer = new ArrayBuffer(6);
 | |
|             for (let i = 0; i < arrayBuffer.byteLength; ++i) {
 | |
|                 arrayBuffer[i] = i;
 | |
|             }
 | |
|             let arrayClone = structuredClone(arrayBuffer);
 | |
|             for (let i = 0; i < arrayBuffer.byteLength; ++i) {
 | |
|                 if (arrayBuffer[i] !== arrayBuffer[i]) {
 | |
|                     println("FAILED");
 | |
|                 }
 | |
|             }
 | |
|             // FIXME: This should print something like ArrayBuffer { byteLength: 6 }
 | |
|             println(arrayClone);
 | |
|         }
 | |
| 
 | |
|         try {
 | |
|             structuredClone(Symbol("foo"));
 | |
|             println("FAILED")
 | |
|         }
 | |
|         catch(e) {
 | |
|             println("ERROR: " + e.name + ": " + e.message)
 | |
|         }
 | |
|     });
 | |
| </script>
 | 
