PageRenderTime 17ms CodeModel.GetById 2ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/alt-tag.rs

http://github.com/jruderman/rust
Rust | 28 lines | 22 code | 5 blank | 1 comment | 3 complexity | 0d5fd3ddb73538bec93397cf1e336e8a MD5 | raw file
 1
 2
 3
 4// -*- rust -*-
 5enum color {
 6    rgb(int, int, int),
 7    rgba(int, int, int, int),
 8    hsl(int, int, int),
 9}
10
11fn process(c: color) -> int {
12    let mut x: int;
13    match c {
14      rgb(r, _, _) => { debug!{"rgb"}; log(debug, r); x = r; }
15      rgba(_, _, _, a) => { debug!{"rgba"}; log(debug, a); x = a; }
16      hsl(_, s, _) => { debug!{"hsl"}; log(debug, s); x = s; }
17    }
18    return x;
19}
20
21fn main() {
22    let gray: color = rgb(127, 127, 127);
23    let clear: color = rgba(50, 150, 250, 0);
24    let red: color = hsl(0, 255, 255);
25    assert (process(gray) == 127);
26    assert (process(clear) == 0);
27    assert (process(red) == 255);
28}