testComparisons.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. this.WScript.LoadScriptFile("..\\UnitTestFramework\\SimdJsHelpers.js");
  6. function testComparisons() {
  7. var m = SIMD.Int32x4(1000, 2000, 100, 1);
  8. var n = SIMD.Int32x4(2000, 2000, 1, 100);
  9. var cmp;
  10. cmp = SIMD.Int32x4.lessThan(m, n);
  11. equal(true, SIMD.Bool32x4.extractLane(cmp, 0));
  12. equal(false, SIMD.Bool32x4.extractLane(cmp, 1));
  13. equal(false, SIMD.Bool32x4.extractLane(cmp, 2));
  14. equal(true, SIMD.Bool32x4.extractLane(cmp, 3));
  15. cmp = SIMD.Int32x4.equal(m, n);
  16. equal(false, SIMD.Bool32x4.extractLane(cmp, 0));
  17. equal(true, SIMD.Bool32x4.extractLane(cmp, 1));
  18. equal(false, SIMD.Bool32x4.extractLane(cmp, 2));
  19. equal(false, SIMD.Bool32x4.extractLane(cmp, 3));
  20. cmp = SIMD.Int32x4.greaterThan(m, n);
  21. equal(false, SIMD.Bool32x4.extractLane(cmp, 0));
  22. equal(false, SIMD.Bool32x4.extractLane(cmp, 1));
  23. equal(true, SIMD.Bool32x4.extractLane(cmp, 2));
  24. equal(false, SIMD.Bool32x4.extractLane(cmp, 3));
  25. cmp = SIMD.Int32x4.lessThanOrEqual(m, n);
  26. equal(true, SIMD.Bool32x4.extractLane(cmp, 0));
  27. equal(true, SIMD.Bool32x4.extractLane(cmp, 1));
  28. equal(false, SIMD.Bool32x4.extractLane(cmp, 2));
  29. equal(true, SIMD.Bool32x4.extractLane(cmp, 3));
  30. cmp = SIMD.Int32x4.notEqual(m, n);
  31. equal(true, SIMD.Bool32x4.extractLane(cmp, 0));
  32. equal(false, SIMD.Bool32x4.extractLane(cmp, 1));
  33. equal(true, SIMD.Bool32x4.extractLane(cmp, 2));
  34. equal(true, SIMD.Bool32x4.extractLane(cmp, 3));
  35. cmp = SIMD.Int32x4.greaterThanOrEqual(m, n);
  36. equal(false, SIMD.Bool32x4.extractLane(cmp, 0));
  37. equal(true, SIMD.Bool32x4.extractLane(cmp, 1));
  38. equal(true, SIMD.Bool32x4.extractLane(cmp, 2));
  39. equal(false, SIMD.Bool32x4.extractLane(cmp, 3));
  40. }
  41. testComparisons();
  42. testComparisons();
  43. testComparisons();
  44. testComparisons();
  45. testComparisons();
  46. testComparisons();
  47. testComparisons();
  48. testComparisons();
  49. print("PASS");