the reason is that there is no need for the `mod test` directive in test.rc. This effectively creates loads the `test.rs` file twice, once in the root namespace and once as the module `test`.

Niko

On 4/10/12 8:07 PM, Alexander Stavonin wrote:
Hi all,

I've faced with strange behavior of #[test] command. Could someone explain me is it bug or feature.

--------- test.rc ----------
#[link (name="test",
        vers = "0.1",
        uuid = "B019C86D-C7ED-4263-810E-B12A33E6954C")];
#[crate_type = "lib"];

use std;
mod test;
------ END -------


--------- test.rs ----------
fn foo() -> bool { ret true }

#[test]
fn foo_test() {
    assert foo() == true;
}
------ END -------

Compiling and run it:

astavonin:/Users/../RustTests: rustc --test test.rc
warning: no debug symbols in executable (-arch x86_64)
astavonin:/Users/../RustTests: ./test

running *_2_* tests
test foo_test ... ok
test test::foo_test ... ok

result: ok. 2 passed; 0 failed; 0 ignored

Question: Why 2 tests was created from just 1 foo_test() test function? Also, it's looks like both tests are running parallel and sometimes it provoke segmentation faults in case of more complex tests.

Regards,
Alexander.


_______________________________________________
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