mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-04 07:10:57 +00:00 
			
		
		
		
	Using ErrorType::ReferencePrimitiveSetProperty the errors for primitives now look like "Cannot set property 'foo' of number '123'". The strict-mode-errors test has been adjusted and re-enabled.
		
			
				
	
	
		
			19 lines
		
	
	
	
		
			696 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
	
		
			696 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
"use strict";
 | 
						|
 | 
						|
test("basic functionality", () => {
 | 
						|
    [true, false, "foo", 123, 123n, null, undefined].forEach(primitive => {
 | 
						|
        let description = `${typeof primitive} '${primitive}${
 | 
						|
            typeof primitive == "bigint" ? "n" : ""
 | 
						|
        }'`;
 | 
						|
        if (primitive == null) description = String(primitive);
 | 
						|
        expect(() => {
 | 
						|
            primitive.foo = "bar";
 | 
						|
        }).toThrowWithMessage(TypeError, `Cannot set property 'foo' of ${description}`);
 | 
						|
        expect(() => {
 | 
						|
            primitive[Symbol.hasInstance] = 123;
 | 
						|
        }).toThrowWithMessage(
 | 
						|
            TypeError,
 | 
						|
            `Cannot set property 'Symbol(Symbol.hasInstance)' of ${description}`
 | 
						|
        );
 | 
						|
    });
 | 
						|
});
 |