Skip to content

Commit 819b000

Browse files
committed
Library test cases for vec::zip
1 parent 268533a commit 819b000

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// error-pattern:Unsatisfied precondition constraint (for example, same_length
2+
use std;
3+
import std::uint;
4+
import std::u8;
5+
import std::vec::*;
6+
7+
fn main() {
8+
let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 10u;
9+
// Silly, but necessary
10+
check u8::le(a, j);
11+
check uint::le(k, l);
12+
let chars = enum_chars(a, j);
13+
let ints = enum_uints(k, l);
14+
15+
let ps = zip(chars, ints);
16+
fail "the impossible happened";
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// In this case, the code should compile but
2+
// the check should fail at runtime
3+
// error-pattern:Predicate same_length
4+
use std;
5+
import std::uint;
6+
import std::u8;
7+
import std::vec::*;
8+
9+
fn main() {
10+
let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 9u;
11+
// Silly, but necessary
12+
check u8::le(a, j);
13+
check uint::le(k, l);
14+
let chars = enum_chars(a, j);
15+
let ints = enum_uints(k, l);
16+
17+
check same_length(chars, ints);
18+
let ps = zip(chars, ints);
19+
fail "the impossible happened";
20+
}

src/test/run-pass/zip-same-length.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// In this case, the code should compile and should
2+
// succeed at runtime
3+
use std;
4+
import std::uint;
5+
6+
import std::vec::*;
7+
8+
fn main() {
9+
let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 10u;
10+
// Silly, but necessary
11+
check le_u8(a, j);
12+
check uint::le(k, l);
13+
let chars = enum_chars(a, j);
14+
let ints = enum_uints(k, l);
15+
16+
/*
17+
check same_length(chars, ints);
18+
let ps = zip(chars, ints);
19+
20+
assert (head(ps) == ('a', 1u));
21+
assert (last(ps) == ('j' as u8, 10u));
22+
*/
23+
}

0 commit comments

Comments
 (0)