mirror of
				https://github.com/tc39/test262.git
				synced 2025-11-04 05:33:50 +01:00 
			
		
		
		
	* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import { variable, constVariable, letVariable, functionDeclaration, classDeclaration } from "./imported-bindings-are-immutable/bindings.js"
 | 
						|
import { shouldBe, shouldThrow } from "./resources/assert.js"
 | 
						|
 | 
						|
shouldBe(variable, 'Cocoa');
 | 
						|
shouldThrow(() => {
 | 
						|
    variable = 42;
 | 
						|
}, `TypeError: Attempted to assign to readonly property.`);
 | 
						|
 | 
						|
shouldBe(constVariable, 'Cocoa');
 | 
						|
shouldThrow(() => {
 | 
						|
    constVariable = 42;
 | 
						|
}, `TypeError: Attempted to assign to readonly property.`);
 | 
						|
 | 
						|
shouldBe(letVariable, 'Cocoa');
 | 
						|
shouldThrow(() => {
 | 
						|
    letVariable = 42;
 | 
						|
}, `TypeError: Attempted to assign to readonly property.`);
 | 
						|
 | 
						|
shouldBe(typeof functionDeclaration, 'function');
 | 
						|
shouldThrow(() => {
 | 
						|
    functionDeclaration = 42;
 | 
						|
}, `TypeError: Attempted to assign to readonly property.`);
 | 
						|
 | 
						|
shouldBe(typeof classDeclaration, 'function');
 | 
						|
shouldThrow(() => {
 | 
						|
    classDeclaration = 42;
 | 
						|
}, `TypeError: Attempted to assign to readonly property.`);
 | 
						|
 | 
						|
 | 
						|
function reference(read) {
 | 
						|
    if (read)
 | 
						|
        return letVariable;
 | 
						|
    else
 | 
						|
        letVariable = "Cocoa";
 | 
						|
}
 | 
						|
noInline(reference);
 | 
						|
 | 
						|
for (var i = 0; i < 10000; ++i)
 | 
						|
    reference(true);
 | 
						|
 | 
						|
shouldThrow(() => {
 | 
						|
    reference(false);
 | 
						|
}, `TypeError: Attempted to assign to readonly property.`);
 |