PageRenderTime 25ms CodeModel.GetById 19ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/expr-fn.rs

http://github.com/jruderman/rust
Rust | 58 lines | 46 code | 11 blank | 1 comment | 10 complexity | 3a81be66acd1425a4cb40b78824cfaaa MD5 | raw file
 1fn test_int() {
 2    fn f() -> int { 10 }
 3    assert (f() == 10);
 4}
 5
 6fn test_vec() {
 7    fn f() -> ~[int] { ~[10, 11] }
 8    assert (f()[1] == 11);
 9}
10
11fn test_generic() {
12    fn f<T: copy>(t: T) -> T { t }
13    assert (f(10) == 10);
14}
15
16fn test_alt() {
17    fn f() -> int { match true { false => { 10 } true => { 20 } } }
18    assert (f() == 20);
19}
20
21fn test_if() {
22    fn f() -> int { if true { 10 } else { 20 } }
23    assert (f() == 10);
24}
25
26fn test_block() {
27    fn f() -> int { { 10 } }
28    assert (f() == 10);
29}
30
31fn test_ret() {
32    fn f() -> int {
33        return 10 // no semi
34
35    }
36    assert (f() == 10);
37}
38
39
40// From issue #372
41fn test_372() {
42    fn f() -> int { let x = { 3 }; x }
43    assert (f() == 3);
44}
45
46fn test_nil() { () }
47
48fn main() {
49    test_int();
50    test_vec();
51    test_generic();
52    test_alt();
53    test_if();
54    test_block();
55    test_ret();
56    test_372();
57    test_nil();
58}