Remove variable name 'res' from test suite
This commit is contained in:
parent
c772269f08
commit
781a265b88
19 changed files with 153 additions and 153 deletions
|
@ -171,8 +171,8 @@ fn find_pre_post_state_call(&fn_ctxt fcx, &prestate pres, &@expr a,
|
||||||
|
|
||||||
fn find_pre_post_state_exprs(&fn_ctxt fcx, &prestate pres, ast::node_id id,
|
fn find_pre_post_state_exprs(&fn_ctxt fcx, &prestate pres, ast::node_id id,
|
||||||
&vec[@expr] es, controlflow cf) -> bool {
|
&vec[@expr] es, controlflow cf) -> bool {
|
||||||
auto res = seq_states(fcx, pres, es);
|
auto rs = seq_states(fcx, pres, es);
|
||||||
auto changed = res._0;
|
auto changed = rs._0;
|
||||||
changed = set_prestate_ann(fcx.ccx, id, pres) || changed;
|
changed = set_prestate_ann(fcx.ccx, id, pres) || changed;
|
||||||
/* if this is a failing call, it sets everything as initialized */
|
/* if this is a failing call, it sets everything as initialized */
|
||||||
alt (cf) {
|
alt (cf) {
|
||||||
|
@ -183,7 +183,7 @@ fn find_pre_post_state_exprs(&fn_ctxt fcx, &prestate pres, ast::node_id id,
|
||||||
changed;
|
changed;
|
||||||
}
|
}
|
||||||
case (_) {
|
case (_) {
|
||||||
changed = set_poststate_ann(fcx.ccx, id, res._1) || changed;
|
changed = set_poststate_ann(fcx.ccx, id, rs._1) || changed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret changed;
|
ret changed;
|
||||||
|
|
|
@ -241,15 +241,15 @@ fn to_vec(&t v) -> vec[uint] {
|
||||||
|
|
||||||
fn to_str(&t v) -> str {
|
fn to_str(&t v) -> str {
|
||||||
let uint i = 0u;
|
let uint i = 0u;
|
||||||
let str res = "";
|
let str rs = "";
|
||||||
while (i < v.nbits) {
|
while (i < v.nbits) {
|
||||||
res += alt (tritv_get(v, i)) {
|
rs += alt (tritv_get(v, i)) {
|
||||||
case (dont_care) { "?" }
|
case (dont_care) { "?" }
|
||||||
case (ttrue) { "1" }
|
case (ttrue) { "1" }
|
||||||
case (tfalse) { "0" } };
|
case (tfalse) { "0" } };
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
ret res;
|
ret rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
auto pth = break;
|
auto pth = break;
|
||||||
|
|
||||||
let rec(str t) res = rec(t=pth);
|
let rec(str t) rs = rec(t=pth);
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,4 +5,4 @@
|
||||||
// as a _|_-typed thing, not a str-typed thing
|
// as a _|_-typed thing, not a str-typed thing
|
||||||
// xfail-stage0
|
// xfail-stage0
|
||||||
// error-pattern:bye
|
// error-pattern:bye
|
||||||
fn main() { auto pth = fail"bye"; let rec(str t) res = rec(t=pth); }
|
fn main() { auto pth = fail"bye"; let rec(str t) rs = rec(t=pth); }
|
|
@ -7,14 +7,14 @@ import std::option::some;
|
||||||
|
|
||||||
fn foo[T](&option::t[T] y) {
|
fn foo[T](&option::t[T] y) {
|
||||||
let int x;
|
let int x;
|
||||||
let vec[int] res = [];
|
let vec[int] rs = [];
|
||||||
/* tests that x doesn't get put in the precondition for the
|
/* tests that x doesn't get put in the precondition for the
|
||||||
entire if expression */
|
entire if expression */
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
} else {
|
} else {
|
||||||
alt (y) { case (none[T]) { x = 17; } case (_) { x = 42; } }
|
alt (y) { case (none[T]) { x = 17; } case (_) { x = 42; } }
|
||||||
res += [x];
|
rs += [x];
|
||||||
}
|
}
|
||||||
ret;
|
ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
// Tests for alt as expressions resulting in boxed types
|
// Tests for alt as expressions resulting in boxed types
|
||||||
fn test_box() {
|
fn test_box() {
|
||||||
auto res = alt (true) { case (true) { @100 } };
|
auto rs = alt (true) { case (true) { @100 } };
|
||||||
assert (*res == 100);
|
assert (*rs == 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_str() {
|
fn test_str() {
|
||||||
auto res = alt (true) { case (true) { "happy" } };
|
auto rs = alt (true) { case (true) { "happy" } };
|
||||||
assert (res == "happy");
|
assert (rs == "happy");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { test_box(); test_str(); }
|
fn main() { test_box(); test_str(); }
|
|
@ -5,14 +5,14 @@
|
||||||
|
|
||||||
// Tests for alt as expressions resulting in structural types
|
// Tests for alt as expressions resulting in structural types
|
||||||
fn test_rec() {
|
fn test_rec() {
|
||||||
auto res = alt (true) { case (true) { rec(i=100) } };
|
auto rs = alt (true) { case (true) { rec(i=100) } };
|
||||||
assert (res == rec(i=100));
|
assert (rs == rec(i=100));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_tag() {
|
fn test_tag() {
|
||||||
tag mood { happy; sad; }
|
tag mood { happy; sad; }
|
||||||
auto res = alt (true) { case (true) { happy } case (false) { sad } };
|
auto rs = alt (true) { case (true) { happy } case (false) { sad } };
|
||||||
assert (res == happy);
|
assert (rs == happy);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { test_rec(); test_tag(); }
|
fn main() { test_rec(); test_tag(); }
|
|
@ -5,37 +5,37 @@
|
||||||
|
|
||||||
// Tests for using alt as an expression
|
// Tests for using alt as an expression
|
||||||
fn test_basic() {
|
fn test_basic() {
|
||||||
let bool res = alt (true) { case (true) { true } case (false) { false } };
|
let bool rs = alt (true) { case (true) { true } case (false) { false } };
|
||||||
assert (res);
|
assert (rs);
|
||||||
res = alt (false) { case (true) { false } case (false) { true } };
|
rs = alt (false) { case (true) { false } case (false) { true } };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_inferrence() {
|
fn test_inferrence() {
|
||||||
auto res = alt (true) { case (true) { true } case (false) { false } };
|
auto rs = alt (true) { case (true) { true } case (false) { false } };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_alt_as_alt_head() {
|
fn test_alt_as_alt_head() {
|
||||||
// Yeah, this is kind of confusing ...
|
// Yeah, this is kind of confusing ...
|
||||||
|
|
||||||
auto res =
|
auto rs =
|
||||||
alt (alt (false) { case (true) { true } case (false) { false } }) {
|
alt (alt (false) { case (true) { true } case (false) { false } }) {
|
||||||
case (true) { false }
|
case (true) { false }
|
||||||
case (false) { true }
|
case (false) { true }
|
||||||
};
|
};
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_alt_as_block_result() {
|
fn test_alt_as_block_result() {
|
||||||
auto res =
|
auto rs =
|
||||||
alt (false) {
|
alt (false) {
|
||||||
case (true) { false }
|
case (true) { false }
|
||||||
case (false) {
|
case (false) {
|
||||||
alt (true) { case (true) { true } case (false) { false } }
|
alt (true) { case (true) { true } case (false) { false } }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -4,8 +4,8 @@ fn test_fn() {
|
||||||
type t = fn() -> int ;
|
type t = fn() -> int ;
|
||||||
|
|
||||||
fn ten() -> int { ret 10; }
|
fn ten() -> int { ret 10; }
|
||||||
let t res = { ten };
|
let t rs = { ten };
|
||||||
assert (res() == 10);
|
assert (rs() == 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { test_fn(); }
|
fn main() { test_fn(); }
|
|
@ -4,13 +4,13 @@
|
||||||
// -*- rust -*-
|
// -*- rust -*-
|
||||||
|
|
||||||
// Tests for standalone blocks as expressions
|
// Tests for standalone blocks as expressions
|
||||||
fn test_basic() { let bool res = { true }; assert (res); }
|
fn test_basic() { let bool rs = { true }; assert (rs); }
|
||||||
|
|
||||||
fn test_rec() { auto res = { rec(v1=10, v2=20) }; assert (res.v2 == 20); }
|
fn test_rec() { auto rs = { rec(v1=10, v2=20) }; assert (rs.v2 == 20); }
|
||||||
|
|
||||||
fn test_filled_with_stuff() {
|
fn test_filled_with_stuff() {
|
||||||
auto res = { auto a = 0; while (a < 10) { a += 1; } a };
|
auto rs = { auto a = 0; while (a < 10) { a += 1; } a };
|
||||||
assert (res == 10);
|
assert (rs == 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { test_basic(); test_rec(); test_filled_with_stuff(); }
|
fn main() { test_basic(); test_rec(); test_filled_with_stuff(); }
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
// Tests for if as expressions returning boxed types
|
// Tests for if as expressions returning boxed types
|
||||||
fn test_box() {
|
fn test_box() {
|
||||||
auto res = if (true) { @100 } else { @101 };
|
auto rs = if (true) { @100 } else { @101 };
|
||||||
assert (*res == 100);
|
assert (*rs == 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_str() {
|
fn test_str() {
|
||||||
auto res = if (true) { "happy" } else { "sad" };
|
auto rs = if (true) { "happy" } else { "sad" };
|
||||||
assert (res == "happy");
|
assert (rs == "happy");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { test_box(); test_str(); }
|
fn main() { test_box(); test_str(); }
|
|
@ -5,14 +5,14 @@
|
||||||
|
|
||||||
// Tests for if as expressions returning structural types
|
// Tests for if as expressions returning structural types
|
||||||
fn test_rec() {
|
fn test_rec() {
|
||||||
auto res = if (true) { rec(i=100) } else { rec(i=101) };
|
auto rs = if (true) { rec(i=100) } else { rec(i=101) };
|
||||||
assert (res == rec(i=100));
|
assert (rs == rec(i=100));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_tag() {
|
fn test_tag() {
|
||||||
tag mood { happy; sad; }
|
tag mood { happy; sad; }
|
||||||
auto res = if (true) { happy } else { sad };
|
auto rs = if (true) { happy } else { sad };
|
||||||
assert (res == happy);
|
assert (rs == happy);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { test_rec(); test_tag(); }
|
fn main() { test_rec(); test_tag(); }
|
|
@ -5,50 +5,50 @@
|
||||||
|
|
||||||
// Tests for if as expressions
|
// Tests for if as expressions
|
||||||
fn test_if() {
|
fn test_if() {
|
||||||
let bool res = if (true) { true } else { false };
|
let bool rs = if (true) { true } else { false };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_else() {
|
fn test_else() {
|
||||||
let bool res = if (false) { false } else { true };
|
let bool rs = if (false) { false } else { true };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_elseif1() {
|
fn test_elseif1() {
|
||||||
let bool res = if (true) { true } else if (true) { false } else { false };
|
let bool rs = if (true) { true } else if (true) { false } else { false };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_elseif2() {
|
fn test_elseif2() {
|
||||||
let bool res =
|
let bool rs =
|
||||||
if (false) { false } else if (true) { true } else { false };
|
if (false) { false } else if (true) { true } else { false };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_elseif3() {
|
fn test_elseif3() {
|
||||||
let bool res =
|
let bool rs =
|
||||||
if (false) { false } else if (false) { false } else { true };
|
if (false) { false } else if (false) { false } else { true };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_inferrence() {
|
fn test_inferrence() {
|
||||||
auto res = if (true) { true } else { false };
|
auto rs = if (true) { true } else { false };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_if_as_if_condition() {
|
fn test_if_as_if_condition() {
|
||||||
auto res1 =
|
auto rs1 =
|
||||||
if (if (false) { false } else { true }) { true } else { false };
|
if (if (false) { false } else { true }) { true } else { false };
|
||||||
assert (res1);
|
assert (rs1);
|
||||||
auto res2 =
|
auto rs2 =
|
||||||
if (if (true) { false } else { true }) { false } else { true };
|
if (if (true) { false } else { true }) { false } else { true };
|
||||||
assert (res2);
|
assert (rs2);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_if_as_block_result() {
|
fn test_if_as_block_result() {
|
||||||
auto res =
|
auto rs =
|
||||||
if (true) { if (false) { false } else { true } } else { false };
|
if (true) { if (false) { false } else { true } } else { false };
|
||||||
assert (res);
|
assert (rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -32,8 +32,8 @@ fn check_fail_type(opt::fail_ f, fail_type ft) {
|
||||||
fn test_reqopt_long() {
|
fn test_reqopt_long() {
|
||||||
auto args = ["--test=20"];
|
auto args = ["--test=20"];
|
||||||
auto opts = [opt::reqopt("test")];
|
auto opts = [opt::reqopt("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (opt::opt_present(m, "test"));
|
assert (opt::opt_present(m, "test"));
|
||||||
assert (opt::opt_str(m, "test") == "20");
|
assert (opt::opt_str(m, "test") == "20");
|
||||||
|
@ -45,8 +45,8 @@ fn test_reqopt_long() {
|
||||||
fn test_reqopt_long_missing() {
|
fn test_reqopt_long_missing() {
|
||||||
auto args = ["blah"];
|
auto args = ["blah"];
|
||||||
auto opts = [opt::reqopt("test")];
|
auto opts = [opt::reqopt("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, option_missing); }
|
case (opt::failure(?f)) { check_fail_type(f, option_missing); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ fn test_reqopt_long_missing() {
|
||||||
fn test_reqopt_long_no_arg() {
|
fn test_reqopt_long_no_arg() {
|
||||||
auto args = ["--test"];
|
auto args = ["--test"];
|
||||||
auto opts = [opt::reqopt("test")];
|
auto opts = [opt::reqopt("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ fn test_reqopt_long_no_arg() {
|
||||||
fn test_reqopt_long_multi() {
|
fn test_reqopt_long_multi() {
|
||||||
auto args = ["--test=20", "--test=30"];
|
auto args = ["--test=20", "--test=30"];
|
||||||
auto opts = [opt::reqopt("test")];
|
auto opts = [opt::reqopt("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,8 @@ fn test_reqopt_long_multi() {
|
||||||
fn test_reqopt_short() {
|
fn test_reqopt_short() {
|
||||||
auto args = ["-t", "20"];
|
auto args = ["-t", "20"];
|
||||||
auto opts = [opt::reqopt("t")];
|
auto opts = [opt::reqopt("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (opt::opt_present(m, "t"));
|
assert (opt::opt_present(m, "t"));
|
||||||
assert (opt::opt_str(m, "t") == "20");
|
assert (opt::opt_str(m, "t") == "20");
|
||||||
|
@ -88,8 +88,8 @@ fn test_reqopt_short() {
|
||||||
fn test_reqopt_short_missing() {
|
fn test_reqopt_short_missing() {
|
||||||
auto args = ["blah"];
|
auto args = ["blah"];
|
||||||
auto opts = [opt::reqopt("t")];
|
auto opts = [opt::reqopt("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, option_missing); }
|
case (opt::failure(?f)) { check_fail_type(f, option_missing); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,8 @@ fn test_reqopt_short_missing() {
|
||||||
fn test_reqopt_short_no_arg() {
|
fn test_reqopt_short_no_arg() {
|
||||||
auto args = ["-t"];
|
auto args = ["-t"];
|
||||||
auto opts = [opt::reqopt("t")];
|
auto opts = [opt::reqopt("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,8 @@ fn test_reqopt_short_no_arg() {
|
||||||
fn test_reqopt_short_multi() {
|
fn test_reqopt_short_multi() {
|
||||||
auto args = ["-t", "20", "-t", "30"];
|
auto args = ["-t", "20", "-t", "30"];
|
||||||
auto opts = [opt::reqopt("t")];
|
auto opts = [opt::reqopt("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -120,8 +120,8 @@ fn test_reqopt_short_multi() {
|
||||||
fn test_optopt_long() {
|
fn test_optopt_long() {
|
||||||
auto args = ["--test=20"];
|
auto args = ["--test=20"];
|
||||||
auto opts = [opt::optopt("test")];
|
auto opts = [opt::optopt("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (opt::opt_present(m, "test"));
|
assert (opt::opt_present(m, "test"));
|
||||||
assert (opt::opt_str(m, "test") == "20");
|
assert (opt::opt_str(m, "test") == "20");
|
||||||
|
@ -133,8 +133,8 @@ fn test_optopt_long() {
|
||||||
fn test_optopt_long_missing() {
|
fn test_optopt_long_missing() {
|
||||||
auto args = ["blah"];
|
auto args = ["blah"];
|
||||||
auto opts = [opt::optopt("test")];
|
auto opts = [opt::optopt("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) { assert (!opt::opt_present(m, "test")); }
|
case (opt::success(?m)) { assert (!opt::opt_present(m, "test")); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,8 @@ fn test_optopt_long_missing() {
|
||||||
fn test_optopt_long_no_arg() {
|
fn test_optopt_long_no_arg() {
|
||||||
auto args = ["--test"];
|
auto args = ["--test"];
|
||||||
auto opts = [opt::optopt("test")];
|
auto opts = [opt::optopt("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -153,8 +153,8 @@ fn test_optopt_long_no_arg() {
|
||||||
fn test_optopt_long_multi() {
|
fn test_optopt_long_multi() {
|
||||||
auto args = ["--test=20", "--test=30"];
|
auto args = ["--test=20", "--test=30"];
|
||||||
auto opts = [opt::optopt("test")];
|
auto opts = [opt::optopt("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -163,8 +163,8 @@ fn test_optopt_long_multi() {
|
||||||
fn test_optopt_short() {
|
fn test_optopt_short() {
|
||||||
auto args = ["-t", "20"];
|
auto args = ["-t", "20"];
|
||||||
auto opts = [opt::optopt("t")];
|
auto opts = [opt::optopt("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (opt::opt_present(m, "t"));
|
assert (opt::opt_present(m, "t"));
|
||||||
assert (opt::opt_str(m, "t") == "20");
|
assert (opt::opt_str(m, "t") == "20");
|
||||||
|
@ -176,8 +176,8 @@ fn test_optopt_short() {
|
||||||
fn test_optopt_short_missing() {
|
fn test_optopt_short_missing() {
|
||||||
auto args = ["blah"];
|
auto args = ["blah"];
|
||||||
auto opts = [opt::optopt("t")];
|
auto opts = [opt::optopt("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) { assert (!opt::opt_present(m, "t")); }
|
case (opt::success(?m)) { assert (!opt::opt_present(m, "t")); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -186,8 +186,8 @@ fn test_optopt_short_missing() {
|
||||||
fn test_optopt_short_no_arg() {
|
fn test_optopt_short_no_arg() {
|
||||||
auto args = ["-t"];
|
auto args = ["-t"];
|
||||||
auto opts = [opt::optopt("t")];
|
auto opts = [opt::optopt("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -196,8 +196,8 @@ fn test_optopt_short_no_arg() {
|
||||||
fn test_optopt_short_multi() {
|
fn test_optopt_short_multi() {
|
||||||
auto args = ["-t", "20", "-t", "30"];
|
auto args = ["-t", "20", "-t", "30"];
|
||||||
auto opts = [opt::optopt("t")];
|
auto opts = [opt::optopt("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -208,8 +208,8 @@ fn test_optopt_short_multi() {
|
||||||
fn test_optflag_long() {
|
fn test_optflag_long() {
|
||||||
auto args = ["--test"];
|
auto args = ["--test"];
|
||||||
auto opts = [opt::optflag("test")];
|
auto opts = [opt::optflag("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) { assert (opt::opt_present(m, "test")); }
|
case (opt::success(?m)) { assert (opt::opt_present(m, "test")); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -218,8 +218,8 @@ fn test_optflag_long() {
|
||||||
fn test_optflag_long_missing() {
|
fn test_optflag_long_missing() {
|
||||||
auto args = ["blah"];
|
auto args = ["blah"];
|
||||||
auto opts = [opt::optflag("test")];
|
auto opts = [opt::optflag("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) { assert (!opt::opt_present(m, "test")); }
|
case (opt::success(?m)) { assert (!opt::opt_present(m, "test")); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -228,8 +228,8 @@ fn test_optflag_long_missing() {
|
||||||
fn test_optflag_long_arg() {
|
fn test_optflag_long_arg() {
|
||||||
auto args = ["--test=20"];
|
auto args = ["--test=20"];
|
||||||
auto opts = [opt::optflag("test")];
|
auto opts = [opt::optflag("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) {
|
case (opt::failure(?f)) {
|
||||||
log_err opt::fail_str(f);
|
log_err opt::fail_str(f);
|
||||||
check_fail_type(f, unexpected_argument);
|
check_fail_type(f, unexpected_argument);
|
||||||
|
@ -241,8 +241,8 @@ fn test_optflag_long_arg() {
|
||||||
fn test_optflag_long_multi() {
|
fn test_optflag_long_multi() {
|
||||||
auto args = ["--test", "--test"];
|
auto args = ["--test", "--test"];
|
||||||
auto opts = [opt::optflag("test")];
|
auto opts = [opt::optflag("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -251,8 +251,8 @@ fn test_optflag_long_multi() {
|
||||||
fn test_optflag_short() {
|
fn test_optflag_short() {
|
||||||
auto args = ["-t"];
|
auto args = ["-t"];
|
||||||
auto opts = [opt::optflag("t")];
|
auto opts = [opt::optflag("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) { assert (opt::opt_present(m, "t")); }
|
case (opt::success(?m)) { assert (opt::opt_present(m, "t")); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -261,8 +261,8 @@ fn test_optflag_short() {
|
||||||
fn test_optflag_short_missing() {
|
fn test_optflag_short_missing() {
|
||||||
auto args = ["blah"];
|
auto args = ["blah"];
|
||||||
auto opts = [opt::optflag("t")];
|
auto opts = [opt::optflag("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) { assert (!opt::opt_present(m, "t")); }
|
case (opt::success(?m)) { assert (!opt::opt_present(m, "t")); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -271,8 +271,8 @@ fn test_optflag_short_missing() {
|
||||||
fn test_optflag_short_arg() {
|
fn test_optflag_short_arg() {
|
||||||
auto args = ["-t", "20"];
|
auto args = ["-t", "20"];
|
||||||
auto opts = [opt::optflag("t")];
|
auto opts = [opt::optflag("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
// The next variable after the flag is just a free argument
|
// The next variable after the flag is just a free argument
|
||||||
|
|
||||||
|
@ -285,8 +285,8 @@ fn test_optflag_short_arg() {
|
||||||
fn test_optflag_short_multi() {
|
fn test_optflag_short_multi() {
|
||||||
auto args = ["-t", "-t"];
|
auto args = ["-t", "-t"];
|
||||||
auto opts = [opt::optflag("t")];
|
auto opts = [opt::optflag("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
case (opt::failure(?f)) { check_fail_type(f, option_duplicated); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -297,8 +297,8 @@ fn test_optflag_short_multi() {
|
||||||
fn test_optmulti_long() {
|
fn test_optmulti_long() {
|
||||||
auto args = ["--test=20"];
|
auto args = ["--test=20"];
|
||||||
auto opts = [opt::optmulti("test")];
|
auto opts = [opt::optmulti("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (opt::opt_present(m, "test"));
|
assert (opt::opt_present(m, "test"));
|
||||||
assert (opt::opt_str(m, "test") == "20");
|
assert (opt::opt_str(m, "test") == "20");
|
||||||
|
@ -310,8 +310,8 @@ fn test_optmulti_long() {
|
||||||
fn test_optmulti_long_missing() {
|
fn test_optmulti_long_missing() {
|
||||||
auto args = ["blah"];
|
auto args = ["blah"];
|
||||||
auto opts = [opt::optmulti("test")];
|
auto opts = [opt::optmulti("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) { assert (!opt::opt_present(m, "test")); }
|
case (opt::success(?m)) { assert (!opt::opt_present(m, "test")); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -320,8 +320,8 @@ fn test_optmulti_long_missing() {
|
||||||
fn test_optmulti_long_no_arg() {
|
fn test_optmulti_long_no_arg() {
|
||||||
auto args = ["--test"];
|
auto args = ["--test"];
|
||||||
auto opts = [opt::optmulti("test")];
|
auto opts = [opt::optmulti("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -330,8 +330,8 @@ fn test_optmulti_long_no_arg() {
|
||||||
fn test_optmulti_long_multi() {
|
fn test_optmulti_long_multi() {
|
||||||
auto args = ["--test=20", "--test=30"];
|
auto args = ["--test=20", "--test=30"];
|
||||||
auto opts = [opt::optmulti("test")];
|
auto opts = [opt::optmulti("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (opt::opt_present(m, "test"));
|
assert (opt::opt_present(m, "test"));
|
||||||
assert (opt::opt_str(m, "test") == "20");
|
assert (opt::opt_str(m, "test") == "20");
|
||||||
|
@ -345,8 +345,8 @@ fn test_optmulti_long_multi() {
|
||||||
fn test_optmulti_short() {
|
fn test_optmulti_short() {
|
||||||
auto args = ["-t", "20"];
|
auto args = ["-t", "20"];
|
||||||
auto opts = [opt::optmulti("t")];
|
auto opts = [opt::optmulti("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (opt::opt_present(m, "t"));
|
assert (opt::opt_present(m, "t"));
|
||||||
assert (opt::opt_str(m, "t") == "20");
|
assert (opt::opt_str(m, "t") == "20");
|
||||||
|
@ -358,8 +358,8 @@ fn test_optmulti_short() {
|
||||||
fn test_optmulti_short_missing() {
|
fn test_optmulti_short_missing() {
|
||||||
auto args = ["blah"];
|
auto args = ["blah"];
|
||||||
auto opts = [opt::optmulti("t")];
|
auto opts = [opt::optmulti("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) { assert (!opt::opt_present(m, "t")); }
|
case (opt::success(?m)) { assert (!opt::opt_present(m, "t")); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -368,8 +368,8 @@ fn test_optmulti_short_missing() {
|
||||||
fn test_optmulti_short_no_arg() {
|
fn test_optmulti_short_no_arg() {
|
||||||
auto args = ["-t"];
|
auto args = ["-t"];
|
||||||
auto opts = [opt::optmulti("t")];
|
auto opts = [opt::optmulti("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
case (opt::failure(?f)) { check_fail_type(f, argument_missing); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -378,8 +378,8 @@ fn test_optmulti_short_no_arg() {
|
||||||
fn test_optmulti_short_multi() {
|
fn test_optmulti_short_multi() {
|
||||||
auto args = ["-t", "20", "-t", "30"];
|
auto args = ["-t", "20", "-t", "30"];
|
||||||
auto opts = [opt::optmulti("t")];
|
auto opts = [opt::optmulti("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (opt::opt_present(m, "t"));
|
assert (opt::opt_present(m, "t"));
|
||||||
assert (opt::opt_str(m, "t") == "20");
|
assert (opt::opt_str(m, "t") == "20");
|
||||||
|
@ -393,8 +393,8 @@ fn test_optmulti_short_multi() {
|
||||||
fn test_unrecognized_option_long() {
|
fn test_unrecognized_option_long() {
|
||||||
auto args = ["--untest"];
|
auto args = ["--untest"];
|
||||||
auto opts = [opt::optmulti("t")];
|
auto opts = [opt::optmulti("t")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, unrecognized_option); }
|
case (opt::failure(?f)) { check_fail_type(f, unrecognized_option); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -403,8 +403,8 @@ fn test_unrecognized_option_long() {
|
||||||
fn test_unrecognized_option_short() {
|
fn test_unrecognized_option_short() {
|
||||||
auto args = ["-t"];
|
auto args = ["-t"];
|
||||||
auto opts = [opt::optmulti("test")];
|
auto opts = [opt::optmulti("test")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::failure(?f)) { check_fail_type(f, unrecognized_option); }
|
case (opt::failure(?f)) { check_fail_type(f, unrecognized_option); }
|
||||||
case (_) { fail; }
|
case (_) { fail; }
|
||||||
}
|
}
|
||||||
|
@ -417,8 +417,8 @@ fn test_combined() {
|
||||||
auto opts =
|
auto opts =
|
||||||
[opt::optopt("s"), opt::optflag("flag"), opt::reqopt("long"),
|
[opt::optopt("s"), opt::optflag("flag"), opt::reqopt("long"),
|
||||||
opt::optflag("f"), opt::optmulti("m"), opt::optopt("notpresent")];
|
opt::optflag("f"), opt::optmulti("m"), opt::optopt("notpresent")];
|
||||||
auto res = opt::getopts(args, opts);
|
auto rs = opt::getopts(args, opts);
|
||||||
alt (res) {
|
alt (rs) {
|
||||||
case (opt::success(?m)) {
|
case (opt::success(?m)) {
|
||||||
assert (m.free.(0) == "prog");
|
assert (m.free.(0) == "prog");
|
||||||
assert (m.free.(1) == "free1");
|
assert (m.free.(1) == "free1");
|
||||||
|
|
|
@ -16,8 +16,8 @@ fn test_from_vec() {
|
||||||
fn test_foldl() {
|
fn test_foldl() {
|
||||||
auto l = from_vec([0, 1, 2, 3, 4]);
|
auto l = from_vec([0, 1, 2, 3, 4]);
|
||||||
fn add(&int a, &uint b) -> uint { ret (a as uint) + b; }
|
fn add(&int a, &uint b) -> uint { ret (a as uint) + b; }
|
||||||
auto res = list::foldl(l, 0u, add);
|
auto rs = list::foldl(l, 0u, add);
|
||||||
assert (res == 10u);
|
assert (rs == 10u);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_find_success() {
|
fn test_find_success() {
|
||||||
|
@ -25,15 +25,15 @@ fn test_find_success() {
|
||||||
fn match(&int i) -> option::t[int] {
|
fn match(&int i) -> option::t[int] {
|
||||||
ret if (i == 2) { option::some(i) } else { option::none[int] };
|
ret if (i == 2) { option::some(i) } else { option::none[int] };
|
||||||
}
|
}
|
||||||
auto res = list::find(l, match);
|
auto rs = list::find(l, match);
|
||||||
assert (res == option::some(2));
|
assert (rs == option::some(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_find_fail() {
|
fn test_find_fail() {
|
||||||
auto l = from_vec([0, 1, 2]);
|
auto l = from_vec([0, 1, 2]);
|
||||||
fn match(&int i) -> option::t[int] { ret option::none[int]; }
|
fn match(&int i) -> option::t[int] { ret option::none[int]; }
|
||||||
auto res = list::find(l, match);
|
auto rs = list::find(l, match);
|
||||||
assert (res == option::none[int]);
|
assert (rs == option::none[int]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_has() {
|
fn test_has() {
|
||||||
|
|
|
@ -13,9 +13,9 @@ fn main() {
|
||||||
|
|
||||||
fn a_million_letter_a() -> str {
|
fn a_million_letter_a() -> str {
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
auto res = "";
|
auto rs = "";
|
||||||
while (i < 100000) { res += "aaaaaaaaaa"; i += 1; }
|
while (i < 100000) { rs += "aaaaaaaaaa"; i += 1; }
|
||||||
ret res;
|
ret rs;
|
||||||
}
|
}
|
||||||
// Test messages from FIPS 180-1
|
// Test messages from FIPS 180-1
|
||||||
|
|
||||||
|
|
|
@ -100,15 +100,15 @@ fn test_slice() {
|
||||||
assert (str::eq("", str::slice("abc", 1u, 1u)));
|
assert (str::eq("", str::slice("abc", 1u, 1u)));
|
||||||
fn a_million_letter_a() -> str {
|
fn a_million_letter_a() -> str {
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
auto res = "";
|
auto rs = "";
|
||||||
while (i < 100000) { res += "aaaaaaaaaa"; i += 1; }
|
while (i < 100000) { rs += "aaaaaaaaaa"; i += 1; }
|
||||||
ret res;
|
ret rs;
|
||||||
}
|
}
|
||||||
fn half_a_million_letter_a() -> str {
|
fn half_a_million_letter_a() -> str {
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
auto res = "";
|
auto rs = "";
|
||||||
while (i < 100000) { res += "aaaaa"; i += 1; }
|
while (i < 100000) { rs += "aaaaa"; i += 1; }
|
||||||
ret res;
|
ret rs;
|
||||||
}
|
}
|
||||||
assert (str::eq(half_a_million_letter_a(),
|
assert (str::eq(half_a_million_letter_a(),
|
||||||
str::slice(a_million_letter_a(), 0u, 500000u)));
|
str::slice(a_million_letter_a(), 0u, 500000u)));
|
||||||
|
|
|
@ -15,12 +15,12 @@ fn main() {
|
||||||
// }
|
// }
|
||||||
fn get() -> int { ret i; }
|
fn get() -> int { ret i; }
|
||||||
}
|
}
|
||||||
let int res;
|
let int rs;
|
||||||
auto o = foo(5);
|
auto o = foo(5);
|
||||||
res = o.get();
|
rs = o.get();
|
||||||
assert (res == 5);
|
assert (rs == 5);
|
||||||
res = o.inc_by(3);
|
rs = o.inc_by(3);
|
||||||
assert (res == 8);
|
assert (rs == 8);
|
||||||
res = o.get();
|
rs = o.get();
|
||||||
assert (res == 8);
|
assert (rs == 8);
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
// -*- rust -*-
|
// -*- rust -*-
|
||||||
fn checktrue(bool res) -> bool { assert (res); ret true; }
|
fn checktrue(bool rs) -> bool { assert (rs); ret true; }
|
||||||
|
|
||||||
fn main() { auto k = checktrue; evenk(42, k); oddk(45, k); }
|
fn main() { auto k = checktrue; evenk(42, k); oddk(45, k); }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue