@@ -16,15 +16,18 @@ mod test {
16
16
use bevy_mod_scripting_derive:: script_bindings;
17
17
18
18
use crate :: {
19
- bindings:: function:: {
20
- from:: { Ref , Val } ,
21
- namespace:: IntoNamespace ,
22
- script_function:: AppScriptFunctionRegistry ,
19
+ bindings:: {
20
+ function:: {
21
+ from:: { Ref , Val } ,
22
+ namespace:: IntoNamespace ,
23
+ script_function:: AppScriptFunctionRegistry ,
24
+ } ,
25
+ script_value:: ScriptValue ,
23
26
} ,
24
- error :: InteropError ,
27
+ docgen :: typed_through :: TypedThrough ,
25
28
} ;
26
29
27
- use super :: arg_meta:: { ScriptArgument , ScriptReturn } ;
30
+ use super :: arg_meta:: { ScriptArgument , ScriptReturn , TypedScriptArgument , TypedScriptReturn } ;
28
31
29
32
#[ test]
30
33
fn test_macro_generates_correct_registrator_function ( ) {
@@ -66,14 +69,14 @@ mod test {
66
69
assert_eq ! ( test_fn. info. arg_info[ 1 ] . name, Some ( "_arg1" . into( ) ) ) ;
67
70
68
71
assert_eq ! (
69
- test_fn. info. return_info. type_id,
72
+ test_fn. info. return_info. as_ref ( ) . unwrap ( ) . type_id,
70
73
std:: any:: TypeId :: of:: <( ) >( )
71
74
) ;
72
75
}
73
76
74
- fn test_is_valid_return < T : ScriptReturn > ( ) { }
75
- fn test_is_valid_arg < T : ScriptArgument > ( ) { }
76
- fn test_is_valid_arg_and_return < T : ScriptArgument + ScriptReturn > ( ) { }
77
+ fn test_is_valid_return < T : TypedScriptReturn > ( ) { }
78
+ fn test_is_valid_arg < T : TypedScriptArgument > ( ) { }
79
+ fn test_is_valid_arg_and_return < T : TypedScriptReturn + TypedScriptArgument > ( ) { }
77
80
78
81
#[ test]
79
82
fn primitives_are_valid_args ( ) {
@@ -92,6 +95,7 @@ mod test {
92
95
test_is_valid_arg_and_return :: < f64 > ( ) ;
93
96
test_is_valid_arg_and_return :: < usize > ( ) ;
94
97
test_is_valid_arg_and_return :: < isize > ( ) ;
98
+ test_is_valid_arg_and_return :: < ScriptValue > ( ) ;
95
99
}
96
100
97
101
#[ test]
@@ -100,14 +104,15 @@ mod test {
100
104
test_is_valid_arg_and_return :: < std:: path:: PathBuf > ( ) ;
101
105
test_is_valid_arg_and_return :: < std:: ffi:: OsString > ( ) ;
102
106
test_is_valid_arg_and_return :: < char > ( ) ;
107
+ test_is_valid_return :: < & ' static str > ( ) ;
103
108
}
104
109
105
110
#[ test]
106
111
fn composites_are_valid_args ( ) {
107
112
fn test_val < T > ( )
108
113
where
109
114
T : ScriptArgument + ScriptReturn ,
110
- T : GetTypeRegistration + FromReflect ,
115
+ T : GetTypeRegistration + FromReflect + Typed ,
111
116
{
112
117
test_is_valid_arg_and_return :: < Val < T > > ( ) ;
113
118
}
@@ -128,12 +133,10 @@ mod test {
128
133
test_is_valid_arg :: < Ref < ' _ , T > > ( ) ;
129
134
}
130
135
131
- test_is_valid_return :: < InteropError > ( ) ;
132
-
133
136
fn test_array < T , const N : usize > ( )
134
137
where
135
138
T : ScriptArgument + ScriptReturn ,
136
- T : GetTypeRegistration + FromReflect + Typed ,
139
+ T : GetTypeRegistration + FromReflect + TypedThrough + Typed ,
137
140
for < ' a > T :: This < ' a > : Into < T > ,
138
141
{
139
142
test_is_valid_arg_and_return :: < [ T ; N ] > ( ) ;
@@ -142,7 +145,7 @@ mod test {
142
145
fn test_tuple < T > ( )
143
146
where
144
147
T : ScriptArgument + ScriptReturn ,
145
- T : GetTypeRegistration + FromReflect + Typed ,
148
+ T : GetTypeRegistration + FromReflect + TypedThrough + Typed ,
146
149
for < ' a > T :: This < ' a > : Into < T > ,
147
150
{
148
151
test_is_valid_arg_and_return :: < ( ) > ( ) ;
@@ -154,7 +157,7 @@ mod test {
154
157
fn test_option < T > ( )
155
158
where
156
159
T : ScriptArgument + ScriptReturn ,
157
- T : GetTypeRegistration + FromReflect + Typed ,
160
+ T : GetTypeRegistration + FromReflect + Typed + TypedThrough ,
158
161
for < ' a > T :: This < ' a > : Into < T > ,
159
162
{
160
163
test_is_valid_arg_and_return :: < Option < T > > ( ) ;
@@ -163,7 +166,7 @@ mod test {
163
166
fn test_vec < T > ( )
164
167
where
165
168
T : ScriptArgument + ScriptReturn ,
166
- T : GetTypeRegistration + FromReflect + Typed ,
169
+ T : GetTypeRegistration + FromReflect + Typed + TypedThrough ,
167
170
for < ' a > T :: This < ' a > : Into < T > ,
168
171
{
169
172
test_is_valid_arg_and_return :: < Vec < T > > ( ) ;
@@ -172,7 +175,7 @@ mod test {
172
175
fn test_hashmap < V > ( )
173
176
where
174
177
V : ScriptArgument + ScriptReturn ,
175
- V : GetTypeRegistration + FromReflect + Typed ,
178
+ V : GetTypeRegistration + FromReflect + Typed + TypedThrough ,
176
179
for < ' a > V :: This < ' a > : Into < V > ,
177
180
{
178
181
test_is_valid_arg_and_return :: < std:: collections:: HashMap < String , V > > ( ) ;
0 commit comments