bug_issue_5777.js 988 B

1234567891011121314151617181920212223
  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. // Bug Issue 5777 https://github.com/Microsoft/ChakraCore/issues/5777
  6. // Duplicate export names should cause an early syntax error
  7. WScript.RegisterModuleSource("a.js",
  8. `export const boo = 4;
  9. export {bar as boo} from "b.js";
  10. print ("Should not be printed")`);
  11. WScript.RegisterModuleSource("b.js","export const bar = 5;");
  12. import("a.js").then(()=>{
  13. print("Failed - expected SyntaxError but no error thrown")
  14. }).catch ((e)=>{
  15. if (e instanceof SyntaxError) {
  16. print("pass");
  17. } else {
  18. print (`Failed - threw ${e.constructor.toString()} but should have thrown SyntaxError`);
  19. }
  20. });