v2 / vlib / v / fmt / tests / import_selective_expected.vv
102 lines · 88 sloc · 1.79 KB · c766ce4fe59400aad592ed07daf1d13832bdfd7e
Raw
1import math { max, min }
2import cli { Command }
3import math.complex { Complex, complex }
4import os {
5 file_ext,
6 user_os,
7}
8import mod {
9 AliasTarget,
10 Enum,
11 FnAliasParam,
12 FnAliasRet,
13 FnArg,
14 FnArgGeneric,
15 FnArgTypeParam1,
16 FnArgTypeParam2,
17 FnArgVariadic,
18 FnRet,
19 FnRetGeneric,
20 FnRetTypeParam1,
21 FnRetTypeParam2,
22 InterfaceField,
23 InterfaceMethodArg,
24 InterfaceMethodRet,
25 RightOfAs,
26 RightOfIs,
27 StructArrayFieldElem,
28 StructEmbed,
29 StructField,
30 StructFixedArrayFieldElem,
31 StructMapFieldKey,
32 StructMapFieldValue,
33 StructMethodArg,
34 StructMethodArgGeneric,
35 StructMethodRet,
36 StructMethodRetGeneric,
37 StructRefField,
38 SumVariant1,
39 SumVariant2,
40}
41
42type Alias = AliasTarget
43type SumType = SumVariant1 | SumVariant2
44type Fn = fn (FnAliasParam) FnAliasRet
45
46struct Struct {
47 StructEmbed
48 v StructField
49 ref &StructRefField
50 map map[StructMapFieldKey]StructMapFieldValue
51 arr []StructArrayFieldElem
52 arr_fixed [2]StructFixedArrayFieldElem
53}
54
55fn (s Struct) method(v StructMethodArg) StructMethodRet {
56 return StructMethodRet{}
57}
58
59fn (s Struct) method_generic[T](v StructMethodArgGeneric[T]) StructMethodRetGeneric[T] {
60 return StructMethodRet[T]{}
61}
62
63interface Interface {
64 v InterfaceField
65 f(InterfaceMethodArg) InterfaceMethodRet
66}
67
68fn f(v FnArg, vv ...FnArgVariadic) FnRet {
69 if v is RightOfIs {
70 }
71 _ = v as RightOfAs
72
73 println(Enum.val)
74
75 return FnRet{}
76}
77
78fn f2(v Generic[FnArgTypeParam1, FnArgTypeParam2]) Generic[FnRetTypeParam1, FnRetTypeParam2] {}
79
80fn f_generic[T](v FnArgGeneric[T]) FnRetGeneric[T] {
81 return FnRetGeneric[T]{}
82}
83
84struct App {
85 command &Command
86}
87
88struct MyCommand {
89 Command
90}
91
92fn imaginary(im f64) Complex {
93 return complex(0, im)
94}
95
96fn main() {
97 println(max(0.1, 0.2))
98 println(min(0.1, 0.2))
99 println(user_os())
100 println(file_ext('main.v'))
101 println(imaginary(1))
102}
103