Skip to content

Commit 9097410

Browse files
committed
Fix tutorial tests
1 parent 0ddae5e commit 9097410

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

doc/tutorial.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ This code creates a closure that adds a given string to its argument,
13301330
returns it from a function, and then calls it:
13311331

13321332
~~~~
1333-
use std;
1333+
extern mod std;
13341334
13351335
fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str {
13361336
return fn@(s: ~str) -> ~str { s + suffix };
@@ -1680,9 +1680,10 @@ content to the `poultry` module itself.
16801680

16811681
## Using other crates
16821682

1683-
Having compiled a crate that contains the `#[crate_type = "lib"]` attribute,
1684-
you can use it in another crate with a `use` directive. We've already seen
1685-
`use std` in several of the examples, which loads in the [standard library][std].
1683+
Having compiled a crate that contains the `#[crate_type = "lib"]`
1684+
attribute, you can use it in another crate with a `use`
1685+
directive. We've already seen `extern mod std` in several of the
1686+
examples, which loads in the [standard library][std].
16861687

16871688
[std]: http://doc.rust-lang.org/doc/std/index/General.html
16881689

@@ -1738,7 +1739,7 @@ fn world() -> ~str { ~"world" }
17381739

17391740
~~~~ {.ignore}
17401741
// main.rs
1741-
use std;
1742+
extern mod std;
17421743
use mylib;
17431744
fn main() { io::println(~"hello " + mylib::world()); }
17441745
~~~~
@@ -2254,7 +2255,7 @@ Tests can be interspersed with other code, and annotated with the
22542255
~~~~{.xfail-test}
22552256
# // FIXME: xfailed because test_twice is a #[test] function it's not
22562257
# // getting compiled
2257-
use std;
2258+
extern mod std;
22582259
22592260
fn twice(x: int) -> int { x + x }
22602261
@@ -2302,7 +2303,7 @@ To indicate that a test is supposed to fail instead of pass, you can
23022303
give it a `#[should_fail]` attribute.
23032304

23042305
~~~~
2305-
use std;
2306+
extern mod std;
23062307
23072308
fn divide(a: float, b: float) -> float {
23082309
if b == 0f { fail; }

src/etc/extract-tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
if not ignore:
5252
if not re.search(r"\bfn main\b", block):
5353
block = "fn main() {\n" + block + "\n}\n"
54-
if not re.search(r"\buse std\b", block):
55-
block = "use std;\n" + block;
54+
if not re.search(r"\bextern mod std\b", block):
55+
block = "extern mod std;\n" + block;
5656
if xfail:
5757
block = "// xfail-test\n" + block
5858
filename = (dest + "/" + str(chapter)

0 commit comments

Comments
 (0)