Skip to content

Commit 8404ea0

Browse files
committed
doc: Fix more language ref tests
1 parent cfcbec3 commit 8404ea0

File tree

1 file changed

+37
-41
lines changed

1 file changed

+37
-41
lines changed

doc/rust.md

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ native mod kernel32 { }
13281328
The `link_name` attribute allows the default library naming behavior to
13291329
be overriden by explicitly specifying the name of the library.
13301330

1331-
~~~
1331+
~~~{.xfail-test}
13321332
#[link_name = "crypto"]
13331333
native mod mycrypto { }
13341334
~~~
@@ -2714,11 +2714,11 @@ order specified by the tuple type.
27142714

27152715
An example of a tuple type and its use:
27162716

2717-
~~~~{.xfail-test}
2717+
~~~~
27182718
type pair = (int,str);
27192719
let p: pair = (10,"hello");
27202720
let (a, b) = p;
2721-
assert (b == "world");
2721+
assert b != "world";
27222722
~~~~
27232723

27242724
### Vector types
@@ -2741,8 +2741,8 @@ behaviour supports idiomatic in-place "growth" of a mutable slot holding a
27412741
vector:
27422742

27432743

2744-
~~~~{.xfail-test}
2745-
let v: mutable [int] = [1, 2, 3];
2744+
~~~~
2745+
let mut v: [int] = [1, 2, 3];
27462746
v += [4, 5, 6];
27472747
~~~~
27482748

@@ -2796,12 +2796,12 @@ consists of a sequence of input slots, an optional set of
27962796

27972797
An example of a `fn` type:
27982798

2799-
~~~~~~~~{.xfail-test}
2799+
~~~~~~~~
28002800
fn add(x: int, y: int) -> int {
28012801
ret x + y;
28022802
}
28032803
2804-
let int x = add(5,7);
2804+
let x = add(5,7);
28052805
28062806
type binop = fn(int,int) -> int;
28072807
let bo: binop = add;
@@ -2879,9 +2879,11 @@ has a set of points before and after it in the implied control flow.
28792879

28802880
For example, this code:
28812881

2882-
~~~~~~~~{.xfail-test}
2883-
s = "hello, world";
2884-
print(s);
2882+
~~~~~~~~
2883+
# let s;
2884+
2885+
s = "hello, world";
2886+
io::println(s);
28852887
~~~~~~~~
28862888

28872889
Consists of 2 statements, 3 expressions and 12 points:
@@ -2904,8 +2906,11 @@ Consists of 2 statements, 3 expressions and 12 points:
29042906
Whereas this code:
29052907

29062908

2907-
~~~~~~~~{.xfail-test}
2908-
print(x() + y());
2909+
~~~~~~~~
2910+
# fn x() -> str { "" }
2911+
# fn y() -> str { "" }
2912+
2913+
io::println(x() + y());
29092914
~~~~~~~~
29102915

29112916
Consists of 1 statement, 7 expressions and 14 points:
@@ -3200,19 +3205,12 @@ let x: @int = @10;
32003205
let x: ~int = ~10;
32013206
~~~~~~~~
32023207

3203-
Some operations implicitly dereference boxes. Examples of such @dfn{implicit
3204-
dereference} operations are:
3205-
3206-
* arithmetic operators (`x + y - z`)
3207-
* field selection (`x.y.z`)
3208-
3209-
3210-
An example of an implicit-dereference operation performed on box values:
3208+
Some operations (such as field selection) implicitly dereference boxes. An
3209+
example of an @dfn{implicit dereference} operation performed on box values:
32113210

3212-
~~~~~~~~{.xfail-test}
3213-
let x: @int = @10;
3214-
let y: @int = @12;
3215-
assert (x + y == 22);
3211+
~~~~~~~~
3212+
let x = @{y: 10};
3213+
assert x.y == 10;
32163214
~~~~~~~~
32173215

32183216
Other operations act on box values as single-word-sized address values. For
@@ -3383,20 +3381,17 @@ The result of a `spawn` call is a `core::task::task` value.
33833381

33843382
An example of a `spawn` call:
33853383

3386-
~~~~{.xfail-test}
3387-
import task::*;
3388-
import comm::*;
3389-
3390-
let p = port();
3391-
let c = chan(p);
3384+
~~~~
3385+
let po = comm::port();
3386+
let ch = comm::chan(po);
33923387
3393-
spawn {||
3388+
task::spawn {||
33943389
// let task run, do other things
33953390
// ...
3396-
send(c, true);
3391+
comm::send(ch, true);
33973392
};
33983393
3399-
let result = recv(p);
3394+
let result = comm::recv(po);
34003395
~~~~
34013396

34023397

@@ -3408,10 +3403,10 @@ channel's outgoing buffer.
34083403

34093404
An example of a send:
34103405

3411-
~~~~{.xfail-test}
3412-
import comm::*;
3413-
let c: chan<str> = ...;
3414-
send(c, "hello, world");
3406+
~~~~
3407+
let po = comm::port();
3408+
let ch = comm::chan(po);
3409+
comm::send(ch, "hello, world");
34153410
~~~~
34163411

34173412

@@ -3424,10 +3419,11 @@ time the port deques a value to return, and un-blocks the receiving task.
34243419

34253420
An example of a *receive*:
34263421

3427-
~~~~~~~~{.xfail-test}
3428-
import comm::*;
3429-
let p: port<str> = ...;
3430-
let s = recv(p);
3422+
~~~~~~~~
3423+
# let po = comm::port();
3424+
# let ch = comm::chan(po);
3425+
# comm::send(ch, "");
3426+
let s = comm::recv(po);
34313427
~~~~~~~~
34323428

34333429

0 commit comments

Comments
 (0)