提交 3333fef1 编写于 作者: P Patrick Walton

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

上级 1461cfe4
......@@ -4,6 +4,6 @@
// -*- rust -*-
// error-pattern:non-exhaustive match failure
tag t { a; b; }
enum t { a; b; }
fn main() { let x = a; alt x { b { } } }
......@@ -5,7 +5,7 @@
import option;
import option::none;
tag sty { ty_nil; }
enum sty { ty_nil; }
type raw_t = {struct: sty, cname: option::t<str>, hash: uint};
......
tag option<T> { some(T); none; }
enum option<T> { some(T); none; }
type r<T> = {mutable v: [option<T>]};
......
mod m1 {
tag foo { foo1; foo2; }
enum foo { foo1; foo2; }
}
fn bar(x: m1::foo) { alt x { m1::foo1 { } } }
......
......@@ -5,7 +5,7 @@
import std::dbg;
tag t { make_t(@int); clam; }
enum t { make_t(@int); clam; }
fn foo(s: @int) {
let count = dbg::refcount(s);
......
tag maybe<T> { nothing; just(T); }
enum maybe<T> { nothing; just(T); }
fn foo(x: maybe<int>) {
alt x { nothing { #error("A"); } just(a) { #error("B"); } }
......
tag thing { a; b; c; }
enum thing { a; b; c; }
fn foo(it: block(int)) { it(10); }
......
......@@ -3,7 +3,7 @@
fn main() {
alt "test" { "not-test" { fail; } "test" { } _ { fail; } }
tag t { tag1(str); tag2; }
enum t { tag1(str); tag2; }
alt tag1("test") {
......
......@@ -2,7 +2,7 @@
// -*- rust -*-
tag color {
enum color {
rgb(int, int, int);
rgba(int, int, int, int);
hsl(int, int, int);
......
type foo = {a: int, b: uint};
tag bar { u(@foo); w(int); }
enum bar { u(@foo); w(int); }
fn main() {
assert (alt u(@{a: 10, b: 40u}) {
......
......@@ -8,7 +8,7 @@
import comm::port;
import comm::recv;
tag request { quit; close(chan<bool>); }
enum request { quit; close(chan<bool>); }
type ctx = chan<request>;
......
......@@ -20,9 +20,9 @@
type t = bool;
#[cfg(bogus)]
tag tg { foo; }
enum tg { foo; }
tag tg { bar; }
enum tg { bar; }
#[cfg(bogus)]
resource r(i: int) { }
......
// -*- rust -*-
tag list { cons(int, @list); nil; }
enum list { cons(int, @list); nil; }
type bubu = {x: int, y: int};
......
tag taggy {
enum taggy {
cons(@mutable taggy);
nil;
}
......
tag t { foo(@int); }
enum t { foo(@int); }
fn main() { let tt = foo(@10); alt tt { foo(z) { } } }
tag chan { chan_t; }
enum chan { chan_t; }
fn wrapper3(i: chan) {
assert i == chan_t;
......
......@@ -5,7 +5,7 @@ mod foo {
export t;
export f;
tag t { t1; }
enum t { t1; }
fn f() -> t { ret t1; }
}
......
......@@ -2,6 +2,6 @@
export foo;
export main;
tag list_cell<T> { cons(@list_cell<T>); }
enum list_cell<T> { cons(@list_cell<T>); }
fn main() { }
// Export the tag variants, without the tag
// Export the enum variants, without the enum
mod foo {
export t1;
tag t { t1; }
enum t { t1; }
}
fn main() { let v = foo::t1; }
......@@ -6,7 +6,7 @@ mod foo {
export g;
// not exported
tag t { t1; t2; }
enum t { t1; t2; }
fn f() -> t { ret t1; }
......
......@@ -10,7 +10,7 @@ fn test_rec() {
}
fn test_tag() {
tag mood { happy; sad; }
enum mood { happy; sad; }
let rs = alt true { true { happy } false { sad } };
assert (rs == happy);
}
......
......@@ -10,7 +10,7 @@ fn test_rec() {
}
fn test_tag() {
tag mood { happy; sad; }
enum mood { happy; sad; }
let rs = if true { happy } else { sad };
assert (rs == happy);
}
......
tag wrapper<T> { wrapped(T); }
enum wrapper<T> { wrapped(T); }
fn main() { let w = wrapped([1, 2, 3, 4, 5]); }
tag list<T> { cons(@T, @list<T>); nil; }
enum list<T> { cons(@T, @list<T>); nil; }
fn main() {
let a: list<int> =
......
tag foo<T> { arm(T); }
enum foo<T> { arm(T); }
fn altfoo<T>(f: foo<T>) {
let hit = false;
......
......@@ -2,6 +2,6 @@
// This causes memory corruption in stage0.
tag thing<K> { some(K); }
enum thing<K> { some(K); }
fn main() { let x = some("hi"); }
tag clam<T> { a(T); }
enum clam<T> { a(T); }
fn main() { let c = a(3); }
......@@ -2,7 +2,7 @@
// -*- rust -*-
tag noption<T> { some(T); }
enum noption<T> { some(T); }
fn main() {
let nop: noption<int> = some::<int>(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>; }
......@@ -30,7 +30,7 @@ mod map_reduce {
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]) {
for i: str in inputs {
......
// Test cyclic detector when using iface instances.
tag Tree = TreeR;
enum Tree = TreeR;
type TreeR = @{
mutable left: option<Tree>,
mutable right: option<Tree>,
......
......@@ -22,7 +22,7 @@ fn test_rec() {
}
fn test_tag() {
tag t {
enum t {
t0(r);
}
......@@ -62,7 +62,7 @@ fn test_box_rec() {
fn main() {
test_box();
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_tup();
test_unique();
......
......@@ -7,7 +7,7 @@
import comm::recv;
import comm::send;
tag msg { closed; received([u8]); }
enum msg { closed; received([u8]); }
fn producer(c: chan<[u8]>) {
send(c, [1u8, 2u8, 3u8, 4u8]);
......
tag maybe_ordered_pair {
enum maybe_ordered_pair {
yes({low: int, high: int} : less_than(*.low, *.high));
no;
}
......
tag maybe_pointy {
enum maybe_pointy {
no_pointy;
yes_pointy(@pointy);
}
......
tag t { a; b(@int); }
enum t { a; b(@int); }
fn main() { let x = b(@10); x = a; }
tag xx = int;
enum xx = int;
fn main() {
let @{x: xx(x), y: y} = @{x: xx(10), y: 20};
......
......@@ -2,6 +2,6 @@
// -*- rust -*-
tag list { cons(int, @list); nil; }
enum list { cons(int, @list); nil; }
fn main() { cons(10, @cons(11, @cons(12, @nil))); }
use std;
import std::list;
tag foo {
enum foo {
a(uint);
b(str);
}
......
// Tests that shapes respect linearize_ty_params().
tag option<T> {
enum option<T> {
none;
some(T);
}
......
......@@ -4,7 +4,7 @@
type cell = {mutable c: @list};
tag list { link(@cell); nil; }
enum list { link(@cell); nil; }
fn main() {
let first: @cell = @{mutable c: @nil()};
......
// -*- rust -*-
tag mlist { cons(int, @mlist); nil; }
enum mlist { cons(int, @mlist); nil; }
fn main() { cons(10, @cons(11, @cons(12, @nil))); }
......@@ -2,12 +2,12 @@
// -*- 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() { }
......@@ -6,7 +6,7 @@
import option::some;
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) {
alt o {
......
tag myvec<X> = [X];
enum myvec<X> = [X];
fn myvec_deref<X: copy>(mv: myvec<X>) -> [X] { ret *mv; }
......
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; }
......
......@@ -13,7 +13,7 @@
// Of course, the compiler can't take advantage of the
// knowledge that ls is a cons node. Future work.
// 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 {
check is_not_empty(ls);
ret head(ls);
......
tag blah { a; b; }
enum blah { a; b; }
fn or_alt(q: blah) -> int {
alt q { a | b { 42 } }
......
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 {
alt q { a(x, y, _) | b(x, y) { ret x + y; } c { ret 0; } }
......
tag t1 { a(int); b(uint); }
enum t1 { a(int); b(uint); }
type t2 = {x: t1, y: int};
tag t3 { c(t2, uint); }
enum t3 { c(t2, uint); }
fn m(in: t3) -> int {
alt in {
......
......@@ -5,7 +5,7 @@
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>) { }
......
tag option<T> { none; some(T); }
enum option<T> { none; some(T); }
fn f<T: copy>() -> option<T> { ret none; }
......
......@@ -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([]); }
// 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
// something else, shape calculations were off.
use std;
......@@ -7,7 +7,7 @@
import std::list::list;
import option;
tag opt_span {
enum opt_span {
//hack (as opposed to option::t), to make `span` compile
os_none;
......
tag opt<T> { none; }
enum opt<T> { none; }
fn main() {
let x = none::<int>;
......
tag clam<T> { a(T); }
enum clam<T> { a(T); }
fn main() { let c = a(2); alt c { a::<int>(_) { } } }
tag clam<T> { a(T); }
enum clam<T> { a(T); }
fn main() { }
......@@ -2,7 +2,7 @@
// -*- rust -*-
tag clam<T> { a(T, int); b; }
enum clam<T> { a(T, int); b; }
fn uhoh<T>(v: [clam<T>]) {
alt v[1] {
......
tag taggy { foo(@taggy); bar; }
enum taggy { foo(@taggy); bar; }
fn main() { assert (bar <= bar); }
tag foo { large; small; }
enum foo { large; small; }
fn main() {
let a = {x: 1, y: 2, z: 3};
......
// xfail-pretty Issue #1510
tag color {
enum color {
red = 0xff0000;
green = 0x00ff00;
blue = 0x0000ff;
......
......@@ -2,7 +2,7 @@
fn foo() {
fn zed(z: bar) { }
tag bar { nil; }
enum bar { nil; }
fn baz() { zed(nil); }
}
......
tag color {
enum color {
red = 0xff0000;
green = 0x00ff00;
blue = 0x0000ff;
......
......@@ -2,7 +2,7 @@
// -*- 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); }
......
......@@ -50,7 +50,7 @@ fn test_str() {
}
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 ch = chan(po);
send(ch, tag1);
......
......@@ -26,7 +26,7 @@ fn count<T>(_t: T, &&u: uint) -> uint { u + 1u }
// Of course, the compiler can't take advantage of the
// knowledge that ls is a cons node. Future work.
// 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 {
check is_not_empty(ls);
ret head(ls)
......
tag maybe_pointy {
enum maybe_pointy {
none;
p(@pointy);
}
......
tag maybe_pointy {
enum maybe_pointy {
none;
p(@pointy);
}
......
fn main() {
tag t { t1(int); t2(int); }
enum t { t1(int); t2(int); }
let x = ~t1(10);
......
fn test1() {
tag bar { u(~int); w(int); }
enum bar { u(~int); w(int); }
let x = u(~10);
assert alt x {
......
type foo = {a: int, b: uint};
tag bar { u(~foo); w(int); }
enum bar { u(~foo); w(int); }
fn main() {
assert (alt u(~{a: 10, b: 40u}) {
......
tag bar { u(~int); w(int); }
enum bar { u(~int); w(int); }
fn main() {
assert alt u(~10) {
......
......@@ -6,6 +6,6 @@ fn foo<T>(o: myoption<T>) -> int {
ret x;
}
tag myoption<T> { none; some(T); }
enum myoption<T> { none; some(T); }
fn main() { log(debug, 5); }
......@@ -6,6 +6,6 @@ fn foo<T>(o: myoption<T>) -> int {
ret x;
}
tag myoption<T> { none; some(T); }
enum myoption<T> { none; some(T); }
fn main() { log(debug, 5); }
tag t { a; b(str); }
enum t { a; b(str); }
fn make(i: int) -> t {
if i > 10 { ret a; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册