mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
86719c5de9
commit
1028f0b59e
@ -24,7 +24,7 @@ pub interface JS.Response {
|
||||
|
||||
pub fn fetch(input string, init map[string]JS.Any) promise.Promise<JS.Response, JS.String> {
|
||||
p_init := JS.Any(voidptr(0))
|
||||
p := promise.Promise<JS.Response,String>{p_init}
|
||||
p := promise.Promise<JS.Response, String>{p_init}
|
||||
|
||||
#let obj = {}; for (let [key,val] of init.map) { obj[key] = val; }
|
||||
#p.promise = fetch(input.str,obj);
|
||||
|
@ -213,7 +213,7 @@ pub fn (mut f Fmt) short_module(name string) string {
|
||||
generic_levels := name.trim_suffix('>').split('<')
|
||||
mut res := '${f.short_module(generic_levels[0])}'
|
||||
for i in 1 .. generic_levels.len {
|
||||
genshorts := generic_levels[i].split(',').map(f.short_module(it)).join(',')
|
||||
genshorts := generic_levels[i].split(', ').map(f.short_module(it)).join(', ')
|
||||
res += '<$genshorts'
|
||||
}
|
||||
res += '>'
|
||||
|
@ -36,7 +36,7 @@ fn main() {
|
||||
println(x.model)
|
||||
println(x.permission)
|
||||
//
|
||||
mut a := Repo<User,Permission>{
|
||||
mut a := Repo<User, Permission>{
|
||||
model: User{
|
||||
name: 'joe'
|
||||
}
|
||||
|
8
vlib/v/fmt/tests/generic_structs_using_mod_keep.vv
Normal file
8
vlib/v/fmt/tests/generic_structs_using_mod_keep.vv
Normal file
@ -0,0 +1,8 @@
|
||||
import v.fmt.tests.obj
|
||||
|
||||
struct GenericStruct<A, B> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
_ := GenericStruct<obj.Test, obj.Test>{}
|
||||
}
|
3
vlib/v/fmt/tests/obj/obj.v
Normal file
3
vlib/v/fmt/tests/obj/obj.v
Normal file
@ -0,0 +1,3 @@
|
||||
module obj
|
||||
|
||||
pub struct Test {}
|
@ -306,13 +306,13 @@ pub mut:
|
||||
// return Repo<T,Permission>{db: db}
|
||||
// }
|
||||
fn test_generic_struct() {
|
||||
mut a := Repo<User,Permission>{
|
||||
mut a := Repo<User, Permission>{
|
||||
model: User{
|
||||
name: 'joe'
|
||||
}
|
||||
}
|
||||
assert a.model.name == 'joe'
|
||||
mut b := Repo<Group,Permission>{
|
||||
mut b := Repo<Group, Permission>{
|
||||
permission: Permission{
|
||||
name: 'superuser'
|
||||
}
|
||||
@ -573,8 +573,8 @@ fn test_generic_detection() {
|
||||
})
|
||||
|
||||
// this final case challenges your scanner :-)
|
||||
assert boring_function<TandU<TandU<int, MultiLevel<Empty_>>, map[string][]int>>(TandU<TandU<int,MultiLevel<Empty_>>, map[string][]int>{
|
||||
t: TandU<int,MultiLevel<Empty_>>{
|
||||
assert boring_function<TandU<TandU<int, MultiLevel<Empty_>>, map[string][]int>>(TandU<TandU<int, MultiLevel<Empty_>>, map[string][]int>{
|
||||
t: TandU<int, MultiLevel<Empty_>>{
|
||||
t: 20
|
||||
u: MultiLevel<Empty_>{
|
||||
foo: Empty_{}
|
||||
|
@ -321,7 +321,7 @@ struct MultiGenericStruct<T, X> {
|
||||
}
|
||||
|
||||
fn test_multi_generic_struct() {
|
||||
x := MultiGenericStruct<TestStruct,TestStruct>{}
|
||||
x := MultiGenericStruct<TestStruct, TestStruct>{}
|
||||
assert '$x' == 'MultiGenericStruct<TestStruct, TestStruct>{\n t: TestStruct{\n x: 0\n }\n x: TestStruct{\n x: 0\n }\n}'
|
||||
assert x.str() == 'MultiGenericStruct<TestStruct, TestStruct>{\n t: TestStruct{\n x: 0\n }\n x: TestStruct{\n x: 0\n }\n}'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user