testWithFlag.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 equal(a, b) {
  6. if (a == b)
  7. {
  8. print("Correct");
  9. }
  10. else
  11. {
  12. print(">> Fail!");
  13. }
  14. }
  15. function testWithFlagX() {
  16. print("Int32x4 withFlagX");
  17. var a = SIMD.Int32x4.bool(true, false, true, false);
  18. var c = SIMD.Int32x4.withFlagX(a, true);
  19. equal(true, c.flagX);
  20. equal(false, c.flagY);
  21. equal(true, c.flagZ);
  22. equal(false, c.flagW);
  23. c = SIMD.Int32x4.withFlagX(a, false);
  24. equal(false, c.flagX);
  25. equal(false, c.flagY);
  26. equal(true, c.flagZ);
  27. equal(false, c.flagW);
  28. equal(0x0, SIMD.Int32x4.extractLane(c, 0));
  29. equal(0x0, SIMD.Int32x4.extractLane(c, 1));
  30. equal(-1, SIMD.Int32x4.extractLane(c, 2));
  31. equal(0x0, SIMD.Int32x4.extractLane(c, 3));
  32. }
  33. function testWithFlagY() {
  34. print("Int32x4 withFlagY");
  35. var a = SIMD.Int32x4.bool(true, false, true, false);
  36. var c = SIMD.Int32x4.withFlagY(a, true);
  37. equal(true, c.flagX);
  38. equal(true, c.flagY);
  39. equal(true, c.flagZ);
  40. equal(false, c.flagW);
  41. c = SIMD.Int32x4.withFlagY(a, false);
  42. equal(true, c.flagX);
  43. equal(false, c.flagY);
  44. equal(true, c.flagZ);
  45. equal(false, c.flagW);
  46. equal(-1, SIMD.Int32x4.extractLane(c, 0));
  47. equal(0x0, SIMD.Int32x4.extractLane(c, 1));
  48. equal(-1, SIMD.Int32x4.extractLane(c, 2));
  49. equal(0x0, SIMD.Int32x4.extractLane(c, 3));
  50. }
  51. function testWithFlagZ() {
  52. print("Int32x4 withFlagZ");
  53. var a = SIMD.Int32x4.bool(true, false, true, false);
  54. var c = SIMD.Int32x4.withFlagZ(a, true);
  55. equal(-1, SIMD.Int32x4.extractLane(c, 0));
  56. equal(true, c.flagX);
  57. equal(false, c.flagY);
  58. equal(true, c.flagZ);
  59. equal(false, c.flagW);
  60. c = SIMD.Int32x4.withFlagZ(a, false);
  61. equal(true, c.flagX);
  62. equal(false, c.flagY);
  63. equal(false, c.flagZ);
  64. equal(false, c.flagW);
  65. equal(-1, SIMD.Int32x4.extractLane(c, 0));
  66. equal(0x0, SIMD.Int32x4.extractLane(c, 1));
  67. equal(0x0, SIMD.Int32x4.extractLane(c, 1));
  68. equal(0x0, SIMD.Int32x4.extractLane(c, 3));
  69. }
  70. function testWithFlagW() {
  71. print("Int32x4 withFlagW");
  72. var a = SIMD.Int32x4.bool(true, false, true, false);
  73. var c = SIMD.Int32x4.withFlagW(a, true);
  74. equal(true, c.flagX);
  75. equal(false, c.flagY);
  76. equal(true, c.flagZ);
  77. equal(true, c.flagW);
  78. c = SIMD.Int32x4.withFlagW(a, false);
  79. equal(true, c.flagX);
  80. equal(false, c.flagY);
  81. equal(true, c.flagZ);
  82. equal(false, c.flagW);
  83. equal(-1, SIMD.Int32x4.extractLane(c, 0));
  84. equal(0x0, SIMD.Int32x4.extractLane(c, 1));
  85. equal(-1, SIMD.Int32x4.extractLane(c, 2));
  86. equal(0x0, SIMD.Int32x4.extractLane(c, 3));
  87. }
  88. testWithFlagX();
  89. testWithFlagX();
  90. testWithFlagX();
  91. testWithFlagX();
  92. testWithFlagX();
  93. testWithFlagX();
  94. testWithFlagX();
  95. testWithFlagX();
  96. testWithFlagY();
  97. testWithFlagY();
  98. testWithFlagY();
  99. testWithFlagY();
  100. testWithFlagY();
  101. testWithFlagY();
  102. testWithFlagY();
  103. testWithFlagY();
  104. testWithFlagZ();
  105. testWithFlagZ();
  106. testWithFlagZ();
  107. testWithFlagZ();
  108. testWithFlagZ();
  109. testWithFlagZ();
  110. testWithFlagZ();
  111. testWithFlagZ();
  112. testWithFlagW();
  113. testWithFlagW();
  114. testWithFlagW();
  115. testWithFlagW();
  116. testWithFlagW();
  117. testWithFlagW();
  118. testWithFlagW();
  119. testWithFlagW();