inline_get_bailout.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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. if (this.WScript && this.WScript.LoadScriptFile) {
  6. WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
  7. WScript.LoadScriptFile("inline_get_bailout_helper.js");
  8. }
  9. let tests = [{
  10. name: "after inlining a getter function from another source file, we should bail out if the input data changes",
  11. body: function () {
  12. const bar = new Bar();
  13. function getWithGetter() {
  14. return bar.data;
  15. }
  16. let sum = 0;
  17. sum += getWithGetter();
  18. sum += getWithGetter();
  19. Object.defineProperty(bar, "data", { value: 3 });
  20. sum += getWithGetter();
  21. assert.areEqual(13, sum);
  22. }
  23. }];
  24. testRunner.run(tests, { verbose: WScript.Arguments[0] != "summary" });