Library test cases for vec::zip
This commit is contained in:
parent
268533a920
commit
819b00079c
3 changed files with 60 additions and 0 deletions
17
src/test/compile-fail/zip-missing-check.rs
Normal file
17
src/test/compile-fail/zip-missing-check.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// error-pattern:Unsatisfied precondition constraint (for example, same_length
|
||||
use std;
|
||||
import std::uint;
|
||||
import std::u8;
|
||||
import std::vec::*;
|
||||
|
||||
fn main() {
|
||||
let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 10u;
|
||||
// Silly, but necessary
|
||||
check u8::le(a, j);
|
||||
check uint::le(k, l);
|
||||
let chars = enum_chars(a, j);
|
||||
let ints = enum_uints(k, l);
|
||||
|
||||
let ps = zip(chars, ints);
|
||||
fail "the impossible happened";
|
||||
}
|
||||
20
src/test/run-fail/zip-different-lengths.rs
Normal file
20
src/test/run-fail/zip-different-lengths.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// In this case, the code should compile but
|
||||
// the check should fail at runtime
|
||||
// error-pattern:Predicate same_length
|
||||
use std;
|
||||
import std::uint;
|
||||
import std::u8;
|
||||
import std::vec::*;
|
||||
|
||||
fn main() {
|
||||
let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 9u;
|
||||
// Silly, but necessary
|
||||
check u8::le(a, j);
|
||||
check uint::le(k, l);
|
||||
let chars = enum_chars(a, j);
|
||||
let ints = enum_uints(k, l);
|
||||
|
||||
check same_length(chars, ints);
|
||||
let ps = zip(chars, ints);
|
||||
fail "the impossible happened";
|
||||
}
|
||||
23
src/test/run-pass/zip-same-length.rs
Normal file
23
src/test/run-pass/zip-same-length.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// In this case, the code should compile and should
|
||||
// succeed at runtime
|
||||
use std;
|
||||
import std::uint;
|
||||
|
||||
import std::vec::*;
|
||||
|
||||
fn main() {
|
||||
let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 10u;
|
||||
// Silly, but necessary
|
||||
check le_u8(a, j);
|
||||
check uint::le(k, l);
|
||||
let chars = enum_chars(a, j);
|
||||
let ints = enum_uints(k, l);
|
||||
|
||||
/*
|
||||
check same_length(chars, ints);
|
||||
let ps = zip(chars, ints);
|
||||
|
||||
assert (head(ps) == ('a', 1u));
|
||||
assert (last(ps) == ('j' as u8, 10u));
|
||||
*/
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue