Skip to content

Commit 8371570

Browse files
author
s.vanriessen
committed
test: replace import override to test file
1 parent 7e6c2c3 commit 8371570

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

crates/spidermonkey-embedding-splicer/src/bindgen.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,23 @@ fn binding_name(func_name: &str, iface_name: &Option<String>) -> String {
12991299
}
13001300
}
13011301

1302+
/// Determine the binding name of a given import
1303+
/// example wit:
1304+
/// package local:hello;
1305+
/// interface greeter {
1306+
/// greet(name: string): string;
1307+
/// }
1308+
/// word main {
1309+
/// export greeter;
1310+
/// }
1311+
///
1312+
/// # Arguments
1313+
/// * `func_name` - function name (e.g. `greet`)
1314+
/// * `iface_name` - an interface name, if present (e.g. `greeter`)
1315+
/// * `import_name` - qualified import specifier (e.g. `local:hello`)
1316+
///
13021317
fn binding_name_import(func_name: &str, iface_name: &Option<String>, import_name: &str) -> String {
1318+
// import_name is only valid when FunctionKind is Freestanding
13031319
if import_name != "<<INVALID>>" {
13041320
let valid_import = import_name
13051321
.chars()

test/bindings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ suite('Bindings', async () => {
9797
if (impt.startsWith('wasi:')) continue;
9898
if (impt.startsWith('[')) impt = impt.slice(impt.indexOf(']') + 1);
9999
let importName = impt.split('/').pop();
100-
if (name === 'import-duplicated-interface')
101-
importName = impt.replace('/', '-').replace(':', '-');
100+
if (testcase.importNameOverride)
101+
importName = testcase.importNameOverride(impt);
102102
if (importName === 'test') importName = 'imports';
103103
map[impt] = `../../cases/${name}/${importName}.js`;
104104
}

test/cases/import-duplicated-interface/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ export function test(instance) {
1111
);
1212
strictEqual(instance.exports.hello('unknown'), 'world unknown unknown');
1313
}
14+
15+
export function importNameOverride(importName) {
16+
return importName.replace('/', '-').replace(':', '-');
17+
}

0 commit comments

Comments
 (0)