Skip to content

Commit

Permalink
Move exception handing into
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Sep 7, 2019
1 parent 5ed29e0 commit ba6e5df
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 65 deletions.
8 changes: 1 addition & 7 deletions src/detectors/bulk-memory/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ import inlineModule from "wat2wasm:--enable-bulk-memory:./module.wat";
import { testCompile } from "../../helpers.js";

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
8 changes: 1 addition & 7 deletions src/detectors/exceptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ import inlineModule from "wat2wasm:--enable-exceptions:./module.wat";
import { testCompile } from "../../helpers.js";

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
8 changes: 1 addition & 7 deletions src/detectors/multi-value/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ import inlineModule from "wat2wasm:--enable-multi-value:./module.wat";
import { testCompile } from "../../helpers.js";

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
8 changes: 1 addition & 7 deletions src/detectors/mutable-globals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,5 @@ import inlineModule from "wat2wasm::./module.wat";
import { testCompile } from "../../helpers.js";

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
8 changes: 1 addition & 7 deletions src/detectors/reference-types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ import inlineModule from "wat2wasm:--enable-reference-types:./module.wat";
import { testCompile } from "../../helpers.js";

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
8 changes: 1 addition & 7 deletions src/detectors/saturated-float-to-int/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ import inlineModule from "wat2wasm:--enable-saturating-float-to-int:./module.wat
import { testCompile } from "../../helpers.js";

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
8 changes: 1 addition & 7 deletions src/detectors/sign-extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ import inlineModule from "wat2wasm:--enable-sign-extension:./module.wat";
import { testCompile } from "../../helpers.js";

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
7 changes: 1 addition & 6 deletions src/detectors/simd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,5 @@ import inlineModule from "wat2wasm:--enable-simd:./module.wat";
import { testCompile } from "../../helpers.js";

export default async function() {
try {
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
8 changes: 1 addition & 7 deletions src/detectors/tail-call/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ import inlineModule from "wat2wasm:--enable-tail-call:./module.wat";
import { testCompile } from "../../helpers.js";

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}
3 changes: 1 addition & 2 deletions src/detectors/threads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export default async function() {
port1.postMessage(sab);
});
// Test for atomics
await testCompile(inlineModule);
return true;
return testCompile(inlineModule);
} catch (e) {
return false;
}
Expand Down
7 changes: 6 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@
// be called quite often and by having our own function terser can give it
// a one-letter name.
export async function testCompile(path) {
return WebAssembly.compile(await fetch(path).then(r => r.arrayBuffer()));
try {
await WebAssembly.compile(await fetch(path).then(r => r.arrayBuffer()));
return true;
} catch (e) {
return false;
}
}

0 comments on commit ba6e5df

Please sign in to comment.