Skip to content

Commit 1e63d53

Browse files
committed
Restore some functionality that got stripped out of the export tests while last reformatting.
1 parent 64d6081 commit 1e63d53

File tree

5 files changed

+66
-29
lines changed

5 files changed

+66
-29
lines changed
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
2-
3-
41
// We can export tags without exporting the variants to create a simple
52
// sort of ADT.
3+
64
mod foo {
7-
tag t { t1; }
8-
fn f() -> t { ret t1; }
5+
export t;
6+
export f;
7+
8+
tag t {
9+
t1;
10+
}
11+
12+
fn f() -> t {
13+
ret t1;
14+
}
915
}
1016

11-
fn main() { let foo::t v = foo::f(); }
17+
fn main() {
18+
let foo::t v = foo::f();
19+
}
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
mod foo {
12

3+
export bar;
24

3-
mod foo {
4-
mod bar {
5-
fn y() { x(); }
5+
mod bar {
6+
fn y() {
7+
x();
68
}
7-
fn x() { log "x"; }
9+
}
10+
11+
fn x() {
12+
log "x";
13+
}
814
}
915

10-
fn main() { foo::bar::y(); }
16+
fn main() {
17+
foo::bar::y();
18+
}
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
2-
31
mod foo {
4-
fn x() { bar::x(); }
2+
export x;
3+
4+
fn x() {
5+
bar::x();
6+
}
57
}
68

79
mod bar {
8-
fn x() { log "x"; }
10+
export x;
11+
12+
fn x() {
13+
log "x";
14+
}
915
}
1016

11-
fn main() { foo::x(); }
17+
fn main() {
18+
foo::x();
19+
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
2-
3-
41
// Export the tag variants, without the tag
2+
53
mod foo {
6-
tag t { t1; }
4+
export t1;
5+
tag t {
6+
t1;
7+
}
78
}
89

9-
fn main() { auto v = foo::t1; }
10+
fn main() {
11+
auto v = foo::t1;
12+
}
Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
2-
3-
41
// This tests that exports can have visible dependencies on things
52
// that are not exported, allowing for a sort of poor-man's ADT
3+
64
mod foo {
5+
export f;
6+
export g;
7+
8+
// not exported
9+
tag t {
10+
t1;
11+
}
12+
13+
fn f() -> t {
14+
ret t1;
15+
}
716

8-
// not exported
9-
tag t { t1; }
10-
fn f() -> t { ret t1; }
11-
fn g(t v) { assert (v == t1); }
17+
fn g(t v) {
18+
assert v == t1;
19+
}
1220
}
1321

14-
fn main() { foo::g(foo::f()); }
22+
fn main() {
23+
foo::g(foo::f());
24+
}

0 commit comments

Comments
 (0)