testTrue.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft Corporation and contributors. 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 asmModule(stdlib, imports) {
  7. "use asm";
  8. var b4 = stdlib.SIMD.Bool32x4;
  9. var b4check = b4.check;
  10. var b4allTrue = b4.allTrue;
  11. var b4anyTrue = b4.anyTrue;
  12. var globImportb4 = b4check(imports.g1);
  13. var b4g1 = b4(0, 0, 0, 0);
  14. var loopCOUNT = 5;
  15. function testAnyTrue() {
  16. var a = b4(1, 0, 1, 0);
  17. var result = 0;
  18. var loopIndex = 0;
  19. while ((loopIndex | 0) < (loopCOUNT | 0)) {
  20. result = b4anyTrue(a) | 0;
  21. loopIndex = (loopIndex + 1) | 0;
  22. }
  23. return result | 0;
  24. }
  25. function testAllTrue()
  26. {
  27. var a = b4(1, 1, 1, 1);
  28. var result = 0;
  29. var loopIndex = 0;
  30. while ((loopIndex | 0) < (loopCOUNT | 0)) {
  31. result = b4allTrue(a) | 0;
  32. loopIndex = (loopIndex + 1) | 0;
  33. }
  34. return result | 0;
  35. }
  36. return {testAnyTrue:testAnyTrue, testAllTrue:testAllTrue};
  37. }
  38. var m = asmModule(this, {g1:SIMD.Bool32x4(1, 0, 1, 1)});
  39. equal(1, m.testAnyTrue());
  40. equal(1, m.testAllTrue());
  41. print("PASS");