@@ -14,10 +14,20 @@ use wasm_bindgen_test::*;
14
14
15
15
module.exports.trivial = function () {};
16
16
17
+ module.exports.incoming_bool = function () { return true; };
18
+ module.exports.incoming_u8 = function () { return 255; };
19
+ module.exports.incoming_i8 = function () { return -127; };
20
+ module.exports.incoming_u16 = function () { return 65535; };
21
+ module.exports.incoming_i16 = function () { return 32767; };
22
+ module.exports.incoming_u32 = function () { return 4294967295; };
17
23
module.exports.incoming_i32 = function () { return 0; };
18
24
module.exports.incoming_f32 = function () { return 1.5; };
19
25
module.exports.incoming_f64 = function () { return 13.37; };
20
26
27
+ module.exports.outgoing_u8 = function (k) { assert_eq(k, 255); };
28
+ module.exports.outgoing_i8 = function (i) { assert_eq(i, -127); };
29
+ module.exports.outgoing_u16 = function (l) { assert_eq(l, 65535); };
30
+ module.exports.outgoing_i16 = function (j) { assert_eq(j, 32767); };
21
31
module.exports.outgoing_i32 = function (x) { assert_eq(x, 0); };
22
32
module.exports.outgoing_f32 = function (y) { assert_eq(y, 1.5); };
23
33
module.exports.outgoing_f64 = function (z) { assert_eq(z, 13.37); };
@@ -33,18 +43,42 @@ use wasm_bindgen_test::*;
33
43
assert_eq(v, 'hello');
34
44
return v;
35
45
};
46
+
47
+ module.exports.MyNamespace = {};
48
+ module.exports.MyNamespace.incoming_namespaced = function () { return 3.14; };
49
+ module.exports.MyNamespace.outgoing_namespaced = function (pi) { assert_eq(3.14, pi); };
36
50
" ) ]
37
51
extern "C" {
38
52
#[ wasm_bindgen( assert_no_shim) ]
39
53
fn trivial ( ) ;
40
54
55
+ #[ wasm_bindgen( assert_no_shim) ]
56
+ fn incoming_bool ( ) -> bool ;
57
+ #[ wasm_bindgen( assert_no_shim) ]
58
+ fn incoming_u8 ( ) -> u8 ;
59
+ #[ wasm_bindgen( assert_no_shim) ]
60
+ fn incoming_i8 ( ) -> i8 ;
61
+ #[ wasm_bindgen( assert_no_shim) ]
62
+ fn incoming_u16 ( ) -> u16 ;
63
+ #[ wasm_bindgen( assert_no_shim) ]
64
+ fn incoming_i16 ( ) -> i16 ;
65
+ #[ wasm_bindgen( assert_no_shim) ]
66
+ fn incoming_u32 ( ) -> u32 ;
41
67
#[ wasm_bindgen( assert_no_shim) ]
42
68
fn incoming_i32 ( ) -> i32 ;
43
69
#[ wasm_bindgen( assert_no_shim) ]
44
70
fn incoming_f32 ( ) -> f32 ;
45
71
#[ wasm_bindgen( assert_no_shim) ]
46
72
fn incoming_f64 ( ) -> f64 ;
47
73
74
+ #[ wasm_bindgen( assert_no_shim) ]
75
+ fn outgoing_u8 ( k : u8 ) ;
76
+ #[ wasm_bindgen( assert_no_shim) ]
77
+ fn outgoing_i8 ( i : i8 ) ;
78
+ #[ wasm_bindgen( assert_no_shim) ]
79
+ fn outgoing_u16 ( l : u16 ) ;
80
+ #[ wasm_bindgen( assert_no_shim) ]
81
+ fn outgoing_i16 ( j : i16 ) ;
48
82
#[ wasm_bindgen( assert_no_shim) ]
49
83
fn outgoing_i32 ( x : i32 ) ;
50
84
#[ wasm_bindgen( assert_no_shim) ]
@@ -55,6 +89,11 @@ extern "C" {
55
89
#[ wasm_bindgen( assert_no_shim) ]
56
90
fn many ( x : i32 , y : f32 , z : f64 ) -> i32 ;
57
91
92
+ #[ wasm_bindgen( assert_no_shim, js_namespace = MyNamespace ) ]
93
+ fn incoming_namespaced ( ) -> f64 ;
94
+ #[ wasm_bindgen( assert_no_shim, js_namespace = MyNamespace ) ]
95
+ fn outgoing_namespaced ( x : f64 ) ;
96
+
58
97
// Note that this should only skip the JS shim if we have anyref support
59
98
// enabled.
60
99
//
@@ -66,20 +105,47 @@ extern "C" {
66
105
fn no_shims ( ) {
67
106
trivial ( ) ;
68
107
108
+ let k = incoming_u8 ( ) ;
109
+ assert_eq ! ( k, 255 ) ;
110
+ outgoing_u8 ( k) ;
111
+
112
+ let l = incoming_u16 ( ) ;
113
+ assert_eq ! ( l, 65535 ) ;
114
+ outgoing_u16 ( l) ;
115
+
116
+ let m = incoming_u32 ( ) ;
117
+ assert_eq ! ( m, 4294967295 ) ;
118
+
119
+ let i = incoming_i8 ( ) ;
120
+ assert_eq ! ( i, -127 ) ;
121
+ outgoing_i8 ( i) ;
122
+
123
+ let j = incoming_i16 ( ) ;
124
+ assert_eq ! ( j, 32767 ) ;
125
+ outgoing_i16 ( j) ;
126
+
69
127
let x = incoming_i32 ( ) ;
70
128
assert_eq ! ( x, 0 ) ;
129
+ outgoing_i32 ( x) ;
130
+
71
131
let y = incoming_f32 ( ) ;
72
132
assert_eq ! ( y, 1.5 ) ;
133
+ outgoing_f32 ( y) ;
134
+
73
135
let z = incoming_f64 ( ) ;
74
136
assert_eq ! ( z, 13.37 ) ;
75
-
76
- outgoing_i32 ( x) ;
77
- outgoing_f32 ( y) ;
78
137
outgoing_f64 ( z) ;
79
138
80
139
let w = many ( x, y, z) ;
81
140
assert_eq ! ( w, 42 ) ;
82
141
142
+ let pi = incoming_namespaced ( ) ;
143
+ assert_eq ! ( pi, 3.14 ) ;
144
+ outgoing_namespaced ( pi) ;
145
+
146
+ let b = incoming_bool ( ) ;
147
+ assert ! ( b) ;
148
+
83
149
let v = JsValue :: from ( "hello" ) ;
84
150
let vv = works_when_anyref_support_is_enabled ( v. clone ( ) ) ;
85
151
assert_eq ! ( v, vv) ;
0 commit comments