Alter/remove tests that include/concern ternary
3 tests, pretty/block-disambig.rs, run-pass/operator-overloading.rs, and run-pass/weird-exprs.rs, all included the ternary operator. These were changed to use the if-then-else construct instead. 2 tests, run-pass/block-arg-in-ternary.rs and run-pass/ternary.rs, were only there because of the ternary operator, and were removed.
This commit is contained in:
parent
86d473ad1f
commit
e1f15a71e3
5 changed files with 3 additions and 52 deletions
|
@ -24,7 +24,7 @@ fn test7() -> uint {
|
||||||
(*regs < 2) as uint
|
(*regs < 2) as uint
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test8() -> int { let val = @0; alt true { true { } } *val < 1 ? 0 : 1 }
|
fn test8() -> int { let val = @0; alt true { true { } } if *val < 1 { 0 } else { 1 } }
|
||||||
|
|
||||||
fn test9() { let regs = @mutable 0; alt true { true { } } *regs += 1; }
|
fn test9() { let regs = @mutable 0; alt true { true { } } *regs += 1; }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
// Allow block arguments with ternary... why not, no chance of ambig.
|
|
||||||
fn main() {
|
|
||||||
let v = [-1f, 1f];
|
|
||||||
let foo = vec::any(v) { |e| float::is_negative(e) } ? true : false;
|
|
||||||
assert foo;
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ impl point_ops for point {
|
||||||
{x: -self.x, y: -self.y}
|
{x: -self.x, y: -self.y}
|
||||||
}
|
}
|
||||||
fn [](x: bool) -> int {
|
fn [](x: bool) -> int {
|
||||||
x ? self.x : self.y
|
if x { self.x } else { self.y }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
fn test_simple() { let x = true ? 10 : 11; assert (x == 10); }
|
|
||||||
|
|
||||||
fn test_precedence() {
|
|
||||||
let x;
|
|
||||||
|
|
||||||
x = true || true ? 10 : 11;
|
|
||||||
assert (x == 10);
|
|
||||||
|
|
||||||
x = true == false ? 10 : 11;
|
|
||||||
assert (x == 11);
|
|
||||||
|
|
||||||
x = true ? false ? 10 : 11 : 12;
|
|
||||||
assert (x == 11);
|
|
||||||
|
|
||||||
let y = true ? 0xF0 : 0x0 | 0x0F;
|
|
||||||
assert (y == 0xF0);
|
|
||||||
|
|
||||||
y = true ? 0xF0 | 0x0F : 0x0;
|
|
||||||
assert (y == 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_associativity() {
|
|
||||||
// Ternary is right-associative
|
|
||||||
let x = false ? 10 : false ? 11 : 12;
|
|
||||||
assert (x == 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_lval() {
|
|
||||||
let box1: @mutable int = @mutable 10;
|
|
||||||
let box2: @mutable int = @mutable 10;
|
|
||||||
*(true ? box1 : box2) = 100;
|
|
||||||
assert (*box1 == 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_as_stmt() { let s; true ? s = 10 : s = 12; assert (s == 10); }
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
test_simple();
|
|
||||||
test_precedence();
|
|
||||||
test_associativity();
|
|
||||||
test_lval();
|
|
||||||
test_as_stmt();
|
|
||||||
}
|
|
|
@ -19,7 +19,7 @@ fn zombiejesus() {
|
||||||
do {
|
do {
|
||||||
while (ret) {
|
while (ret) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
alt (ret) { _ { ret ? ret : ret } };
|
alt (ret) { _ { if ret { ret } else { ret } } };
|
||||||
} else if (ret) {
|
} else if (ret) {
|
||||||
ret;
|
ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue