test: Begin running the language ref examples. Mostly xfailed
This commit is contained in:
parent
a0cbf638ee
commit
57281f52e5
4 changed files with 99 additions and 62 deletions
1
configure
vendored
1
configure
vendored
|
@ -476,6 +476,7 @@ do
|
||||||
make_dir $h/test/perf
|
make_dir $h/test/perf
|
||||||
make_dir $h/test/pretty
|
make_dir $h/test/pretty
|
||||||
make_dir $h/test/doc-tutorial
|
make_dir $h/test/doc-tutorial
|
||||||
|
make_dir $h/test/doc-ref
|
||||||
done
|
done
|
||||||
|
|
||||||
# Configure submodules
|
# Configure submodules
|
||||||
|
|
122
doc/rust.md
122
doc/rust.md
|
@ -424,7 +424,7 @@ across crates; an item's canonical path merely identifies it within the crate.
|
||||||
|
|
||||||
Two examples of simple paths consisting of only identifier components:
|
Two examples of simple paths consisting of only identifier components:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
x;
|
x;
|
||||||
x::y::z;
|
x::y::z;
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -438,7 +438,7 @@ expression context, the final namespace qualifier is omitted.
|
||||||
|
|
||||||
Two examples of paths with type arguments:
|
Two examples of paths with type arguments:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
type t = map::hashtbl<int,str>; // Type arguments used in a type expression
|
type t = map::hashtbl<int,str>; // Type arguments used in a type expression
|
||||||
let x = id::<int>(10); // Type arguments used in a call expression
|
let x = id::<int>(10); // Type arguments used in a call expression
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -506,7 +506,7 @@ or a *configuration* in Mesa.] A crate file describes:
|
||||||
|
|
||||||
An example of a crate file:
|
An example of a crate file:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
// Linkage attributes
|
// Linkage attributes
|
||||||
#[ link(name = "projx"
|
#[ link(name = "projx"
|
||||||
vers = "2.5",
|
vers = "2.5",
|
||||||
|
@ -627,7 +627,7 @@ of modules making up a crate. Modules can nest arbitrarily.
|
||||||
|
|
||||||
An example of a module:
|
An example of a module:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
mod math {
|
mod math {
|
||||||
type complex = (f64,f64);
|
type complex = (f64,f64);
|
||||||
fn sin(f64) -> f64 {
|
fn sin(f64) -> f64 {
|
||||||
|
@ -680,7 +680,7 @@ attribute is assumed, equal to the `ident` given in the `use_decl`.
|
||||||
|
|
||||||
Two examples of `use` declarations:
|
Two examples of `use` declarations:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
use pcre (uuid = "54aba0f8-a7b1-4beb-92f1-4cf625264841");
|
use pcre (uuid = "54aba0f8-a7b1-4beb-92f1-4cf625264841");
|
||||||
|
|
||||||
use std; // equivalent to: use std ( name = "std" );
|
use std; // equivalent to: use std ( name = "std" );
|
||||||
|
@ -718,7 +718,7 @@ Imports support a number of "convenience" notations:
|
||||||
|
|
||||||
An example of imports:
|
An example of imports:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
import foo = core::info;
|
import foo = core::info;
|
||||||
import std::math::sin;
|
import std::math::sin;
|
||||||
import std::str::{char_at, hash};
|
import std::str::{char_at, hash};
|
||||||
|
@ -753,7 +753,7 @@ declaration replaces the default export with the export specified.
|
||||||
|
|
||||||
An example of an export:
|
An example of an export:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
mod foo {
|
mod foo {
|
||||||
export primary;
|
export primary;
|
||||||
|
|
||||||
|
@ -775,7 +775,7 @@ fn main() {
|
||||||
|
|
||||||
Multiple names may be exported from a single export declaration:
|
Multiple names may be exported from a single export declaration:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
mod foo {
|
mod foo {
|
||||||
export primary, secondary;
|
export primary, secondary;
|
||||||
|
|
||||||
|
@ -797,7 +797,7 @@ mod foo {
|
||||||
When exporting the name of an `enum` type `t`, by default, the module also
|
When exporting the name of an `enum` type `t`, by default, the module also
|
||||||
implicitly exports all of `t`'s constructors. For example:
|
implicitly exports all of `t`'s constructors. For example:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
mod foo {
|
mod foo {
|
||||||
export t;
|
export t;
|
||||||
|
|
||||||
|
@ -815,7 +815,7 @@ constructors, achieving a simple kind of data abstraction. The third
|
||||||
form exports an `enum` type name along with a subset of its
|
form exports an `enum` type name along with a subset of its
|
||||||
constructors. For example:
|
constructors. For example:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
mod foo {
|
mod foo {
|
||||||
export abstract{};
|
export abstract{};
|
||||||
export slightly_abstract{a, b};
|
export slightly_abstract{a, b};
|
||||||
|
@ -883,7 +883,7 @@ with a [`ret`](#return-expressions) or diverging expression. So, if `my_err`
|
||||||
were declared without the `!` annotation, the following code would not
|
were declared without the `!` annotation, the following code would not
|
||||||
typecheck:
|
typecheck:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn f(i: int) -> int {
|
fn f(i: int) -> int {
|
||||||
if i == 42 {
|
if i == 42 {
|
||||||
ret 42;
|
ret 42;
|
||||||
|
@ -923,7 +923,7 @@ pure fn lt_42(x: int) -> bool {
|
||||||
A non-boolean function may also be declared with `pure fn`. This allows
|
A non-boolean function may also be declared with `pure fn`. This allows
|
||||||
predicates to call non-boolean functions as long as they are pure. For example:
|
predicates to call non-boolean functions as long as they are pure. For example:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
pure fn pure_length<T>(ls: list<T>) -> uint { /* ... */ }
|
pure fn pure_length<T>(ls: list<T>) -> uint { /* ... */ }
|
||||||
|
|
||||||
pure fn nonempty_list<T>(ls: list<T>) -> bool { pure_length(ls) > 0u }
|
pure fn nonempty_list<T>(ls: list<T>) -> bool { pure_length(ls) > 0u }
|
||||||
|
@ -953,7 +953,7 @@ verify the semantics of the predicates they write.
|
||||||
|
|
||||||
An example of a predicate that uses an unchecked block:
|
An example of a predicate that uses an unchecked block:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn pure_foldl<T, U: copy>(ls: list<T>, u: U, f: block(&T, &U) -> U) -> U {
|
fn pure_foldl<T, U: copy>(ls: list<T>, u: U, f: block(&T, &U) -> U) -> U {
|
||||||
alt ls {
|
alt ls {
|
||||||
nil. { u }
|
nil. { u }
|
||||||
|
@ -982,7 +982,7 @@ appear in its signature. Each type parameter must be explicitly
|
||||||
declared, in an angle-bracket-enclosed, comma-separated list following
|
declared, in an angle-bracket-enclosed, comma-separated list following
|
||||||
the function name.
|
the function name.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn iter<T>(seq: [T], f: block(T)) {
|
fn iter<T>(seq: [T], f: block(T)) {
|
||||||
for elt: T in seq { f(elt); }
|
for elt: T in seq { f(elt); }
|
||||||
}
|
}
|
||||||
|
@ -1031,7 +1031,7 @@ crust fn new_vec() -> [int] { [] }
|
||||||
Crust functions may not be called from Rust code, but their value
|
Crust functions may not be called from Rust code, but their value
|
||||||
may be taken as an unsafe `u8` pointer.
|
may be taken as an unsafe `u8` pointer.
|
||||||
|
|
||||||
~~~
|
~~~{.xfail-test}
|
||||||
let fptr: *u8 = new_vec;
|
let fptr: *u8 = new_vec;
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
@ -1081,7 +1081,7 @@ type the constructor is a member of. Such recursion has restrictions:
|
||||||
|
|
||||||
An example of an `enum` item and its use:
|
An example of an `enum` item and its use:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
enum animal {
|
enum animal {
|
||||||
dog;
|
dog;
|
||||||
cat;
|
cat;
|
||||||
|
@ -1093,7 +1093,7 @@ a = cat;
|
||||||
|
|
||||||
An example of a *recursive* `enum` item and its use:
|
An example of a *recursive* `enum` item and its use:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
enum list<T> {
|
enum list<T> {
|
||||||
nil;
|
nil;
|
||||||
cons(T, @list<T>);
|
cons(T, @list<T>);
|
||||||
|
@ -1107,7 +1107,7 @@ let a: list<int> = cons(7, @cons(13, @nil));
|
||||||
_Resources_ are values that have a destructor associated with them. A
|
_Resources_ are values that have a destructor associated with them. A
|
||||||
_resource item_ is used to declare resource type and constructor.
|
_resource item_ is used to declare resource type and constructor.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
resource file_descriptor(fd: int) {
|
resource file_descriptor(fd: int) {
|
||||||
std::os::libc::close(fd);
|
std::os::libc::close(fd);
|
||||||
}
|
}
|
||||||
|
@ -1133,7 +1133,7 @@ An _interface item_ describes a set of method types. _[implementation
|
||||||
items](#implementations)_ can be used to provide implementations of
|
items](#implementations)_ can be used to provide implementations of
|
||||||
those methods for a specific type.
|
those methods for a specific type.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
iface shape {
|
iface shape {
|
||||||
fn draw(surface);
|
fn draw(surface);
|
||||||
fn bounding_box() -> bounding_box;
|
fn bounding_box() -> bounding_box;
|
||||||
|
@ -1149,7 +1149,7 @@ Type parameters can be specified for an interface to make it generic.
|
||||||
These appear after the name, using the same syntax used in [generic
|
These appear after the name, using the same syntax used in [generic
|
||||||
functions](#generic-functions).
|
functions](#generic-functions).
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
iface seq<T> {
|
iface seq<T> {
|
||||||
fn len() -> uint;
|
fn len() -> uint;
|
||||||
fn elt_at(n: uint) -> T;
|
fn elt_at(n: uint) -> T;
|
||||||
|
@ -1163,7 +1163,7 @@ interface can be used to instantiate the parameter, and within the
|
||||||
generic function, the methods of the interface can be called on values
|
generic function, the methods of the interface can be called on values
|
||||||
that have the parameter's type. For example:
|
that have the parameter's type. For example:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn draw_twice<T: shape>(surface: surface, sh: T) {
|
fn draw_twice<T: shape>(surface: surface, sh: T) {
|
||||||
sh.draw(surface);
|
sh.draw(surface);
|
||||||
sh.draw(surface);
|
sh.draw(surface);
|
||||||
|
@ -1176,7 +1176,7 @@ interface. Values of this type are created by
|
||||||
implementation of the given interface is in scope) to the interface
|
implementation of the given interface is in scope) to the interface
|
||||||
type.
|
type.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
let myshape: shape = mycircle as shape;
|
let myshape: shape = mycircle as shape;
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
|
@ -1191,7 +1191,7 @@ instantiate type parameters that are bounded on their interface.
|
||||||
An _implementation item_ provides an implementation of an
|
An _implementation item_ provides an implementation of an
|
||||||
[interfaces](#interfaces) for a type.
|
[interfaces](#interfaces) for a type.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
type circle = {radius: float, center: point};
|
type circle = {radius: float, center: point};
|
||||||
|
|
||||||
impl circle_shape of shape for circle {
|
impl circle_shape of shape for circle {
|
||||||
|
@ -1218,7 +1218,7 @@ statically (as direct calls on the values of the type that the
|
||||||
implementation targets). In such an implementation, the `of` clause is
|
implementation targets). In such an implementation, the `of` clause is
|
||||||
not given, and the name is mandatory.
|
not given, and the name is mandatory.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
impl uint_loops for uint {
|
impl uint_loops for uint {
|
||||||
fn times(f: block(uint)) {
|
fn times(f: block(uint)) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
@ -1236,7 +1236,7 @@ from the type parameters taken by the interface it implements. They
|
||||||
are written after the name of the implementation, or if that is not
|
are written after the name of the implementation, or if that is not
|
||||||
specified, after the `impl` keyword.
|
specified, after the `impl` keyword.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
impl <T> of seq<T> for [T] {
|
impl <T> of seq<T> for [T] {
|
||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
|
@ -1257,7 +1257,7 @@ module describes functions in external, non-Rust libraries. Functions within
|
||||||
native modules are declared the same as other Rust functions, with the exception
|
native modules are declared the same as other Rust functions, with the exception
|
||||||
that they may not have a body and are instead terminated by a semi-colon.
|
that they may not have a body and are instead terminated by a semi-colon.
|
||||||
|
|
||||||
~~~
|
~~~{.xfail-test}
|
||||||
native mod c {
|
native mod c {
|
||||||
fn fopen(filename: *c_char, mod: *c_char) -> *FILE;
|
fn fopen(filename: *c_char, mod: *c_char) -> *FILE;
|
||||||
}
|
}
|
||||||
|
@ -1281,7 +1281,7 @@ By default native mods assume that the library they are calling use
|
||||||
the standard C "cdecl" ABI. Other ABI's may be specified using the `abi`
|
the standard C "cdecl" ABI. Other ABI's may be specified using the `abi`
|
||||||
attribute as in
|
attribute as in
|
||||||
|
|
||||||
~~~
|
~~~{.xfail-test}
|
||||||
// Interface to the Windows API
|
// Interface to the Windows API
|
||||||
#[abi = "stdcall"]
|
#[abi = "stdcall"]
|
||||||
native mod kernel32 { }
|
native mod kernel32 { }
|
||||||
|
@ -1325,7 +1325,7 @@ declaration within the entity body.
|
||||||
|
|
||||||
An example of attributes:
|
An example of attributes:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
// A function marked as a unit test
|
// A function marked as a unit test
|
||||||
#[test]
|
#[test]
|
||||||
fn test_foo() {
|
fn test_foo() {
|
||||||
|
@ -1475,7 +1475,7 @@ values.
|
||||||
|
|
||||||
~~~~~~~~ {.tuple}
|
~~~~~~~~ {.tuple}
|
||||||
(0f, 4.5f);
|
(0f, 4.5f);
|
||||||
("a", 4u, true)
|
("a", 4u, true);
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
### Record expressions
|
### Record expressions
|
||||||
|
@ -1578,7 +1578,7 @@ Indices are zero-based, and may be of any integral type. Vector access
|
||||||
is bounds-checked at run-time. When the check fails, it will put the
|
is bounds-checked at run-time. When the check fails, it will put the
|
||||||
task in a _failing state_.
|
task in a _failing state_.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
[1, 2, 3, 4][0];
|
[1, 2, 3, 4][0];
|
||||||
[mutable 'x', 'y'][1] = 'z';
|
[mutable 'x', 'y'][1] = 'z';
|
||||||
["a", "b"][10]; // fails
|
["a", "b"][10]; // fails
|
||||||
|
@ -1696,7 +1696,7 @@ is unsupported and will fail to compile.
|
||||||
|
|
||||||
An example of an `as` expression:
|
An example of an `as` expression:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn avg(v: [float]) -> float {
|
fn avg(v: [float]) -> float {
|
||||||
let sum: float = sum(v);
|
let sum: float = sum(v);
|
||||||
let sz: float = std::vec::len(v) as float;
|
let sz: float = std::vec::len(v) as float;
|
||||||
|
@ -1727,7 +1727,7 @@ expression. No allocation or destruction is entailed.
|
||||||
|
|
||||||
An example of three different move expressions:
|
An example of three different move expressions:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
x <- a;
|
x <- a;
|
||||||
x[i] <- b;
|
x[i] <- b;
|
||||||
x.y <- c;
|
x.y <- c;
|
||||||
|
@ -1749,7 +1749,7 @@ expression. No allocation or destruction is entailed.
|
||||||
|
|
||||||
An example of three different swap expressions:
|
An example of three different swap expressions:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
x <-> a;
|
x <-> a;
|
||||||
x[i] <-> b[i];
|
x[i] <-> b[i];
|
||||||
x.y <-> a.b;
|
x.y <-> a.b;
|
||||||
|
@ -1766,7 +1766,7 @@ expression](#binary-move-expressions) applied to a [unary copy
|
||||||
expression](#unary-copy-expressions). For example, the following two
|
expression](#unary-copy-expressions). For example, the following two
|
||||||
expressions have the same effect:
|
expressions have the same effect:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
x = y
|
x = y
|
||||||
x <- copy y
|
x <- copy y
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -1871,7 +1871,7 @@ typestates propagate through function boundaries.
|
||||||
|
|
||||||
An example of a call expression:
|
An example of a call expression:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
let x: int = add(1, 2);
|
let x: int = add(1, 2);
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
|
@ -1894,7 +1894,7 @@ and residual arguments that was specified during the binding.
|
||||||
|
|
||||||
An example of a `bind` expression:
|
An example of a `bind` expression:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn add(x: int, y: int) -> int {
|
fn add(x: int, y: int) -> int {
|
||||||
ret x + y;
|
ret x + y;
|
||||||
}
|
}
|
||||||
|
@ -1949,7 +1949,7 @@ loop body. If it evaluates to `false`, control exits the loop.
|
||||||
|
|
||||||
An example of a simple `while` expression:
|
An example of a simple `while` expression:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
while i < 10 {
|
while i < 10 {
|
||||||
print("hello\n");
|
print("hello\n");
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
|
@ -1958,7 +1958,7 @@ while i < 10 {
|
||||||
|
|
||||||
An example of a `do`-`while` expression:
|
An example of a `do`-`while` expression:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
do {
|
do {
|
||||||
print("hello\n");
|
print("hello\n");
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
|
@ -2035,7 +2035,7 @@ elements of the underlying sequence, one iteration per sequence element.
|
||||||
|
|
||||||
An example a for loop:
|
An example a for loop:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
let v: [foo] = [a, b, c];
|
let v: [foo] = [a, b, c];
|
||||||
|
|
||||||
for e: foo in v {
|
for e: foo in v {
|
||||||
|
@ -2093,7 +2093,7 @@ variables in the arm's block, and control enters the block.
|
||||||
An example of an `alt` expression:
|
An example of an `alt` expression:
|
||||||
|
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
enum list<X> { nil; cons(X, @list<X>); }
|
enum list<X> { nil; cons(X, @list<X>); }
|
||||||
|
|
||||||
let x: list<int> = cons(10, @cons(11, @nil));
|
let x: list<int> = cons(10, @cons(11, @nil));
|
||||||
|
@ -2118,7 +2118,7 @@ Records can also be pattern-matched and their fields bound to variables.
|
||||||
When matching fields of a record, the fields being matched are specified
|
When matching fields of a record, the fields being matched are specified
|
||||||
first, then a placeholder (`_`) represents the remaining fields.
|
first, then a placeholder (`_`) represents the remaining fields.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn main() {
|
fn main() {
|
||||||
let r = {
|
let r = {
|
||||||
player: "ralph",
|
player: "ralph",
|
||||||
|
@ -2146,7 +2146,7 @@ fn main() {
|
||||||
Multiple alternative patterns may be joined with the `|` operator. A
|
Multiple alternative patterns may be joined with the `|` operator. A
|
||||||
range of values may be specified with `to`. For example:
|
range of values may be specified with `to`. For example:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
let message = alt x {
|
let message = alt x {
|
||||||
0 | 1 { "not many" }
|
0 | 1 { "not many" }
|
||||||
2 to 9 { "a few" }
|
2 to 9 { "a few" }
|
||||||
|
@ -2159,7 +2159,7 @@ criteria for matching a case. Pattern guards appear after the pattern and
|
||||||
consist of a bool-typed expression following the `if` keyword. A pattern
|
consist of a bool-typed expression following the `if` keyword. A pattern
|
||||||
guard may refer to the variables bound within the pattern they follow.
|
guard may refer to the variables bound within the pattern they follow.
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
let message = alt maybe_digit {
|
let message = alt maybe_digit {
|
||||||
some(x) if x < 10 { process_digit(x) }
|
some(x) if x < 10 { process_digit(x) }
|
||||||
some(x) { process_other(x) }
|
some(x) { process_other(x) }
|
||||||
|
@ -2203,7 +2203,7 @@ the `note` to the internal logging diagnostic buffer.
|
||||||
|
|
||||||
An example of a `note` expression:
|
An example of a `note` expression:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn read_file_lines(path: str) -> [str] {
|
fn read_file_lines(path: str) -> [str] {
|
||||||
note path;
|
note path;
|
||||||
let r: [str];
|
let r: [str];
|
||||||
|
@ -2276,7 +2276,7 @@ syntax-extension.
|
||||||
The following examples all produce the same output, logged at the `error`
|
The following examples all produce the same output, logged at the `error`
|
||||||
logging level:
|
logging level:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
// Full version, logging a value.
|
// Full version, logging a value.
|
||||||
log(core::error, "file not found: " + filename);
|
log(core::error, "file not found: " + filename);
|
||||||
|
|
||||||
|
@ -2327,7 +2327,7 @@ itself. From there, the typestate algorithm can perform dataflow calculations
|
||||||
on subsequent expressions, propagating [conditions](#conditions) forward and
|
on subsequent expressions, propagating [conditions](#conditions) forward and
|
||||||
statically comparing implied states and their specifications.
|
statically comparing implied states and their specifications.
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
pure fn even(x: int) -> bool {
|
pure fn even(x: int) -> bool {
|
||||||
ret x & 1 == 0;
|
ret x & 1 == 0;
|
||||||
}
|
}
|
||||||
|
@ -2392,14 +2392,14 @@ following two examples are equivalent:
|
||||||
|
|
||||||
Example using `check`:
|
Example using `check`:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
check even(x);
|
check even(x);
|
||||||
print_even(x);
|
print_even(x);
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
Equivalent example using `if check`:
|
Equivalent example using `if check`:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
if check even(x) {
|
if check even(x) {
|
||||||
print_even(x);
|
print_even(x);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2455,7 +2455,7 @@ second-class Rust concepts that are present in syntax. The arguments to
|
||||||
`macro` are pairs (two-element vectors). The pairs consist of an invocation
|
`macro` are pairs (two-element vectors). The pairs consist of an invocation
|
||||||
and the syntax to expand into. An example:
|
and the syntax to expand into. An example:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
#macro([#apply[fn, [args, ...]], fn(args, ...)]);
|
#macro([#apply[fn, [args, ...]], fn(args, ...)]);
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
|
@ -2474,7 +2474,7 @@ matched, and where the repeated output must be transcribed. A more
|
||||||
sophisticated example:
|
sophisticated example:
|
||||||
|
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
#macro([#zip_literals[[x, ...], [y, ...]), [[x, y], ...]]);
|
#macro([#zip_literals[[x, ...], [y, ...]), [[x, y], ...]]);
|
||||||
#macro([#unzip_literals[[x, y], ...], [[x, ...], [y, ...]]]);
|
#macro([#unzip_literals[[x, y], ...], [[x, ...], [y, ...]]]);
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
@ -2611,7 +2611,7 @@ order specified by the tuple type.
|
||||||
|
|
||||||
An example of a tuple type and its use:
|
An example of a tuple type and its use:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
type pair = (int,str);
|
type pair = (int,str);
|
||||||
let p: pair = (10,"hello");
|
let p: pair = (10,"hello");
|
||||||
let (a, b) = p;
|
let (a, b) = p;
|
||||||
|
@ -2638,7 +2638,7 @@ behaviour supports idiomatic in-place "growth" of a mutable slot holding a
|
||||||
vector:
|
vector:
|
||||||
|
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
let v: mutable [int] = [1, 2, 3];
|
let v: mutable [int] = [1, 2, 3];
|
||||||
v += [4, 5, 6];
|
v += [4, 5, 6];
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -2693,7 +2693,7 @@ consists of a sequence of input slots, an optional set of
|
||||||
|
|
||||||
An example of a `fn` type:
|
An example of a `fn` type:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
fn add(x: int, y: int) -> int {
|
fn add(x: int, y: int) -> int {
|
||||||
ret x + y;
|
ret x + y;
|
||||||
}
|
}
|
||||||
|
@ -2735,7 +2735,7 @@ that value to be of copyable kind. Type parameter types are assumed to
|
||||||
be noncopyable, unless one of the special bounds `send` or `copy` is
|
be noncopyable, unless one of the special bounds `send` or `copy` is
|
||||||
declared for it. For example, this is not a valid program:
|
declared for it. For example, this is not a valid program:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
fn box<T>(x: T) -> @T { @x }
|
fn box<T>(x: T) -> @T { @x }
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
|
@ -2776,7 +2776,7 @@ has a set of points before and after it in the implied control flow.
|
||||||
|
|
||||||
For example, this code:
|
For example, this code:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
s = "hello, world";
|
s = "hello, world";
|
||||||
print(s);
|
print(s);
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
@ -2801,8 +2801,8 @@ Consists of 2 statements, 3 expressions and 12 points:
|
||||||
Whereas this code:
|
Whereas this code:
|
||||||
|
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
print(x() + y());
|
print(x() + y());
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
Consists of 1 statement, 7 expressions and 14 points:
|
Consists of 1 statement, 7 expressions and 14 points:
|
||||||
|
@ -3106,7 +3106,7 @@ dereference} operations are:
|
||||||
|
|
||||||
An example of an implicit-dereference operation performed on box values:
|
An example of an implicit-dereference operation performed on box values:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
let x: @int = @10;
|
let x: @int = @10;
|
||||||
let y: @int = @12;
|
let y: @int = @12;
|
||||||
assert (x + y == 22);
|
assert (x + y == 22);
|
||||||
|
@ -3280,7 +3280,7 @@ The result of a `spawn` call is a `core::task::task` value.
|
||||||
|
|
||||||
An example of a `spawn` call:
|
An example of a `spawn` call:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
import task::*;
|
import task::*;
|
||||||
import comm::*;
|
import comm::*;
|
||||||
|
|
||||||
|
@ -3305,7 +3305,7 @@ channel's outgoing buffer.
|
||||||
|
|
||||||
An example of a send:
|
An example of a send:
|
||||||
|
|
||||||
~~~~
|
~~~~{.xfail-test}
|
||||||
import comm::*;
|
import comm::*;
|
||||||
let c: chan<str> = ...;
|
let c: chan<str> = ...;
|
||||||
send(c, "hello, world");
|
send(c, "hello, world");
|
||||||
|
@ -3321,7 +3321,7 @@ time the port deques a value to return, and un-blocks the receiving task.
|
||||||
|
|
||||||
An example of a *receive*:
|
An example of a *receive*:
|
||||||
|
|
||||||
~~~~~~~~
|
~~~~~~~~{.xfail-test}
|
||||||
import comm::*;
|
import comm::*;
|
||||||
let p: port<str> = ...;
|
let p: port<str> = ...;
|
||||||
let s = recv(p);
|
let s = recv(p);
|
||||||
|
|
32
mk/tests.mk
32
mk/tests.mk
|
@ -113,6 +113,11 @@ doc-tutorial-extract$(1):
|
||||||
$$(Q)rm -f $(1)/test/doc-tutorial/*.rs
|
$$(Q)rm -f $(1)/test/doc-tutorial/*.rs
|
||||||
$$(Q)$$(EXTRACT_TESTS) $$(S)doc/tutorial.md $(1)/test/doc-tutorial
|
$$(Q)$$(EXTRACT_TESTS) $$(S)doc/tutorial.md $(1)/test/doc-tutorial
|
||||||
|
|
||||||
|
doc-ref-extract$(1):
|
||||||
|
@$$(call E, extract: ref tests)
|
||||||
|
$$(Q)rm -f $(1)/test/doc-ref/*.rs
|
||||||
|
$$(Q)$$(EXTRACT_TESTS) $$(S)doc/rust.md $(1)/test/doc-ref
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach host,$(CFG_TARGET_TRIPLES), \
|
$(foreach host,$(CFG_TARGET_TRIPLES), \
|
||||||
|
@ -141,7 +146,8 @@ check-stage$(1)-T-$(2)-H-$(3): tidy \
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-bench \
|
check-stage$(1)-T-$(2)-H-$(3)-bench \
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-pretty \
|
check-stage$(1)-T-$(2)-H-$(3)-pretty \
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-rustdoc \
|
check-stage$(1)-T-$(2)-H-$(3)-rustdoc \
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-doc-tutorial
|
check-stage$(1)-T-$(2)-H-$(3)-doc-tutorial \
|
||||||
|
check-stage$(1)-T-$(2)-H-$(3)-doc-ref
|
||||||
|
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-core: \
|
check-stage$(1)-T-$(2)-H-$(3)-core: \
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-core-dummy
|
check-stage$(1)-T-$(2)-H-$(3)-core-dummy
|
||||||
|
@ -191,6 +197,9 @@ check-stage$(1)-T-$(2)-H-$(3)-rustdoc: \
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-doc-tutorial: \
|
check-stage$(1)-T-$(2)-H-$(3)-doc-tutorial: \
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-doc-tutorial-dummy
|
check-stage$(1)-T-$(2)-H-$(3)-doc-tutorial-dummy
|
||||||
|
|
||||||
|
check-stage$(1)-T-$(2)-H-$(3)-doc-ref: \
|
||||||
|
check-stage$(1)-T-$(2)-H-$(3)-doc-ref-dummy
|
||||||
|
|
||||||
# Rules for the core library test runner
|
# Rules for the core library test runner
|
||||||
|
|
||||||
$(3)/test/coretest.stage$(1)-$(2)$$(X): \
|
$(3)/test/coretest.stage$(1)-$(2)$$(X): \
|
||||||
|
@ -323,6 +332,12 @@ DOC_TUTORIAL_ARGS$(1)-T-$(2)-H-$(3) := \
|
||||||
--build-base $(3)/test/doc-tutorial/ \
|
--build-base $(3)/test/doc-tutorial/ \
|
||||||
--mode run-pass
|
--mode run-pass
|
||||||
|
|
||||||
|
DOC_REF_ARGS$(1)-T-$(2)-H-$(3) := \
|
||||||
|
$$(CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3)) \
|
||||||
|
--src-base $(3)/test/doc-ref/ \
|
||||||
|
--build-base $(3)/test/doc-ref/ \
|
||||||
|
--mode run-pass
|
||||||
|
|
||||||
check-stage$(1)-T-$(2)-H-$(3)-cfail-dummy: \
|
check-stage$(1)-T-$(2)-H-$(3)-cfail-dummy: \
|
||||||
$$(HBIN$(1)_H_$(3))/compiletest$$(X) \
|
$$(HBIN$(1)_H_$(3))/compiletest$$(X) \
|
||||||
$$(SREQ$(1)_T_$(2)_H_$(3)) \
|
$$(SREQ$(1)_T_$(2)_H_$(3)) \
|
||||||
|
@ -403,6 +418,14 @@ check-stage$(1)-T-$(2)-H-$(3)-doc-tutorial-dummy: \
|
||||||
$$(Q)$$(call CFG_RUN_CTEST,$(1),$$<,$(3)) \
|
$$(Q)$$(call CFG_RUN_CTEST,$(1),$$<,$(3)) \
|
||||||
$$(DOC_TUTORIAL_ARGS$(1)-T-$(2)-H-$(3))
|
$$(DOC_TUTORIAL_ARGS$(1)-T-$(2)-H-$(3))
|
||||||
|
|
||||||
|
check-stage$(1)-T-$(2)-H-$(3)-doc-ref-dummy: \
|
||||||
|
$$(HBIN$(1)_H_$(3))/compiletest$$(X) \
|
||||||
|
$$(SREQ$(1)_T_$(2)_H_$(3)) \
|
||||||
|
doc-ref-extract$(3)
|
||||||
|
@$$(call E, run doc-ref: $$<)
|
||||||
|
$$(Q)$$(call CFG_RUN_CTEST,$(1),$$<,$(3)) \
|
||||||
|
$$(DOC_REF_ARGS$(1)-T-$(2)-H-$(3))
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# Instantiate the template for stage 0, 1, 2, 3
|
# Instantiate the template for stage 0, 1, 2, 3
|
||||||
|
@ -512,6 +535,9 @@ check-stage$(1)-H-$(2)-rustdoc: \
|
||||||
check-stage$(1)-H-$(2)-doc-tutorial: \
|
check-stage$(1)-H-$(2)-doc-tutorial: \
|
||||||
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
|
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
|
||||||
check-stage$(1)-T-$$(target)-H-$(2)-doc-tutorial)
|
check-stage$(1)-T-$$(target)-H-$(2)-doc-tutorial)
|
||||||
|
check-stage$(1)-H-$(2)-doc-ref: \
|
||||||
|
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
|
||||||
|
check-stage$(1)-T-$$(target)-H-$(2)-doc-ref)
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -578,6 +604,9 @@ check-stage$(1)-H-all-rustdoc: \
|
||||||
check-stage$(1)-H-all-doc-tutorial: \
|
check-stage$(1)-H-all-doc-tutorial: \
|
||||||
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
|
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
|
||||||
check-stage$(1)-H-$$(target)-doc-tutorial)
|
check-stage$(1)-H-$$(target)-doc-tutorial)
|
||||||
|
check-stage$(1)-H-all-doc-ref: \
|
||||||
|
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
|
||||||
|
check-stage$(1)-H-$$(target)-doc-ref)
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -602,6 +631,7 @@ check-stage$(1)-pretty-bench: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-pretty-bench
|
||||||
check-stage$(1)-pretty-pretty: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-pretty-pretty
|
check-stage$(1)-pretty-pretty: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-pretty-pretty
|
||||||
check-stage$(1)-rustdoc: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-rustdoc
|
check-stage$(1)-rustdoc: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-rustdoc
|
||||||
check-stage$(1)-doc-tutorial: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-doc-tutorial
|
check-stage$(1)-doc-tutorial: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-doc-tutorial
|
||||||
|
check-stage$(1)-doc-ref: check-stage$(1)-H-$$(CFG_HOST_TRIPLE)-doc-ref
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,12 @@ while cur < len(lines):
|
||||||
tags = re.findall("\.([\w-]*)", line)
|
tags = re.findall("\.([\w-]*)", line)
|
||||||
block = ""
|
block = ""
|
||||||
ignore = "notrust" in tags or "ignore" in tags
|
ignore = "notrust" in tags or "ignore" in tags
|
||||||
|
# Some tags used by the language ref that indicate not rust
|
||||||
|
ignore |= "ebnf" in tags
|
||||||
|
ignore |= "abnf" in tags
|
||||||
|
ignore |= "keyword" in tags
|
||||||
|
ignore |= "field" in tags
|
||||||
|
ignore |= "precedence" in tags
|
||||||
xfail = "xfail-test" in tags
|
xfail = "xfail-test" in tags
|
||||||
while cur < len(lines):
|
while cur < len(lines):
|
||||||
line = lines[cur]
|
line = lines[cur]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue