2020-05-06 00:13:23 +09:00
|
|
|
const testModule = require('./index.node')
|
2020-02-19 00:05:13 +09:00
|
|
|
|
|
|
|
function testSpawn() {
|
|
|
|
console.log('=== Test spawning a future on libuv event loop')
|
|
|
|
return testModule.testSpawn()
|
|
|
|
}
|
|
|
|
|
|
|
|
function testThrow() {
|
|
|
|
console.log('=== Test throwing from Rust')
|
|
|
|
try {
|
|
|
|
testModule.testThrow()
|
2020-05-12 14:59:20 +09:00
|
|
|
console.log('Expected function to throw an error')
|
2020-05-06 00:13:23 +09:00
|
|
|
process.exit(1)
|
2020-02-19 00:05:13 +09:00
|
|
|
} catch (e) {
|
2020-05-12 14:59:20 +09:00
|
|
|
console.log(e)
|
2020-02-19 00:05:13 +09:00
|
|
|
}
|
|
|
|
}
|
2020-05-12 14:59:20 +09:00
|
|
|
testSpawn()
|
2020-05-06 00:13:23 +09:00
|
|
|
.then((value) => {
|
|
|
|
console.info(`${value} from napi`)
|
|
|
|
testThrow()
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
2020-02-19 00:05:13 +09:00
|
|
|
console.error(e)
|
|
|
|
process.exit(1)
|
|
|
|
})
|