testMinMax.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. WScript.Echo("Correct");
  8. else
  9. WScript.Echo(">> Fail!");
  10. }
  11. function dislay(a) {
  12. WScript.Echo("0:" + SIMD.Int32x4.extractLane(c, 0) + "\n");
  13. WScript.Echo("1:" + SIMD.Int32x4.extractLane(c, 1) + "\n");
  14. WScript.Echo("2:" + SIMD.Int32x4.extractLane(c, 2) + "\n");
  15. WScript.Echo("3:" + SIMD.Int32x4.extractLane(c, 3) + "\n");
  16. }
  17. function testMin() {
  18. WScript.Echo("Int32x4 min");
  19. var a = SIMD.Int32x4(0xFFFFFFFF, 0xFFFFFFFF, 0x7fffffff, 0x0);
  20. var b = SIMD.Int32x4(0x1, 0xFFFFFFFF, 0x1, 0xFFFFFFFF);
  21. var c = SIMD.Int32x4.min(a, b);
  22. equal(-1, SIMD.Int32x4.extractLane(c, 0));
  23. equal(-1, SIMD.Int32x4.extractLane(c, 1));
  24. equal(1, SIMD.Int32x4.extractLane(c, 2));
  25. equal(-1, SIMD.Int32x4.extractLane(c, 3));
  26. var m = SIMD.Int32x4(4, 3, 2, 1);
  27. var n = SIMD.Int32x4(10, 20, 30, 40);
  28. var f = SIMD.Int32x4.min(m, n);
  29. equal(4, SIMD.Int32x4.extractLane(f, 0));
  30. equal(3, SIMD.Int32x4.extractLane(f, 1));
  31. equal(2, SIMD.Int32x4.extractLane(f, 2));
  32. equal(1, SIMD.Int32x4.extractLane(f, 3));
  33. }
  34. function testMax() {
  35. WScript.Echo("Int32x4 max");
  36. var a = SIMD.Int32x4(0xFFFFFFFF, 0xFFFFFFFF, 0x80000000, 0x0);
  37. var b = SIMD.Int32x4(0x1, 0xFFFFFFFF, 0x1, 0xFFFFFFFF);
  38. var c = SIMD.Int32x4.max(a, b);
  39. equal(1, SIMD.Int32x4.extractLane(c, 0));
  40. equal(-1, SIMD.Int32x4.extractLane(c, 1));
  41. equal(1, SIMD.Int32x4.extractLane(c, 2));
  42. equal(0, SIMD.Int32x4.extractLane(c, 3));
  43. var d = SIMD.Int32x4(4, 3, 2, 1);
  44. var e = SIMD.Int32x4(10, 20, 30, 40);
  45. var f = SIMD.Int32x4.max(d, e);
  46. equal(10, SIMD.Int32x4.extractLane(f, 0));
  47. equal(20, SIMD.Int32x4.extractLane(f, 1));
  48. equal(30, SIMD.Int32x4.extractLane(f, 2));
  49. equal(40, SIMD.Int32x4.extractLane(f, 3));
  50. }
  51. testMin();
  52. testMin();
  53. testMin();
  54. testMin();
  55. testMin();
  56. testMin();
  57. testMin();
  58. testMax();
  59. testMax();
  60. testMax();
  61. testMax();
  62. testMax();
  63. testMax();
  64. testMax();