2016-12-21 15:19:23 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cat > test.js << EOF
|
|
|
|
var task = new Task();
|
|
|
|
task.onExit = function() {
|
|
|
|
print("child exited");
|
|
|
|
};
|
|
|
|
task.activate();
|
2021-01-02 13:10:00 -05:00
|
|
|
task.execute({name: "child.js", source: utf8Decode(File.readFile("child.js"))}).then(async function() {
|
2016-12-21 15:19:23 -05:00
|
|
|
print("child started");
|
2021-01-02 13:10:00 -05:00
|
|
|
var input = new Uint8Array(10);
|
2016-12-21 15:19:23 -05:00
|
|
|
for (var i = 0; i < 10; i++) {
|
|
|
|
input[i] = i;
|
|
|
|
}
|
|
|
|
var test = (await task.getExports()).test;
|
2021-01-02 13:10:00 -05:00
|
|
|
var output = new Uint8Array(await test(input));
|
|
|
|
print("input", input, input.length, input.byteLength);
|
|
|
|
print("output", output, output.length, output.byteLength);
|
2016-12-21 15:19:23 -05:00
|
|
|
for (var i = 0; i < 10; i++) {
|
|
|
|
print(output[i]);
|
|
|
|
if (output[i] != i) {
|
|
|
|
print("output[" + i + "] == " + output[i]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
});
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > child.js << EOF
|
|
|
|
exports = {
|
|
|
|
test: function(data) {
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
$TILDEFRIENDS test.js
|