clz32.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. // intended to test inlining of Math.clz32
  6. // compliance tests are in es6 UT folder
  7. function module(glob, imp, b) {
  8. var clz = glob.Math.clz32;
  9. function f1(a)
  10. {
  11. a = a|0;
  12. return clz(a);
  13. }
  14. function f2()
  15. {
  16. return clz(0);
  17. }
  18. function f3()
  19. {
  20. return clz(0x80000000);
  21. }
  22. function f4()
  23. {
  24. return clz(32768);
  25. }
  26. function f5()
  27. {
  28. return clz(NaN);
  29. }
  30. function f6()
  31. {
  32. return clz(Infinity);
  33. }
  34. function f7()
  35. {
  36. return clz(undefined);
  37. }
  38. function f8()
  39. {
  40. return clz(true);
  41. }
  42. function f9()
  43. {
  44. return clz();
  45. }
  46. return {
  47. f1:f1,
  48. f2:f2,
  49. f3:f3,
  50. f4:f4,
  51. f5:f5,
  52. f6:f6,
  53. f7:f7,
  54. f8:f8,
  55. f9:f9
  56. }
  57. }
  58. var global = this;
  59. var env = {}
  60. var heap = new ArrayBuffer(1<<20);
  61. var m = module(global, env, heap);
  62. print(m.f1(0));
  63. print(m.f1(0));
  64. print(m.f1(0x80000000));
  65. print(m.f1(32768));
  66. print(m.f1(NaN));
  67. print(m.f1(Infinity));
  68. print(m.f1(undefined));
  69. print(m.f1(true));
  70. print(m.f2());
  71. print(m.f2());
  72. print(m.f3());
  73. print(m.f3());
  74. print(m.f4());
  75. print(m.f4());
  76. print(m.f5());
  77. print(m.f5());
  78. print(m.f6());
  79. print(m.f6());
  80. print(m.f7());
  81. print(m.f7());
  82. print(m.f8());
  83. print(m.f8());
  84. print(m.f9());
  85. print(m.f9());