2
0

modopt.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. function write(v) { WScript.Echo(v + ""); }
  6. // Bailout cases
  7. function modByNeg(x)
  8. {
  9. return 32 % x;
  10. }
  11. function modByNonPowerOf2(x)
  12. {
  13. return 32 % x;
  14. }
  15. function modOfNeg(a, x)
  16. {
  17. a = a | 0; // forces typespec
  18. return a % x;
  19. }
  20. function runTest()
  21. {
  22. write(modByNeg(16)); // by power of 2
  23. write(modByNeg(-3)) // cause bailout
  24. write(modByNonPowerOf2(16*16)); // by power of 2
  25. write(modByNonPowerOf2(23)) // cause bailout
  26. write(modOfNeg(100, 32));
  27. write(modOfNeg(-12, 32)); // cause bailout
  28. for(var i=0; i < 500; i++)
  29. {
  30. modByNeg(-3); // cause rejit
  31. }
  32. }
  33. runTest();