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