1
Fork 0

test: "tag" -> "enum" in run-pass and run-fail

This commit is contained in:
Patrick Walton 2012-01-19 16:10:31 -08:00
parent 1461cfe416
commit 3333fef1af
76 changed files with 84 additions and 84 deletions

View file

@ -4,6 +4,6 @@
// -*- rust -*- // -*- rust -*-
// error-pattern:non-exhaustive match failure // error-pattern:non-exhaustive match failure
tag t { a; b; } enum t { a; b; }
fn main() { let x = a; alt x { b { } } } fn main() { let x = a; alt x { b { } } }

View file

@ -5,7 +5,7 @@ use std;
import option; import option;
import option::none; import option::none;
tag sty { ty_nil; } enum sty { ty_nil; }
type raw_t = {struct: sty, cname: option::t<str>, hash: uint}; type raw_t = {struct: sty, cname: option::t<str>, hash: uint};

View file

@ -1,4 +1,4 @@
tag option<T> { some(T); none; } enum option<T> { some(T); none; }
type r<T> = {mutable v: [option<T>]}; type r<T> = {mutable v: [option<T>]};

View file

@ -1,7 +1,7 @@
mod m1 { mod m1 {
tag foo { foo1; foo2; } enum foo { foo1; foo2; }
} }
fn bar(x: m1::foo) { alt x { m1::foo1 { } } } fn bar(x: m1::foo) { alt x { m1::foo1 { } } }

View file

@ -5,7 +5,7 @@ use std;
import std::dbg; import std::dbg;
tag t { make_t(@int); clam; } enum t { make_t(@int); clam; }
fn foo(s: @int) { fn foo(s: @int) {
let count = dbg::refcount(s); let count = dbg::refcount(s);

View file

@ -1,4 +1,4 @@
tag maybe<T> { nothing; just(T); } enum maybe<T> { nothing; just(T); }
fn foo(x: maybe<int>) { fn foo(x: maybe<int>) {
alt x { nothing { #error("A"); } just(a) { #error("B"); } } alt x { nothing { #error("A"); } just(a) { #error("B"); } }

View file

@ -1,6 +1,6 @@
tag thing { a; b; c; } enum thing { a; b; c; }
fn foo(it: block(int)) { it(10); } fn foo(it: block(int)) { it(10); }

View file

@ -3,7 +3,7 @@
fn main() { fn main() {
alt "test" { "not-test" { fail; } "test" { } _ { fail; } } alt "test" { "not-test" { fail; } "test" { } _ { fail; } }
tag t { tag1(str); tag2; } enum t { tag1(str); tag2; }
alt tag1("test") { alt tag1("test") {

View file

@ -2,7 +2,7 @@
// -*- rust -*- // -*- rust -*-
tag color { enum color {
rgb(int, int, int); rgb(int, int, int);
rgba(int, int, int, int); rgba(int, int, int, int);
hsl(int, int, int); hsl(int, int, int);

View file

@ -1,5 +1,5 @@
type foo = {a: int, b: uint}; type foo = {a: int, b: uint};
tag bar { u(@foo); w(int); } enum bar { u(@foo); w(int); }
fn main() { fn main() {
assert (alt u(@{a: 10, b: 40u}) { assert (alt u(@{a: 10, b: 40u}) {

View file

@ -8,7 +8,7 @@ import comm;
import comm::port; import comm::port;
import comm::recv; import comm::recv;
tag request { quit; close(chan<bool>); } enum request { quit; close(chan<bool>); }
type ctx = chan<request>; type ctx = chan<request>;

View file

@ -20,9 +20,9 @@ type t = int;
type t = bool; type t = bool;
#[cfg(bogus)] #[cfg(bogus)]
tag tg { foo; } enum tg { foo; }
tag tg { bar; } enum tg { bar; }
#[cfg(bogus)] #[cfg(bogus)]
resource r(i: int) { } resource r(i: int) { }

View file

@ -1,6 +1,6 @@
// -*- rust -*- // -*- rust -*-
tag list { cons(int, @list); nil; } enum list { cons(int, @list); nil; }
type bubu = {x: int, y: int}; type bubu = {x: int, y: int};

View file

@ -1,4 +1,4 @@
tag taggy { enum taggy {
cons(@mutable taggy); cons(@mutable taggy);
nil; nil;
} }

View file

@ -1,5 +1,5 @@
tag t { foo(@int); } enum t { foo(@int); }
fn main() { let tt = foo(@10); alt tt { foo(z) { } } } fn main() { let tt = foo(@10); alt tt { foo(z) { } } }

View file

@ -1,4 +1,4 @@
tag chan { chan_t; } enum chan { chan_t; }
fn wrapper3(i: chan) { fn wrapper3(i: chan) {
assert i == chan_t; assert i == chan_t;

View file

@ -5,7 +5,7 @@ mod foo {
export t; export t;
export f; export f;
tag t { t1; } enum t { t1; }
fn f() -> t { ret t1; } fn f() -> t { ret t1; }
} }

View file

@ -2,6 +2,6 @@
export foo; export foo;
export main; export main;
tag list_cell<T> { cons(@list_cell<T>); } enum list_cell<T> { cons(@list_cell<T>); }
fn main() { } fn main() { }

View file

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

View file

@ -6,7 +6,7 @@ mod foo {
export g; export g;
// not exported // not exported
tag t { t1; t2; } enum t { t1; t2; }
fn f() -> t { ret t1; } fn f() -> t { ret t1; }

View file

@ -10,7 +10,7 @@ fn test_rec() {
} }
fn test_tag() { fn test_tag() {
tag mood { happy; sad; } enum mood { happy; sad; }
let rs = alt true { true { happy } false { sad } }; let rs = alt true { true { happy } false { sad } };
assert (rs == happy); assert (rs == happy);
} }

View file

@ -10,7 +10,7 @@ fn test_rec() {
} }
fn test_tag() { fn test_tag() {
tag mood { happy; sad; } enum mood { happy; sad; }
let rs = if true { happy } else { sad }; let rs = if true { happy } else { sad };
assert (rs == happy); assert (rs == happy);
} }

View file

@ -1,4 +1,4 @@
tag wrapper<T> { wrapped(T); } enum wrapper<T> { wrapped(T); }
fn main() { let w = wrapped([1, 2, 3, 4, 5]); } fn main() { let w = wrapped([1, 2, 3, 4, 5]); }

View file

@ -1,6 +1,6 @@
tag list<T> { cons(@T, @list<T>); nil; } enum list<T> { cons(@T, @list<T>); nil; }
fn main() { fn main() {
let a: list<int> = let a: list<int> =

View file

@ -1,6 +1,6 @@
tag foo<T> { arm(T); } enum foo<T> { arm(T); }
fn altfoo<T>(f: foo<T>) { fn altfoo<T>(f: foo<T>) {
let hit = false; let hit = false;

View file

@ -2,6 +2,6 @@
// This causes memory corruption in stage0. // This causes memory corruption in stage0.
tag thing<K> { some(K); } enum thing<K> { some(K); }
fn main() { let x = some("hi"); } fn main() { let x = some("hi"); }

View file

@ -1,5 +1,5 @@
tag clam<T> { a(T); } enum clam<T> { a(T); }
fn main() { let c = a(3); } fn main() { let c = a(3); }

View file

@ -2,7 +2,7 @@
// -*- rust -*- // -*- rust -*-
tag noption<T> { some(T); } enum noption<T> { some(T); }
fn main() { fn main() {
let nop: noption<int> = some::<int>(5); let nop: noption<int> = some::<int>(5);

View file

@ -1,5 +1,5 @@
tag option<T> { some(@T); none; } enum option<T> { some(@T); none; }
fn main() { let a: option<int> = some::<int>(@10); a = none::<int>; } fn main() { let a: option<int> = some::<int>(@10); a = none::<int>; }

View file

@ -30,7 +30,7 @@ mod map_reduce {
type mapper = native fn(str, putter); type mapper = native fn(str, putter);
tag ctrl_proto { find_reducer([u8], chan<int>); mapper_done; } enum ctrl_proto { find_reducer([u8], chan<int>); mapper_done; }
fn start_mappers(ctrl: chan<ctrl_proto>, inputs: [str]) { fn start_mappers(ctrl: chan<ctrl_proto>, inputs: [str]) {
for i: str in inputs { for i: str in inputs {

View file

@ -1,6 +1,6 @@
// Test cyclic detector when using iface instances. // Test cyclic detector when using iface instances.
tag Tree = TreeR; enum Tree = TreeR;
type TreeR = @{ type TreeR = @{
mutable left: option<Tree>, mutable left: option<Tree>,
mutable right: option<Tree>, mutable right: option<Tree>,

View file

@ -22,7 +22,7 @@ fn test_rec() {
} }
fn test_tag() { fn test_tag() {
tag t { enum t {
t0(r); t0(r);
} }
@ -62,7 +62,7 @@ fn test_box_rec() {
fn main() { fn main() {
test_box(); test_box();
test_rec(); test_rec();
// FIXME: tag constructors don't optimize their arguments into moves // FIXME: enum constructors don't optimize their arguments into moves
// test_tag(); // test_tag();
test_tup(); test_tup();
test_unique(); test_unique();

View file

@ -7,7 +7,7 @@ import comm::port;
import comm::recv; import comm::recv;
import comm::send; import comm::send;
tag msg { closed; received([u8]); } enum msg { closed; received([u8]); }
fn producer(c: chan<[u8]>) { fn producer(c: chan<[u8]>) {
send(c, [1u8, 2u8, 3u8, 4u8]); send(c, [1u8, 2u8, 3u8, 4u8]);

View file

@ -1,4 +1,4 @@
tag maybe_ordered_pair { enum maybe_ordered_pair {
yes({low: int, high: int} : less_than(*.low, *.high)); yes({low: int, high: int} : less_than(*.low, *.high));
no; no;
} }

View file

@ -1,4 +1,4 @@
tag maybe_pointy { enum maybe_pointy {
no_pointy; no_pointy;
yes_pointy(@pointy); yes_pointy(@pointy);
} }

View file

@ -1,5 +1,5 @@
tag t { a; b(@int); } enum t { a; b(@int); }
fn main() { let x = b(@10); x = a; } fn main() { let x = b(@10); x = a; }

View file

@ -1,4 +1,4 @@
tag xx = int; enum xx = int;
fn main() { fn main() {
let @{x: xx(x), y: y} = @{x: xx(10), y: 20}; let @{x: xx(x), y: y} = @{x: xx(10), y: 20};

View file

@ -2,6 +2,6 @@
// -*- rust -*- // -*- rust -*-
tag list { cons(int, @list); nil; } enum list { cons(int, @list); nil; }
fn main() { cons(10, @cons(11, @cons(12, @nil))); } fn main() { cons(10, @cons(11, @cons(12, @nil))); }

View file

@ -1,7 +1,7 @@
use std; use std;
import std::list; import std::list;
tag foo { enum foo {
a(uint); a(uint);
b(str); b(str);
} }

View file

@ -1,4 +1,4 @@
tag foo { enum foo {
a(uint); a(uint);
b(str); b(str);
c; c;

View file

@ -1,6 +1,6 @@
// Tests that shapes respect linearize_ty_params(). // Tests that shapes respect linearize_ty_params().
tag option<T> { enum option<T> {
none; none;
some(T); some(T);
} }

View file

@ -4,7 +4,7 @@ use std;
type cell = {mutable c: @list}; type cell = {mutable c: @list};
tag list { link(@cell); nil; } enum list { link(@cell); nil; }
fn main() { fn main() {
let first: @cell = @{mutable c: @nil()}; let first: @cell = @{mutable c: @nil()};

View file

@ -1,4 +1,4 @@
// -*- rust -*- // -*- rust -*-
tag mlist { cons(int, @mlist); nil; } enum mlist { cons(int, @mlist); nil; }
fn main() { cons(10, @cons(11, @cons(12, @nil))); } fn main() { cons(10, @cons(11, @cons(12, @nil))); }

View file

@ -2,12 +2,12 @@
// -*- rust -*- // -*- rust -*-
tag colour { red; green; blue; } enum colour { red; green; blue; }
tag tree { children(@list); leaf(colour); } enum tree { children(@list); leaf(colour); }
tag list { cons(@tree, @list); nil; } enum list { cons(@tree, @list); nil; }
tag small_list { kons(int, @small_list); neel; } enum small_list { kons(int, @small_list); neel; }
fn main() { } fn main() { }

View file

@ -6,7 +6,7 @@ import option;
import option::some; import option::some;
import option::none; import option::none;
tag t { foo(int, uint); bar(int, option::t<int>); } enum t { foo(int, uint); bar(int, option::t<int>); }
fn nested(o: t) { fn nested(o: t) {
alt o { alt o {

View file

@ -1,4 +1,4 @@
tag myvec<X> = [X]; enum myvec<X> = [X];
fn myvec_deref<X: copy>(mv: myvec<X>) -> [X] { ret *mv; } fn myvec_deref<X: copy>(mv: myvec<X>) -> [X] { ret *mv; }

View file

@ -1,4 +1,4 @@
tag mytype = {compute: native fn(mytype) -> int, val: int}; enum mytype = {compute: native fn(mytype) -> int, val: int};
fn compute(i: mytype) -> int { ret i.val + 20; } fn compute(i: mytype) -> int { ret i.val + 20; }

View file

@ -13,7 +13,7 @@ pure fn nonempty_list<T: copy>(ls: list<T>) -> bool { pure_length(ls) > 0u }
// Of course, the compiler can't take advantage of the // Of course, the compiler can't take advantage of the
// knowledge that ls is a cons node. Future work. // knowledge that ls is a cons node. Future work.
// Also, this is pretty contrived since nonempty_list // Also, this is pretty contrived since nonempty_list
// could be a "tag refinement", if we implement those. // could be a "enum refinement", if we implement those.
fn safe_head<T: copy>(ls: list<T>) : nonempty_list(ls) -> T { fn safe_head<T: copy>(ls: list<T>) : nonempty_list(ls) -> T {
check is_not_empty(ls); check is_not_empty(ls);
ret head(ls); ret head(ls);

View file

@ -1,4 +1,4 @@
tag blah { a; b; } enum blah { a; b; }
fn or_alt(q: blah) -> int { fn or_alt(q: blah) -> int {
alt q { a | b { 42 } } alt q { a | b { 42 } }

View file

@ -1,4 +1,4 @@
tag blah { a(int, int, uint); b(int, int); c; } enum blah { a(int, int, uint); b(int, int); c; }
fn or_alt(q: blah) -> int { fn or_alt(q: blah) -> int {
alt q { a(x, y, _) | b(x, y) { ret x + y; } c { ret 0; } } alt q { a(x, y, _) | b(x, y) { ret x + y; } c { ret 0; } }

View file

@ -1,6 +1,6 @@
tag t1 { a(int); b(uint); } enum t1 { a(int); b(uint); }
type t2 = {x: t1, y: int}; type t2 = {x: t1, y: int};
tag t3 { c(t2, uint); } enum t3 { c(t2, uint); }
fn m(in: t3) -> int { fn m(in: t3) -> int {
alt in { alt in {

View file

@ -5,7 +5,7 @@ type closable = @mutable bool;
resource close_res(i: closable) { *i = false; } resource close_res(i: closable) { *i = false; }
tag option<T> { none; some(T); } enum option<T> { none; some(T); }
fn sink(res: option<close_res>) { } fn sink(res: option<close_res>) { }

View file

@ -1,6 +1,6 @@
tag option<T> { none; some(T); } enum option<T> { none; some(T); }
fn f<T: copy>() -> option<T> { ret none; } fn f<T: copy>() -> option<T> { ret none; }

View file

@ -16,6 +16,6 @@ fn foo(c: [int]) {
} }
} }
tag t<T> { none; some(T); } enum t<T> { none; some(T); }
fn main() { let x = 10; let x = x + 20; assert (x == 30); foo([]); } fn main() { let x = 10; let x = x + 20; assert (x == 30); foo([]); }

View file

@ -1,5 +1,5 @@
// Exercises a bug in the shape code that was exposed // Exercises a bug in the shape code that was exposed
// on x86_64: when there is a tag embedded in an // on x86_64: when there is a enum embedded in an
// interior record which is then itself interior to // interior record which is then itself interior to
// something else, shape calculations were off. // something else, shape calculations were off.
use std; use std;
@ -7,7 +7,7 @@ import std::list;
import std::list::list; import std::list::list;
import option; import option;
tag opt_span { enum opt_span {
//hack (as opposed to option::t), to make `span` compile //hack (as opposed to option::t), to make `span` compile
os_none; os_none;

View file

@ -1,6 +1,6 @@
tag opt<T> { none; } enum opt<T> { none; }
fn main() { fn main() {
let x = none::<int>; let x = none::<int>;

View file

@ -1,5 +1,5 @@
tag clam<T> { a(T); } enum clam<T> { a(T); }
fn main() { let c = a(2); alt c { a::<int>(_) { } } } fn main() { let c = a(2); alt c { a::<int>(_) { } } }

View file

@ -1,5 +1,5 @@
tag clam<T> { a(T); } enum clam<T> { a(T); }
fn main() { } fn main() { }

View file

@ -2,7 +2,7 @@
// -*- rust -*- // -*- rust -*-
tag clam<T> { a(T, int); b; } enum clam<T> { a(T, int); b; }
fn uhoh<T>(v: [clam<T>]) { fn uhoh<T>(v: [clam<T>]) {
alt v[1] { alt v[1] {

View file

@ -1,5 +1,5 @@
tag taggy { foo(@taggy); bar; } enum taggy { foo(@taggy); bar; }
fn main() { assert (bar <= bar); } fn main() { assert (bar <= bar); }

View file

@ -1,6 +1,6 @@
tag foo { large; small; } enum foo { large; small; }
fn main() { fn main() {
let a = {x: 1, y: 2, z: 3}; let a = {x: 1, y: 2, z: 3};

View file

@ -1,6 +1,6 @@
// xfail-pretty Issue #1510 // xfail-pretty Issue #1510
tag color { enum color {
red = 0xff0000; red = 0xff0000;
green = 0x00ff00; green = 0x00ff00;
blue = 0x0000ff; blue = 0x0000ff;

View file

@ -2,7 +2,7 @@
fn foo() { fn foo() {
fn zed(z: bar) { } fn zed(z: bar) { }
tag bar { nil; } enum bar { nil; }
fn baz() { zed(nil); } fn baz() { zed(nil); }
} }

View file

@ -1,4 +1,4 @@
tag color { enum color {
red = 0xff0000; red = 0xff0000;
green = 0x00ff00; green = 0x00ff00;
blue = 0x0000ff; blue = 0x0000ff;

View file

@ -2,7 +2,7 @@
// -*- rust -*- // -*- rust -*-
tag colour { red(int, int); green; } enum colour { red(int, int); green; }
fn f() { let x = red(1, 2); let y = green; assert (x != y); } fn f() { let x = red(1, 2); let y = green; assert (x != y); }

View file

@ -50,7 +50,7 @@ fn test_str() {
} }
fn test_tag() { fn test_tag() {
tag t { tag1; tag2(int); tag3(int, u8, char); } enum t { tag1; tag2(int); tag3(int, u8, char); }
let po = port(); let po = port();
let ch = chan(po); let ch = chan(po);
send(ch, tag1); send(ch, tag1);

View file

@ -26,7 +26,7 @@ pure fn nonempty_list<T: copy>(ls: list<T>) -> bool { pure_length(ls) > 0u }
// Of course, the compiler can't take advantage of the // Of course, the compiler can't take advantage of the
// knowledge that ls is a cons node. Future work. // knowledge that ls is a cons node. Future work.
// Also, this is pretty contrived since nonempty_list // Also, this is pretty contrived since nonempty_list
// could be a "tag refinement", if we implement those. // could be a "enum refinement", if we implement those.
fn safe_head<T: copy>(ls: list<T>) : nonempty_list(ls) -> T { fn safe_head<T: copy>(ls: list<T>) : nonempty_list(ls) -> T {
check is_not_empty(ls); check is_not_empty(ls);
ret head(ls) ret head(ls)

View file

@ -1,4 +1,4 @@
tag maybe_pointy { enum maybe_pointy {
none; none;
p(@pointy); p(@pointy);
} }

View file

@ -1,4 +1,4 @@
tag maybe_pointy { enum maybe_pointy {
none; none;
p(@pointy); p(@pointy);
} }

View file

@ -1,5 +1,5 @@
fn main() { fn main() {
tag t { t1(int); t2(int); } enum t { t1(int); t2(int); }
let x = ~t1(10); let x = ~t1(10);

View file

@ -1,5 +1,5 @@
fn test1() { fn test1() {
tag bar { u(~int); w(int); } enum bar { u(~int); w(int); }
let x = u(~10); let x = u(~10);
assert alt x { assert alt x {

View file

@ -1,6 +1,6 @@
type foo = {a: int, b: uint}; type foo = {a: int, b: uint};
tag bar { u(~foo); w(int); } enum bar { u(~foo); w(int); }
fn main() { fn main() {
assert (alt u(~{a: 10, b: 40u}) { assert (alt u(~{a: 10, b: 40u}) {

View file

@ -1,5 +1,5 @@
tag bar { u(~int); w(int); } enum bar { u(~int); w(int); }
fn main() { fn main() {
assert alt u(~10) { assert alt u(~10) {

View file

@ -6,6 +6,6 @@ fn foo<T>(o: myoption<T>) -> int {
ret x; ret x;
} }
tag myoption<T> { none; some(T); } enum myoption<T> { none; some(T); }
fn main() { log(debug, 5); } fn main() { log(debug, 5); }

View file

@ -6,6 +6,6 @@ fn foo<T>(o: myoption<T>) -> int {
ret x; ret x;
} }
tag myoption<T> { none; some(T); } enum myoption<T> { none; some(T); }
fn main() { log(debug, 5); } fn main() { log(debug, 5); }

View file

@ -1,5 +1,5 @@
tag t { a; b(str); } enum t { a; b(str); }
fn make(i: int) -> t { fn make(i: int) -> t {
if i > 10 { ret a; } if i > 10 { ret a; }