Skip to content

Commit 91866e4

Browse files
author
s.vanriessen
committed
test: add dup interface test
1 parent eddb296 commit 91866e4

File tree

12 files changed

+48
-65
lines changed

12 files changed

+48
-65
lines changed

test/bindings.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ 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.replace('/', '-');
99+
let importName = impt.split('/').pop();
100+
if (name === 'import-duplicated-interface')
101+
importName = impt.replace('/', '-').replace(':', '-');
100102
if (importName === 'test') importName = 'imports';
101103
map[impt] = `../../cases/${name}/${importName}.js`;
102104
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function hello(name) {
2+
return `Hello 1.0.0, ${name}`
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function hello(name) {
2+
if (name) {
3+
return `Hello 2.0.0, ${name}`
4+
} else {
5+
return undefined
6+
}
7+
}

test/cases/import-duplicated-interface/local:http-request-http.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/cases/import-duplicated-interface/local:http-request-part-two-http.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import * as $local$e1ab0bfa$1 from 'local:http-request/http';
2-
import * as $local$15f12255$1 from 'local:http-request-part-two/http';
1+
import { hello as hello1 } from 'local:hello/hello';
2+
import { hello as hello2 } from 'local:hello-second/hello';
33

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,
4+
export const exports = {
5+
hello(str) {
6+
if (str === 'hello') {
7+
return `world ${str} (${hello1('world')})`;
8+
}
9+
if (str === 'hello-second') {
10+
return `world ${str} (${hello2('world')})`;
11+
}
12+
return `world unknown ${str}`;
13+
},
1314
};
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import { strictEqual } from 'node:assert';
22

3-
export function test(instance, args) {
3+
export function test(instance) {
44
strictEqual(
5-
instance['actions'].call({
6-
actionId: '123',
7-
payload: { input: '' },
8-
}),
9-
''
5+
instance.exports.hello('hello'),
6+
'world hello (Hello 1.0.0, world)'
107
);
118
strictEqual(
12-
instance['actions'].instance.call({
13-
actionId: '123',
14-
payload: { input: '' },
15-
}),
16-
'http://example.com'
9+
instance.exports.hello('hello-second'),
10+
'world hello-second (Hello 2.0.0, world)'
1711
);
12+
strictEqual(instance.exports.hello('unknown'), 'world unknown unknown');
1813
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package local:hello-second;
2+
3+
interface hello {
4+
hello: func(name: option<string>) -> option<string>;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package local:hello;
2+
3+
interface hello {
4+
hello: func(name: string) -> string;
5+
}

test/cases/import-duplicated-interface/wit/deps/local-http-request-part-two/package.wit

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)