You need to include "extern mod std;" at the top of your program.  This will link in the standard library (as opposed to the core lib).  I think that in modern versions of the compiler (i.e., the trunk) this is automatic, or at least has a better error message, but I am not sure.


Niko

March 2, 2013 12:10 AM
Hi,

I'm trying to get started with rust 0.5.  I've got it built and can compile+execute some simple programs.  Now I want to get running with test driven development, so I just want to write, build, and run a simple unit test... according to the documentation+wiki, the following is the minimal unit test:

$ cat test.rs
// sample
#[test]
fn testFail() {
    fail;
}

And the --test option is supposed to build a harness to run everything marked with attribute #[test]:

$ rustc test.rs --test
test.rs:1:0: 1:0 error: unresolved name
test.rs:1 // sample
          ^
test.rs:1:0: 1:0 error: use of undeclared module `std::test`
test.rs:1 // sample
          ^
test.rs:1:0: 1:0 error: unresolved name: std::test::test_main
test.rs:1 // sample
          ^
test.rs:1:0: 1:0 error: unresolved name
test.rs:1 // sample
          ^
test.rs:1:0: 1:0 error: use of undeclared module `std::test`
test.rs:1 // sample
          ^
test.rs:1:0: 1:0 error: use of undeclared type name `std::test::TestDesc`
test.rs:1 // sample
          ^
Can someone point me in the right direction here?

Thanks,
David

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to