Skip to content

Commit 00761a7

Browse files
rake format
1 parent 0137910 commit 00761a7

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

packages/npm-packages/ruby-wasm-wasi/test/init.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const rubyModule = (async () => {
1414
return await WebAssembly.compile(binary.buffer);
1515
})();
1616

17-
export const initRubyVM = async ({ suppressStderr } = { suppressStderr: false }) => {
17+
export const initRubyVM = async (
18+
{ suppressStderr } = { suppressStderr: false }
19+
) => {
1820
let preopens = {};
1921
if (process.env.RUBY_ROOT) {
2022
preopens["/usr"] = path.join(process.env.RUBY_ROOT, "./usr");

packages/npm-packages/ruby-wasm-wasi/test/vm.test.ts

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -139,39 +139,41 @@ eval:11:in \`<main>'`);
139139
}).toThrowError("Ruby APIs that may rewind the VM stack are prohibited");
140140
});
141141

142-
test.each([
143-
`JS::RubyVM.evalAsync("")`,
144-
])("nested VM rewinding operation should throw fatal error (async)", async (code) => {
145-
// Supress bugreport message triggered by the fatal error inside evalAsync
146-
const vm = await initRubyVM({ suppressStderr: true });
147-
const setVM = vm.eval(`proc { |vm| JS::RubyVM = vm }`);
148-
setVM.call("call", vm.wrap(vm));
142+
test.each([`JS::RubyVM.evalAsync("")`])(
143+
"nested VM rewinding operation should throw fatal error (async)",
144+
async (code) => {
145+
// Supress bugreport message triggered by the fatal error inside evalAsync
146+
const vm = await initRubyVM({ suppressStderr: true });
147+
const setVM = vm.eval(`proc { |vm| JS::RubyVM = vm }`);
148+
setVM.call("call", vm.wrap(vm));
149149

150-
// HACK: We need to capture all promises to avoid unhandled promise rejection
151-
const promises: Promise<any>[] = []
152-
const _Promise = global.Promise
153-
const spy = jest.spyOn(global, "Promise")
154-
.mockImplementation((future) => {
155-
const promise = new _Promise(future)
156-
promises.push(promise)
157-
return promise
158-
})
150+
// HACK: We need to capture all promises to avoid unhandled promise rejection
151+
const promises: Promise<any>[] = [];
152+
const _Promise = global.Promise;
153+
const spy = jest.spyOn(global, "Promise").mockImplementation((future) => {
154+
const promise = new _Promise(future);
155+
promises.push(promise);
156+
return promise;
157+
});
159158

160-
vm.evalAsync(code)
159+
vm.evalAsync(code);
161160

162-
const rejections: Error[] = []
163-
for (const promise of promises) {
164-
try {
165-
await promise
166-
} catch (e) {
167-
rejections.push(e)
161+
const rejections: Error[] = [];
162+
for (const promise of promises) {
163+
try {
164+
await promise;
165+
} catch (e) {
166+
rejections.push(e);
167+
}
168168
}
169-
}
170169

171-
spy.mockReset()
170+
spy.mockReset();
172171

173-
expect(rejections[0].message).toMatch("Ruby APIs that may rewind the VM stack are prohibited")
174-
});
172+
expect(rejections[0].message).toMatch(
173+
"Ruby APIs that may rewind the VM stack are prohibited"
174+
);
175+
}
176+
);
175177

176178
test("caught raise in nested eval is ok", async () => {
177179
const vm = await initRubyVM();

0 commit comments

Comments
 (0)