shru_peep.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 Failed = 0;
  6. function FAILED()
  7. {
  8. Failed++;
  9. }
  10. function test(a, b)
  11. {
  12. if (((a|0)>>>0) > ((b|0)>>>0))
  13. return true;
  14. else
  15. return false;
  16. }
  17. function foo()
  18. {
  19. return 1;
  20. }
  21. function bar()
  22. {
  23. return -1;
  24. }
  25. function test2(a, f)
  26. {
  27. if (((a|0)>>>0) > ((f()|0)>>>0))
  28. return true;
  29. else
  30. return false;
  31. }
  32. for (var i = 0; i < 50; i++)
  33. {
  34. if (!test(-1, 1))
  35. FAILED();
  36. if (!test2(-1, foo))
  37. FAILED();
  38. }
  39. if (test(1,-1))
  40. FAILED();
  41. if (!test(-1,(-1>>>0)+10))
  42. FAILED();
  43. // Force bailout
  44. if (test2(1,bar))
  45. FAILED();
  46. if (Failed == 0)
  47. WScript.Echo("Passed");
  48. else
  49. WScript.Echo("FAILED");