array.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. var mod = new WebAssembly.Module(readbuffer('array.wasm'));
  6. var a = new WebAssembly.Instance(mod).exports;
  7. print(a["goodload"](0));
  8. try {
  9. print(a["badload"](0));
  10. }
  11. catch(e) {
  12. print(e.message.includes("out of range") ? "PASSED" : "FAILED");
  13. }
  14. try {
  15. a["badstore"](0);
  16. }
  17. catch(e) {
  18. print(e.message.includes("out of range") ? "PASSED" : "FAILED");
  19. }
  20. a.goodload(65535)
  21. try {
  22. a.goodload(65536)
  23. }
  24. catch(e) {
  25. print(e.message.includes("out of range") ? "PASSED" : "FAILED");
  26. }
  27. a.goodstore(0)
  28. a.goodstore(65535)
  29. try {
  30. a.goodstore(65536)
  31. }
  32. catch(e) {
  33. print(e.message.includes("out of range") ? "PASSED" : "FAILED");
  34. }