duplicate-imports.js (959B)
1 // Test errors due to duplicate lexically declared names. 2 3 load(libdir + "asserts.js"); 4 5 function testNoError(source) { 6 parseModule(source); 7 } 8 9 function testSyntaxError(source) { 10 assertThrowsInstanceOf(() => parseModule(source), SyntaxError); 11 } 12 13 testNoError("import { a } from 'm';"); 14 testNoError("import { a as b } from 'm';"); 15 testNoError("import * as a from 'm';"); 16 testNoError("import a from 'm';"); 17 18 testSyntaxError("import { a } from 'm'; let a = 1;"); 19 testSyntaxError("let a = 1; import { a } from 'm';"); 20 testSyntaxError("import { a } from 'm'; var a = 1;"); 21 testSyntaxError("var a = 1; import { a } from 'm';"); 22 testSyntaxError("import { a, b } from 'm'; const b = 1;"); 23 testSyntaxError("import { a } from 'm'; import { a } from 'm2';"); 24 testSyntaxError("import { a } from 'm'; import { b as a } from 'm2';"); 25 testSyntaxError("import { a } from 'm'; import * as a from 'm2';"); 26 testSyntaxError("import { a } from 'm'; import a from 'm2';");