Debian Codegraph @

js/src/tests/non262/extensions/redeclaration-of-catch-warning.js

raw
1 // |reftest| skip-if(!xulRuntime.shell)
2 //
3 // Any copyright is dedicated to the Public Domain.
4 // http://creativecommons.org/licenses/publicdomain/
5
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 622646;
8 var summary = "Shadowing an exception identifier in a catch block with a " +
9 "|const| or |let| declaration should throw an error";
10
11 print(BUGNUMBER + ": " + summary);
12
13 /**************
14 * BEGIN TEST *
15 **************/
16
17 function assertRedeclarationErrorThrown(expression)
18 {
19 "use strict";
20
21 try
22 {
23 evaluate(expression);
24 throw new Error("Redeclaration error wasn't thrown");
25 }
26 catch(e)
27 {
28 assertEq(e.message.indexOf("catch") > 0, true,
29 "wrong error, got " + e.message);
30 }
31 }
32
33 assertRedeclarationErrorThrown("try {} catch(e) { const e = undefined; }");
34 assertRedeclarationErrorThrown("try {} catch(e) { let e; }");
35
36 if (typeof reportCompare === "function")
37 reportCompare(true, true);