Restore some functionality that got stripped out of the export tests while last reformatting.

This commit is contained in:
Graydon Hoare 2011-06-30 15:19:47 -07:00
parent 64d6081429
commit 1e63d5303f
5 changed files with 68 additions and 31 deletions

View File

@ -1,11 +1,19 @@
// We can export tags without exporting the variants to create a simple
// sort of ADT.
mod foo {
tag t { t1; }
fn f() -> t { ret t1; }
export t;
export f;
tag t {
t1;
}
fn f() -> t {
ret t1;
}
}
fn main() { let foo::t v = foo::f(); }
fn main() {
let foo::t v = foo::f();
}

View File

@ -1,10 +1,18 @@
mod foo {
mod bar {
fn y() { x(); }
export bar;
mod bar {
fn y() {
x();
}
fn x() { log "x"; }
}
fn x() {
log "x";
}
}
fn main() { foo::bar::y(); }
fn main() {
foo::bar::y();
}

View File

@ -1,11 +1,19 @@
mod foo {
fn x() { bar::x(); }
export x;
fn x() {
bar::x();
}
}
mod bar {
fn x() { log "x"; }
export x;
fn x() {
log "x";
}
}
fn main() { foo::x(); }
fn main() {
foo::x();
}

View File

@ -1,9 +1,12 @@
// Export the tag variants, without the tag
mod foo {
tag t { t1; }
export t1;
tag t {
t1;
}
}
fn main() { auto v = foo::t1; }
fn main() {
auto v = foo::t1;
}

View File

@ -1,14 +1,24 @@
// This tests that exports can have visible dependencies on things
// that are not exported, allowing for a sort of poor-man's ADT
mod foo {
// not exported
tag t { t1; }
fn f() -> t { ret t1; }
fn g(t v) { assert (v == t1); }
mod foo {
export f;
export g;
// not exported
tag t {
t1;
}
fn f() -> t {
ret t1;
}
fn g(t v) {
assert v == t1;
}
}
fn main() { foo::g(foo::f()); }
fn main() {
foo::g(foo::f());
}