Skip to content

Commit eddb296

Browse files
author
s.vanriessen
committed
tests: add duplicated function name test
1 parent 806e832 commit eddb296

File tree

9 files changed

+81
-6
lines changed

9 files changed

+81
-6
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,12 +1300,11 @@ fn binding_name(func_name: &str, iface_name: &Option<String>) -> String {
13001300
}
13011301

13021302
fn binding_name_import(func_name: &str, iface_name: &Option<String>, import_name: &str) -> String {
1303-
let valid_import = import_name
1304-
.chars()
1305-
.map(|c| if c.is_alphanumeric() { c } else { '_' })
1306-
.collect::<String>();
1307-
13081303
if import_name != "<<INVALID>>" {
1304+
let valid_import = import_name
1305+
.chars()
1306+
.map(|c| if c.is_alphanumeric() { c } else { '_' })
1307+
.collect::<String>();
13091308
format!("{valid_import}${func_name}")
13101309
} else if let Some(iface_name) = iface_name {
13111310
format!("{iface_name}${func_name}")

test/bindings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ suite('Bindings', async () => {
9696
for (let [impt] of imports) {
9797
if (impt.startsWith('wasi:')) continue;
9898
if (impt.startsWith('[')) impt = impt.slice(impt.indexOf(']') + 1);
99-
let importName = impt.split('/').pop();
99+
let importName = impt.replace('/', '-');
100100
if (importName === 'test') importName = 'imports';
101101
map[impt] = `../../cases/${name}/${importName}.js`;
102102
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function run(endpoint) {
2+
return endpoint;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function run(endpoint) {
2+
return endpoint;
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as $local$e1ab0bfa$1 from 'local:http-request/http';
2+
import * as $local$15f12255$1 from 'local:http-request-part-two/http';
3+
4+
export function call(parameters) {
5+
console.log('call called with', parameters);
6+
// $local$e1ab0bfa$1.import.run('http://example.com');
7+
// $local$15f12255$1.import.run('http://example.com');
8+
return parameters;
9+
}
10+
11+
export const actions = {
12+
call,
13+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { strictEqual } from 'node:assert';
2+
3+
export function test(instance, args) {
4+
strictEqual(
5+
instance['actions'].call({
6+
actionId: '123',
7+
payload: { input: '' },
8+
}),
9+
''
10+
);
11+
strictEqual(
12+
instance['actions'].instance.call({
13+
actionId: '123',
14+
payload: { input: '' },
15+
}),
16+
'http://example.com'
17+
);
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package local:http-request-part-two;
2+
3+
interface http {
4+
run: func(endpoint: string) -> result<string, string>;
5+
}
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package local:http-request;
2+
3+
interface http {
4+
run: func(endpoint: string) -> result<string, string>;
5+
}
6+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package local:custom;
2+
3+
interface actions {
4+
type json-string = string;
5+
6+
record payload {
7+
input: json-string,
8+
}
9+
10+
record input {
11+
action-id: string,
12+
payload: payload,
13+
}
14+
15+
record output {
16+
%result: json-string,
17+
}
18+
19+
call: func(input: input) -> result<output, string>;
20+
}
21+
22+
world main {
23+
import local:http-request/http;
24+
import local:http-request-part-two/http;
25+
26+
export actions;
27+
}

0 commit comments

Comments
 (0)