Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuang committed Mar 1, 2025
1 parent 7ac71bf commit f8fa035
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,18 @@ const testRunInNewThread = () => {
}

const testFunction = () => {
const funcDesc = funcConstructor({
paramsType: [
DataType.I32,
DataType.Boolean,
DataType.String,
DataType.Double,
arrayConstructor({ type: DataType.StringArray, length: 2 }),
arrayConstructor({ type: DataType.I32Array, length: 3 }),
personType,
],
retType: DataType.I32,
})
const func = (a, b, c, d, e, f, g) => {
equal(a, 100);
equal(b, false);
Expand All @@ -304,36 +316,14 @@ const testFunction = () => {
logGreen("test function succeed");
// free function memory which malloc in c side when it not in use
freePointer({
paramsType: [funcConstructor({
paramsType: [
DataType.I32,
DataType.Boolean,
DataType.String,
DataType.Double,
arrayConstructor({ type: DataType.StringArray, length: 2 }),
arrayConstructor({ type: DataType.I32Array, length: 3 }),
personType,
],
retType: DataType.Void,
})],
paramsType: [funcDesc],
paramsValue: funcExternal,
pointerType: PointerType.RsPointer
})
return 100
};
const funcExternal = createPointer({
paramsType: [funcConstructor({
paramsType: [
DataType.I32,
DataType.Boolean,
DataType.String,
DataType.Double,
arrayConstructor({ type: DataType.StringArray, length: 2 }),
arrayConstructor({ type: DataType.I32Array, length: 3 }),
personType,
],
retType: DataType.I32,
})],
paramsType: [funcDesc],
paramsValue: [func]
})
load({
Expand Down

0 comments on commit f8fa035

Please sign in to comment.