Conversation
src/librlibc/lib.rs
Outdated
There was a problem hiding this comment.
This will need to stay rather than being commented out. You can follow the same test strategy of crates like libcollections which have lots of #[cfg(test)] directives at the top.
There was a problem hiding this comment.
Sure, there is one right down below, but it seems to make no effect whrn this one is on :(
There was a problem hiding this comment.
Can you explain the errors that you're encountering?
There was a problem hiding this comment.
The errors where simply that assert! (and friends) are not defined. Turns out that it's not enough to add #[cfg(test)] extern crate test;, which seemed like an obvious way of fixing this...
#[cfg(test)] #[phase(plugin, link)] extern crate std;Following your advise I checked libcollections/lib.rs and adding the above for some reason fixes this. This still looks like a little issue in the compiler, don't you think?
There was a problem hiding this comment.
Turns out that it's not enough to add #[cfg(test)] extern crate test;,
What is the error? (We'll be able to tell if it's a compiler issue if you tell us the error messages/problems. :) )
There was a problem hiding this comment.
The error message without the extra attribute was this:
lib.rs:117:13: 117:22 error: macro undefined: 'assert_eq!'
I am now actually face with something more interesting:
error: type `&'static str` does not implement any method in scope named `len`
There was a problem hiding this comment.
Ah, yes, if you're using macros from std (or core) you need to import them via a #[phase].
For len, it's a trait method so you need to have the traits in scope. (i.e. add a use std::collections::Collection in the module with the tests.)
|
I will add a test for |
|
r? |
src/librlibc/lib.rs
Outdated
|
Ok, I will squash if everyone is happy :) r? |
We are pulling in rlibc into Zinc (hackndev/zinc#113), but while reading the code, I though it could do with some unit tests.
So I have added some tests here, but seem like there are a few issues... Please see comments withXXXand respond if you have any thoughts...