testTrue.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 b16 = stdlib.SIMD.Bool8x16;
  9. var b16check = b16.check;
  10. var b16allTrue = b16.allTrue;
  11. var b16anyTrue = b16.anyTrue;
  12. var globImportb16 = b16check(imports.g1);
  13. var b16g1 = b16(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  14. var loopCOUNT = 5;
  15. function testAnyTrue()
  16. {
  17. var a = b16(1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0);
  18. var result = 0;
  19. var loopIndex = 0;
  20. while ((loopIndex | 0) < (loopCOUNT | 0))
  21. {
  22. result = b16anyTrue(a) | 0;
  23. loopIndex = (loopIndex + 1) | 0;
  24. }
  25. return result | 0;
  26. }
  27. function testAllTrue()
  28. {
  29. var a = b16(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  30. var result = 0;
  31. var loopIndex = 0;
  32. while ((loopIndex | 0) < (loopCOUNT | 0))
  33. {
  34. result = b16allTrue(a) | 0;
  35. loopIndex = (loopIndex + 1) | 0;
  36. }
  37. return result | 0;
  38. }
  39. return {testAnyTrue:testAnyTrue, testAllTrue:testAllTrue};
  40. }
  41. var m = asmModule(this, { g1: SIMD.Bool8x16(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) });
  42. equal(1, m.testAnyTrue());
  43. equal(1, m.testAllTrue());
  44. print("PASS");