Fixing more doc tests
This commit is contained in:
parent
316345610a
commit
f9b231cd08
6 changed files with 12 additions and 6 deletions
|
@ -132,7 +132,7 @@ specifiers that can be used to dictate how a code block is tested:
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
Rustdoc also supplies some extra sugar for helping with some tedious
|
Rustdoc also supplies some extra sugar for helping with some tedious
|
||||||
documentation examples. If a line os prefixed with a `#` character, then the
|
documentation examples. If a line is prefixed with a `#` character, then the
|
||||||
line will not show up in the HTML documentation, but it will be used when
|
line will not show up in the HTML documentation, but it will be used when
|
||||||
testing the code block.
|
testing the code block.
|
||||||
|
|
||||||
|
|
|
@ -516,7 +516,7 @@ impl MatchOptions {
|
||||||
*
|
*
|
||||||
* This function always returns this value:
|
* This function always returns this value:
|
||||||
*
|
*
|
||||||
* ```rust,notest
|
* ```rust,ignore
|
||||||
* MatchOptions {
|
* MatchOptions {
|
||||||
* case_sensitive: true,
|
* case_sensitive: true,
|
||||||
* require_literal_separator: false.
|
* require_literal_separator: false.
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
//!
|
//!
|
||||||
//! # Example
|
//! # Example
|
||||||
//!
|
//!
|
||||||
//! ```rust,notest
|
//! ```rust,ignore
|
||||||
//! let (mut p1, c1) = Chan::new();
|
//! let (mut p1, c1) = Chan::new();
|
||||||
//! let (mut p2, c2) = Chan::new();
|
//! let (mut p2, c2) = Chan::new();
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -222,7 +222,7 @@ fn main() {
|
||||||
There are a number of related macros in the `format!` family. The ones that are
|
There are a number of related macros in the `format!` family. The ones that are
|
||||||
currently implemented are:
|
currently implemented are:
|
||||||
|
|
||||||
```rust,notest
|
```rust,ignore
|
||||||
format! // described above
|
format! // described above
|
||||||
write! // first argument is a &mut io::Writer, the destination
|
write! // first argument is a &mut io::Writer, the destination
|
||||||
writeln! // same as write but appends a newline
|
writeln! // same as write but appends a newline
|
||||||
|
|
|
@ -29,6 +29,7 @@ Some examples of obvious things you might want to do
|
||||||
use std::io::buffered::BufferedReader;
|
use std::io::buffered::BufferedReader;
|
||||||
use std::io::stdin;
|
use std::io::stdin;
|
||||||
|
|
||||||
|
# let _g = ::std::io::ignore_io_error();
|
||||||
let mut stdin = BufferedReader::new(stdin());
|
let mut stdin = BufferedReader::new(stdin());
|
||||||
for line in stdin.lines() {
|
for line in stdin.lines() {
|
||||||
print(line);
|
print(line);
|
||||||
|
@ -40,6 +41,7 @@ Some examples of obvious things you might want to do
|
||||||
```rust
|
```rust
|
||||||
use std::io::File;
|
use std::io::File;
|
||||||
|
|
||||||
|
# let _g = ::std::io::ignore_io_error();
|
||||||
let contents = File::open(&Path::new("message.txt")).read_to_end();
|
let contents = File::open(&Path::new("message.txt")).read_to_end();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -48,6 +50,7 @@ Some examples of obvious things you might want to do
|
||||||
```rust
|
```rust
|
||||||
use std::io::File;
|
use std::io::File;
|
||||||
|
|
||||||
|
# let _g = ::std::io::ignore_io_error();
|
||||||
let mut file = File::create(&Path::new("message.txt"));
|
let mut file = File::create(&Path::new("message.txt"));
|
||||||
file.write(bytes!("hello, file!\n"));
|
file.write(bytes!("hello, file!\n"));
|
||||||
```
|
```
|
||||||
|
@ -58,6 +61,7 @@ Some examples of obvious things you might want to do
|
||||||
use std::io::buffered::BufferedReader;
|
use std::io::buffered::BufferedReader;
|
||||||
use std::io::File;
|
use std::io::File;
|
||||||
|
|
||||||
|
# let _g = ::std::io::ignore_io_error();
|
||||||
let path = Path::new("message.txt");
|
let path = Path::new("message.txt");
|
||||||
let mut file = BufferedReader::new(File::open(&path));
|
let mut file = BufferedReader::new(File::open(&path));
|
||||||
for line in file.lines() {
|
for line in file.lines() {
|
||||||
|
@ -71,6 +75,7 @@ Some examples of obvious things you might want to do
|
||||||
use std::io::buffered::BufferedReader;
|
use std::io::buffered::BufferedReader;
|
||||||
use std::io::File;
|
use std::io::File;
|
||||||
|
|
||||||
|
# let _g = ::std::io::ignore_io_error();
|
||||||
let path = Path::new("message.txt");
|
let path = Path::new("message.txt");
|
||||||
let mut file = BufferedReader::new(File::open(&path));
|
let mut file = BufferedReader::new(File::open(&path));
|
||||||
let lines: ~[~str] = file.lines().collect();
|
let lines: ~[~str] = file.lines().collect();
|
||||||
|
@ -80,10 +85,11 @@ Some examples of obvious things you might want to do
|
||||||
XXX This needs more improvement: TcpStream constructor taking &str,
|
XXX This needs more improvement: TcpStream constructor taking &str,
|
||||||
`write_str` and `write_line` methods.
|
`write_str` and `write_line` methods.
|
||||||
|
|
||||||
```rust,ignore
|
```rust,should_fail
|
||||||
use std::io::net::ip::SocketAddr;
|
use std::io::net::ip::SocketAddr;
|
||||||
use std::io::net::tcp::TcpStream;
|
use std::io::net::tcp::TcpStream;
|
||||||
|
|
||||||
|
# let _g = ::std::io::ignore_io_error();
|
||||||
let addr = from_str::<SocketAddr>("127.0.0.1:8080").unwrap();
|
let addr = from_str::<SocketAddr>("127.0.0.1:8080").unwrap();
|
||||||
let mut socket = TcpStream::connect(addr).unwrap();
|
let mut socket = TcpStream::connect(addr).unwrap();
|
||||||
socket.write(bytes!("GET / HTTP/1.0\n\n"));
|
socket.write(bytes!("GET / HTTP/1.0\n\n"));
|
||||||
|
|
|
@ -78,7 +78,7 @@ error,hello=warn // turn on global error logging and also warn for hello
|
||||||
|
|
||||||
Each of these macros will expand to code similar to:
|
Each of these macros will expand to code similar to:
|
||||||
|
|
||||||
```rust,notest
|
```rust,ignore
|
||||||
if log_level <= my_module_log_level() {
|
if log_level <= my_module_log_level() {
|
||||||
::std::logging::log(log_level, format!(...));
|
::std::logging::log(log_level, format!(...));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue