assign_by_value.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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) { // Check for running in ch
  6. this.WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
  7. }
  8. var tests = [
  9. {
  10. name: "Assign BigInt literal",
  11. body: function () {
  12. var x = 123n;
  13. var y = x;
  14. assert.isTrue(x == 123n);
  15. assert.isTrue(y == 123n);
  16. x++;
  17. assert.isTrue(x == 124n);
  18. assert.isTrue(y == 123n);
  19. y = x;
  20. ++x;
  21. assert.isTrue(x == 125n);
  22. assert.isTrue(y == 124n);
  23. }
  24. },
  25. {
  26. name: "Assign BigInt object",
  27. body: function () {
  28. var x = BigInt(123n);
  29. var y = x;
  30. assert.isTrue(x == 123n);
  31. assert.isTrue(y == 123n);
  32. x++;
  33. assert.isTrue(x == 124n);
  34. assert.isTrue(y == 123n);
  35. y = x;
  36. ++x;
  37. assert.isTrue(x == 125n);
  38. assert.isTrue(y == 124n);
  39. }
  40. },
  41. ];
  42. testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });