I8SelectColumnsOfB.js (3955B)
1 // This file contains all the tests for int8_select_columns_of_b intrinsic. It depends 2 // on the CommonTestSetup.js script which contains the common functionality 3 // that is required for testing all the intrinsics. 4 const COMMON_TEST_SETUP_SCRIPT = "./CommonTestSetup.js" 5 6 // All tests for this intrinsic as a string 7 const ALL_TESTS_AS_STRING =` 8 let {int8_select_columns_of_b} = instance.exports; 9 10 const VALID = {input: 0, rows: ROWS_B_MULTIPLIER, cols: COLUMNS_B_MULTIPLIER, colIndexList: ARRAY_ALIGNMENT << 3, sizeColIndexList: SELECTED_COLUMNS_B_MULTIPLIER, output: ARRAY_ALIGNMENT << 5}; 11 12 function testInvalidSize() { 13 let invalidSize; 14 15 // row: 0 16 invalidSize = 0; 17 assertErrorMessage(() => int8_select_columns_of_b(VALID.input, invalidSize, VALID.cols, VALID.colIndexList, VALID.sizeColIndexList, VALID.output), WebAssembly.RuntimeError, /unreachable/); 18 19 // row: Not an integral multiple of ROWS_B_MULTIPLIER 20 invalidSize = ROWS_B_MULTIPLIER + 1; 21 assertErrorMessage(() => int8_select_columns_of_b(VALID.input, invalidSize, VALID.cols, VALID.colIndexList, VALID.sizeColIndexList, VALID.output), WebAssembly.RuntimeError, /unreachable/); 22 23 // col: 0 24 invalidSize = 0; 25 assertErrorMessage(() => int8_select_columns_of_b(VALID.input, VALID.rows, invalidSize, VALID.colIndexList, VALID.sizeColIndexList, VALID.output), WebAssembly.RuntimeError, /unreachable/); 26 27 // col: Not an integral multiple of COLUMNS_B_MULTIPLIER 28 invalidSize = COLUMNS_B_MULTIPLIER + 1; 29 assertErrorMessage(() => int8_select_columns_of_b(VALID.input, VALID.rows, invalidSize, VALID.colIndexList, VALID.sizeColIndexList, VALID.output), WebAssembly.RuntimeError, /unreachable/); 30 31 // sizeColIndexList: 0 32 invalidSize = 0; 33 assertErrorMessage(() => int8_select_columns_of_b(VALID.input, VALID.rows, VALID.cols, VALID.colIndexList, invalidSize, VALID.output), WebAssembly.RuntimeError, /unreachable/); 34 35 // sizeColIndexList: Not an integral multiple of SELECTED_COLUMNS_B_MULTIPLIER 36 invalidSize = SELECTED_COLUMNS_B_MULTIPLIER + 1; 37 assertErrorMessage(() => int8_select_columns_of_b(VALID.input, VALID.rows, VALID.cols, VALID.colIndexList, invalidSize, VALID.output), WebAssembly.RuntimeError, /unreachable/); 38 } 39 40 function testInvalidAlignment() { 41 let invalidAlignment = ARRAY_ALIGNMENT + 1; 42 43 // input: Not an integral multiple of ARRAY_ALIGNMENT 44 assertErrorMessage(() => int8_select_columns_of_b(invalidAlignment, VALID.rows, VALID.cols, VALID.colIndexList, VALID.sizeColIndexList, VALID.output), WebAssembly.RuntimeError, /index out of bounds/); 45 } 46 47 function testOutOfBounds() { 48 let outOfBound; 49 50 // input: Out of Bounds 51 outOfBound = PageSizeInBytes - ARRAY_ALIGNMENT; 52 assertErrorMessage(() => int8_select_columns_of_b(outOfBound, VALID.rows, VALID.cols, VALID.colIndexList, VALID.sizeColIndexList, VALID.output), WebAssembly.RuntimeError, /index out of bounds/); 53 54 // colIndexList: Out of Bounds 55 outOfBound = PageSizeInBytes - VALID.sizeColIndexList; 56 assertErrorMessage(() => int8_select_columns_of_b(outOfBound, VALID.rows, VALID.cols, outOfBound, VALID.sizeColIndexList, VALID.output), WebAssembly.RuntimeError, /index out of bounds/); 57 58 // output: Out of Bounds 59 outOfBound = PageSizeInBytes - (VALID.rows * VALID.sizeColIndexList); 60 assertErrorMessage(() => int8_select_columns_of_b(VALID.input, VALID.rows, VALID.cols, VALID.colIndexList, VALID.sizeColIndexList, outOfBound), WebAssembly.RuntimeError, /index out of bounds/); 61 } 62 63 function testSuccessfulCall() { 64 // We just test that with valid arguments the intrinsic executes without any error 65 int8_select_columns_of_b(VALID.input, VALID.rows, VALID.cols, VALID.colIndexList, VALID.sizeColIndexList, VALID.output); 66 } 67 68 testInvalidSize(); 69 testInvalidAlignment(); 70 testOutOfBounds(); 71 testSuccessfulCall(); 72 ` 73 74 // Run all the tests 75 import(COMMON_TEST_SETUP_SCRIPT).then((importedModule) => { 76 importedModule.runTest(importedModule.COMMON_TEST_SETUP_AS_STRING + ALL_TESTS_AS_STRING); 77 });