Skip to content

Commit 56e24fd

Browse files
committed
---
yaml --- r: 148453 b: refs/heads/try2 c: 94236fc h: refs/heads/master i: 148451: 56a115c v: v3
1 parent 6a1326a commit 56e24fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1435
-948
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: caa321ab7d2b5d82e87c7d88dcb5ab7bd2adfd66
8+
refs/heads/try2: 94236fc078474a48fe516394b472027d6b7f66d4
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/guide-testing.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
3333
# Unit testing in Rust
3434

3535
Rust has built in support for simple unit testing. Functions can be
36-
marked as unit tests using the 'test' attribute.
36+
marked as unit tests using the `test` attribute.
3737

3838
~~~
3939
#[test]
@@ -44,13 +44,13 @@ fn return_none_if_empty() {
4444

4545
A test function's signature must have no arguments and no return
4646
value. To run the tests in a crate, it must be compiled with the
47-
'--test' flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
47+
`--test` flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
4848
the resulting executable will run all the tests in the crate. A test
4949
is considered successful if its function returns; if the task running
5050
the test fails, through a call to `fail!`, a failed `check` or
5151
`assert`, or some other (`assert_eq`, ...) means, then the test fails.
5252

53-
When compiling a crate with the '--test' flag '--cfg test' is also
53+
When compiling a crate with the `--test` flag `--cfg test` is also
5454
implied, so that tests can be conditionally compiled.
5555

5656
~~~
@@ -64,17 +64,17 @@ mod tests {
6464
~~~
6565

6666
Additionally `#[test]` items behave as if they also have the
67-
`#[cfg(test)]` attribute, and will not be compiled when the --test flag
67+
`#[cfg(test)]` attribute, and will not be compiled when the `--test` flag
6868
is not used.
6969

70-
Tests that should not be run can be annotated with the 'ignore'
70+
Tests that should not be run can be annotated with the `ignore`
7171
attribute. The existence of these tests will be noted in the test
7272
runner output, but the test will not be run. Tests can also be ignored
7373
by configuration so, for example, to ignore a test on windows you can
7474
write `#[ignore(cfg(target_os = "win32"))]`.
7575

7676
Tests that are intended to fail can be annotated with the
77-
'should_fail' attribute. The test will be run, and if it causes its
77+
`should_fail` attribute. The test will be run, and if it causes its
7878
task to fail then the test will be counted as successful; otherwise it
7979
will be counted as a failure. For example:
8080

@@ -87,11 +87,11 @@ fn test_out_of_bounds_failure() {
8787
}
8888
~~~
8989

90-
A test runner built with the '--test' flag supports a limited set of
90+
A test runner built with the `--test` flag supports a limited set of
9191
arguments to control which tests are run: the first free argument
9292
passed to a test runner specifies a filter used to narrow down the set
93-
of tests being run; the '--ignored' flag tells the test runner to run
94-
only tests with the 'ignore' attribute.
93+
of tests being run; the `--ignored` flag tells the test runner to run
94+
only tests with the `ignore` attribute.
9595

9696
## Parallelism
9797

branches/try2/doc/tutorial.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,10 +1020,15 @@ being destroyed along with the owner. Since the `list` variable above is
10201020
immutable, the whole list is immutable. The memory allocation itself is the
10211021
box, while the owner holds onto a pointer to it:
10221022

1023-
Cons cell Cons cell Cons cell
1024-
+-----------+ +-----+-----+ +-----+-----+
1025-
| 1 | ~ | -> | 2 | ~ | -> | 3 | ~ | -> Nil
1026-
+-----------+ +-----+-----+ +-----+-----+
1023+
List box List box List box List box
1024+
+--------------+ +--------------+ +--------------+ +--------------+
1025+
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
1026+
+--------------+ +--------------+ +--------------+ +--------------+
1027+
1028+
> Note: the above diagram shows the logical contents of the enum. The actual
1029+
> memory layout of the enum may vary. For example, for the `List` enum shown
1030+
> above, Rust guarantees that there will be no enum tag field in the actual
1031+
> structure. See the language reference for more details.
10271032
10281033
An owned box is a common example of a type with a destructor. The allocated
10291034
memory is cleaned up when the box is destroyed.

branches/try2/src/compiletest/runtest.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ fn run_pretty_test(config: &config, props: &TestProps, testfile: &Path) {
206206
}
207207

208208
fn make_pp_args(config: &config, _testfile: &Path) -> ProcArgs {
209-
let args = ~[~"-", ~"--pretty", ~"normal"];
209+
let args = ~[~"-", ~"--pretty", ~"normal",
210+
~"--target=" + config.target];
210211
// FIXME (#9639): This needs to handle non-utf8 paths
211212
return ProcArgs {prog: config.rustc_path.as_str().unwrap().to_owned(), args: args};
212213
}
@@ -237,9 +238,15 @@ actual:\n\
237238

238239
fn make_typecheck_args(config: &config, props: &TestProps, testfile: &Path) -> ProcArgs {
239240
let aux_dir = aux_output_dir_name(config, testfile);
241+
let target = if props.force_host {
242+
config.host.as_slice()
243+
} else {
244+
config.target.as_slice()
245+
};
240246
// FIXME (#9639): This needs to handle non-utf8 paths
241247
let mut args = ~[~"-",
242248
~"--no-trans", ~"--lib",
249+
~"--target=" + target,
243250
~"-L", config.build_base.as_str().unwrap().to_owned(),
244251
~"-L",
245252
aux_dir.as_str().unwrap().to_owned()];

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: 2013 Dec 10
6+
" Last Change: 2014 Jan 4
77

88
if version < 600
99
syntax clear
@@ -147,8 +147,8 @@ syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustFail
147147
syn match rustSpecialError display contained /\\./
148148
syn match rustSpecial display contained /\\\([nrt0\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)/
149149
syn match rustStringContinuation display contained /\\\n\s*/
150-
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustSpecial,rustSpecialError,rustStringContinuation
151-
syn region rustString start='r\z(#*\)"' end='"\z1'
150+
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustSpecial,rustSpecialError,rustStringContinuation,@Spell
151+
syn region rustString start='r\z(#*\)"' end='"\z1' contains=@Spell
152152

153153
syn region rustAttribute start="#\[" end="\]" contains=rustString,rustDeriving
154154
syn region rustDeriving start="deriving(" end=")" contained contains=rustTrait
@@ -179,10 +179,10 @@ syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit
179179
syn match rustCharacter /'\([^'\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustSpecial,rustSpecialError
180180

181181
syn cluster rustComment contains=rustCommentLine,rustCommentLineDoc,rustCommentBlock,rustCommentBlockDoc
182-
syn region rustCommentLine start="//" end="$" contains=rustTodo
183-
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo
184-
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment keepend extend
185-
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment keepend extend
182+
syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell
183+
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell
184+
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
185+
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment,@Spell keepend extend
186186
" FIXME: this is a really ugly and not fully correct implementation. Most
187187
" importantly, a case like ``/* */*`` should have the final ``*`` not being in
188188
" a comment, but in practice at present it leaves comments open two levels

branches/try2/src/libextra/base64.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ impl<'a> FromBase64 for &'a str {
237237
}
238238

239239
for (idx, byte) in it {
240-
if (byte as char) != '=' {
241-
return Err(InvalidBase64Character(self.char_at(idx), idx));
240+
match byte as char {
241+
'='|'\r'|'\n' => continue,
242+
_ => return Err(InvalidBase64Character(self.char_at(idx), idx)),
242243
}
243244
}
244245

@@ -310,6 +311,8 @@ mod test {
310311
fn test_from_base64_newlines() {
311312
assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(),
312313
"foobar".as_bytes().to_owned());
314+
assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(),
315+
"foob".as_bytes().to_owned());
313316
}
314317

315318
#[test]

branches/try2/src/libextra/bitv.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,23 @@ impl Bitv {
269269

270270
impl Bitv {
271271
pub fn new(nbits: uint, init: bool) -> Bitv {
272-
let rep = if nbits <= uint::bits {
272+
let rep = if nbits < uint::bits {
273+
Small(SmallBitv::new(if init {(1<<nbits)-1} else {0}))
274+
} else if nbits == uint::bits {
273275
Small(SmallBitv::new(if init {!0} else {0}))
274-
}
275-
else {
276-
let nelems = nbits/uint::bits +
277-
if nbits % uint::bits == 0 {0} else {1};
278-
let elem = if init {!0u} else {0u};
279-
let s = vec::from_elem(nelems, elem);
276+
} else {
277+
let exact = nbits % uint::bits == 0;
278+
let nelems = nbits/uint::bits + if exact {0} else {1};
279+
let s =
280+
if init {
281+
if exact {
282+
vec::from_elem(nelems, !0u)
283+
} else {
284+
let mut v = vec::from_elem(nelems-1, !0u);
285+
v.push((1<<nbits % uint::bits)-1);
286+
v
287+
}
288+
} else { vec::from_elem(nelems, 0u)};
280289
Big(BigBitv::new(s))
281290
};
282291
Bitv {rep: rep, nbits: nbits}
@@ -1329,6 +1338,20 @@ mod tests {
13291338
assert_eq!(idxs, ~[0, 2, 3]);
13301339
}
13311340
1341+
#[test]
1342+
fn test_bitv_set_frombitv_init() {
1343+
let bools = [true, false];
1344+
let lengths = [10, 64, 100];
1345+
for &b in bools.iter() {
1346+
for &l in lengths.iter() {
1347+
let bitset = BitvSet::from_bitv(Bitv::new(l, b));
1348+
assert_eq!(bitset.contains(&1u), b)
1349+
assert_eq!(bitset.contains(&(l-1u)), b)
1350+
assert!(!bitset.contains(&l))
1351+
}
1352+
}
1353+
}
1354+
13321355
#[test]
13331356
fn test_small_difference() {
13341357
let mut b1 = Bitv::new(3, false);

branches/try2/src/libextra/c_vec.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,19 @@ impl <T> Container for CVec<T> {
160160

161161
#[cfg(test)]
162162
mod tests {
163-
164163
use super::*;
165164

166165
use std::libc::*;
167166
use std::libc;
168167
use std::ptr;
168+
use std::rt::global_heap::malloc_raw;
169169

170170
fn malloc(n: uint) -> CVec<u8> {
171171
unsafe {
172-
let mem = libc::malloc(n as size_t);
173-
174-
assert!(mem as int != 0);
172+
let mem = malloc_raw(n);
175173

176174
CVec::new_with_dtor(mem as *mut u8, n,
177-
proc() { libc::free(mem); })
175+
proc() { libc::free(mem as *c_void); })
178176
}
179177
}
180178

0 commit comments

Comments
 (0)