v2 / vlib / v / tests / module_test.v
46 lines · 42 sloc · 896 bytes · 1363cc85fd6ca1945446d8e7eed499db25b1ce7f
Raw
1import os
2import crypto.sha256
3import term { white }
4import crypto.md5 { sum }
5import log as l
6import time as t { Time, utc }
7import math
8import crypto.sha512
9import cli { Command }
10
11struct TestAliasInStruct {
12 time Time
13}
14
15fn test_import() {
16 info := l.Level.info
17 assert info == .info
18 assert white('INFO') == white('INFO')
19 assert os.o_rdonly == os.o_rdonly
20 assert t.month_days[0] == t.month_days[0]
21 assert sha256.size == sha256.size
22 assert math.pi == math.pi
23 assert sha512.size == sha512.size
24 assert sum('module'.bytes()).hex() == sum('module'.bytes()).hex()
25 assert utc().unix() == utc().unix()
26}
27
28fn test_imports_array_as_fn_arg() {
29 mut cmd := Command{
30 name: 'module test'
31 }
32 c1 := Command{}
33 c2 := Command{
34 name: 'cmd2'
35 }
36 cmd.add_commands([c1, c2])
37}
38
39fn test_alias_in_struct_field() {
40 a := TestAliasInStruct{
41 time: Time{
42 year: 2020
43 }
44 }
45 assert a.time.year == 2020
46}
47