unassignedconst.js 1015 B

12345678910111213141516171819
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. var passed = true;
  6. try { eval('const x;'); } catch (e) { if (e.message != "Const must be initialized") { passed = false; } }
  7. try { eval('function a() { const x; }'); } catch (e) { if (e.message != "Const must be initialized") { passed = false; } }
  8. WScript.LoadScriptFile('unassignedconst_noneval_global.js');
  9. try { test1(); } catch (e) { if (e.message != "Const must be initialized") { passed = false; }}
  10. WScript.LoadScriptFile('unassignedconst_noneval_function.js');
  11. try { test2(); } catch (e) { if (e.message != "Const must be initialized") { passed = false; }}
  12. if (passed) {
  13. print('Pass');
  14. }
  15. else {
  16. print('Fail');
  17. }