Serenity Operating System
at master 30 lines 1.1 kB view raw
1describe("duplicated variable declarations should throw", () => { 2 test("given two declarations in the same statement", () => { 3 expect("let a, a;").not.toEval(); 4 expect("const a, a;").not.toEval(); 5 6 expect("var a, a;").toEval(); 7 }); 8 9 test("fail to parse if repeated over multiple statements", () => { 10 expect("let a; var a;").not.toEval(); 11 expect("let b, a; var c, a;").not.toEval(); 12 expect("const a; var a;").not.toEval(); 13 expect("const b, a; var c, a;").not.toEval(); 14 }); 15 16 test("should fail to parse even if variable first declared with var", () => { 17 expect("var a; let a;").not.toEval(); 18 expect("var a; let b, a;").not.toEval(); 19 expect("var a; const a;").not.toEval(); 20 expect("var a; const b, a;").not.toEval(); 21 }); 22 23 test("special cases with for loops", () => { 24 expect("for (var a;;) { let a; }").toEval(); 25 expect("for (let a;;) { let a; }").toEval(); 26 expect("for (var a;;) { var a; }").toEval(); 27 28 expect("for (let a;;) { var a; }").not.toEval(); 29 }); 30});