mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-30 03:03:51 +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)
		
			
				
	
	
		
			116 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			116 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| let globalLet = "let";
 | |
| function globalFunction() { }
 | |
| class globalClass { }
 | |
| const globalConst = 20;
 | |
| var globalVar = 21;
 | |
| this.globalProperty = 22;
 | |
| 
 | |
| let sentinel = "__s__";
 | |
| 
 | |
| function assert(b) {
 | |
|     if (!b)
 | |
|         throw new Error("bad assertion");
 | |
| }
 | |
| 
 | |
| function assertExpectations() {
 | |
|     assert(sentinel === "__s__");
 | |
| }
 | |
| 
 | |
| 
 | |
| let errorCount = 0;
 | |
| function assertProperError(e) {
 | |
|     if (e instanceof SyntaxError && e.message.indexOf("Can't create duplicate variable") !== -1) {
 | |
|         errorCount++;
 | |
|     } else {
 | |
|         assert(false);
 | |
|     }
 | |
| 
 | |
| }
 | |
| 
 | |
| assertExpectations();
 | |
| 
 | |
| try {
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/first.js");
 | |
| } catch(e) {
 | |
|     assertProperError(e);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| try {
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/second.js");
 | |
| } catch(e) {
 | |
|     assertProperError(e);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| try {
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/third.js");
 | |
| } catch(e) {
 | |
|     assertProperError(e);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| try {
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/fourth.js");
 | |
| } catch(e) {
 | |
|     assertProperError(e);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| try {
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/fifth.js");
 | |
| } catch(e) {
 | |
|     assertProperError(e);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| // Checking if the implementation is following
 | |
| // ES6 spec 8.1.1.4.14 http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasrestrictedglobalproperty
 | |
| 
 | |
| try {
 | |
|     sentinel = "bad";
 | |
|     assert(Object.getOwnPropertyDescriptor(this, "globalProperty").configurable);
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/sixth.js");
 | |
| } catch(e) {
 | |
|     assert(false);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| try {
 | |
|     sentinel = "bad";
 | |
|     assert(Object.getOwnPropertyDescriptor(this, "Array").configurable);
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/seventh.js");
 | |
| } catch(e) {
 | |
|     assert(false);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| try {
 | |
|     sentinel = "bad";
 | |
|     Object.defineProperty(this, 'foo', {value: 5, configurable: true, writable: true});
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/eighth.js");
 | |
| } catch(e) {
 | |
|     assert(false);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| try {
 | |
|     Object.defineProperty(this, 'bar', {value: 5, configurable: false, writable: true});
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/ninth.js");
 | |
| } catch(e) {
 | |
|     assertProperError(e);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| assert(errorCount === 6);
 | |
| 
 | |
| try {
 | |
|     Object.defineProperty(this, 'zoo', {value: undefined, configurable: false, writable: true});
 | |
|     load("./multiple-files-tests/global-lexical-redeclare-variable/tenth.js");
 | |
| } catch(e) {
 | |
|     assertProperError(e);
 | |
| }
 | |
| assertExpectations();
 | |
| 
 | |
| assert(errorCount === 7);
 |