1from ./m1 {.all.} as r1 import foo1
2from ./m1 {.all.} as r2 import foo7
3
4block: # different symbol kinds
5  doAssert foo1 == 2
6  doAssert r1.foo1 == 2
7  doAssert r1.foo2 == 2
8  doAssert compiles(foo1)
9  doAssert compiles(r1.foo2)
10  doAssert not compiles(foo2)
11  doAssert not compiles(m3h2)
12  doAssert r1.foo3 == 2
13
14  block: # enum
15    var a: r1.Foo4
16    let a1 = r1.kg1
17    doAssert a1 == r1.Foo4.kg1
18    type A = r1.Foo4
19    doAssert a1 == A.kg1
20    doAssert not compiles(kg1)
21    doAssert compiles(A.kg1)
22    var witness = false
23    for ai in r1.Foo4:
24      doAssert ai == a
25      doAssert ai == a1
26      witness = true
27      break
28    doAssert witness
29
30  block: # {.pure.} enum
31    var a: r1.Foo4b
32    doAssert not compiles(r1.foo4b1) # because pure
33    doAssert not compiles(foo4b1)
34    let a1 = r1.Foo4b.foo4b1
35    doAssert a1 == a
36    type A = r1.Foo4b
37    doAssert a1 == A.foo4b1
38    var witness = false
39    for ai in A:
40      doAssert ai == a
41      doAssert ai == a1
42      witness = true
43      break
44    doAssert witness
45
46  block: # object
47    doAssert compiles(r1.Foo5)
48    var a: r1.Foo5
49    doAssert compiles(a.z4)
50    doAssert not compiles(a.z3)
51
52  block: # remaining symbol kinds
53    doAssert r1.foo6() == 2
54    doAssert r1.foo6b() == 2
55    doAssert foo7() == 2
56    doAssert r2.foo6b() == 2
57
58    r1.foo8()
59    r1.foo9(1)
60    doAssert r1.foo13() == 2
61    for a in r1.foo14a(): discard
62    for a in r1.foo14b(): discard
63    for a in r1.foo14c(): discard
64    for a in r1.foo14d(): discard
65    doAssert r1.foo15() == 2
66    doAssert r1.foo16() == 2
67    doAssert r1.foo17() == 2
68    doAssert compiles(r1.foo18)
69    doAssert declared(r1.foo18)
70
71  block: # declarations at block scope should not be visible
72    doAssert declared(foo7)
73    doAssert declared(r1.foo6)
74    doAssert not declared(foo10)
75    doAssert not declared(foo6)
76    doAssert not declared(r1.Foo11)
77    doAssert not declared(r1.kg1b)
78    doAssert not declared(r1.foo12)
79    doAssert not compiles(r1.foo12())
80
81## field access
82import std/importutils
83privateAccess(r1.Foo5)
84var x = r1.Foo5(z1: "foo", z2: r1.kg1)
85doAssert x.z1 == "foo"
86
87var f0: r1.Foo5
88f0.z3 = 3
89doAssert f0.z3 == 3
90var f = r1.initFoo5(z3=3)
91doAssert f.z3 == 3
92doAssert r1.z3(f) == 30
93
94import ./m1 as r3
95doAssert not declared(foo2)
96doAssert not declared(r3.foo2)
97
98from ./m1 {.all.} as r4 import nil
99doAssert not declared(foo2)
100doAssert declared(r4.foo2)
101
102from ./m1 {.all.} import nil
103doAssert not declared(foo2)
104doAssert declared(m1.foo2)
105