Skip to content

Commit

Permalink
[unity] fix #853
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieyang committed Jul 6, 2022
1 parent bace464 commit 93dc7ce
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions unity/general/Src/UnitTest/JSTypeTest/ArrayBufferTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,24 @@ public void Test8()

Assert.AreEqual("1", res);
}

[Test]
public void JSFunctionInvokeWithArrayBuffer()
{
var jsEnv = new JsEnv(new TxtLoader());
jsEnv.UsingFunc<Puerts.ArrayBuffer, int, Puerts.ArrayBuffer>();

Func<Puerts.ArrayBuffer, int, Puerts.ArrayBuffer> callback = jsEnv.Eval<Func<Puerts.ArrayBuffer, int, Puerts.ArrayBuffer>>(@"
(function() {
const CS = require('csharp');
return function(data, length) {
return data.slice(0, length - 1)
};
})()
");
Puerts.ArrayBuffer ab = callback(new Puerts.ArrayBuffer(new byte[] { 1, 2, 3 }), 3);
Assert.True(ab.Count == 2);
}
}
}

0 comments on commit 93dc7ce

Please sign in to comment.