Skip to content

Commit 1330b1c

Browse files
committed
Add test cases (one xfailed, one not)
as per #3601 and #3609
1 parent 1bc51f1 commit 1330b1c

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/test/compile-fail/issue-3601.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
struct HTMLImageData {
2+
mut image: Option<~str>
3+
}
4+
5+
struct ElementData {
6+
kind: ~ElementKind
7+
}
8+
9+
enum ElementKind {
10+
HTMLImageElement(HTMLImageData)
11+
}
12+
13+
enum NodeKind {
14+
Element(ElementData)
15+
}
16+
17+
enum NodeData = {
18+
kind: ~NodeKind
19+
};
20+
21+
fn main() {
22+
let id = HTMLImageData { image: None };
23+
let ed = ElementData { kind: ~HTMLImageElement(id) };
24+
let n = NodeData({kind : ~Element(ed)});
25+
match n.kind {
26+
~Element(ed) => match ed.kind {
27+
~HTMLImageElement(d) if d.image.is_some() => { true }
28+
},
29+
_ => fail ~"WAT" //~ ERROR wat
30+
};
31+
}

src/test/run-pass/issue-3609.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
extern mod std;
2+
3+
use pipes::Chan;
4+
5+
type RingBuffer = ~[float];
6+
type SamplesFn = fn~ (samples: &RingBuffer);
7+
8+
enum Msg
9+
{
10+
GetSamples(~str, SamplesFn), // sample set name, callback which receives samples
11+
}
12+
13+
fn foo(name: ~str, samples_chan: Chan<Msg>) {
14+
do task::spawn
15+
|copy name|
16+
{
17+
let callback: SamplesFn =
18+
|buffer|
19+
{
20+
for uint::range(0, buffer.len())
21+
|i| {error!("%?: %f", i, buffer[i])}
22+
};
23+
samples_chan.send(GetSamples(copy name, callback));
24+
};
25+
}
26+
27+
fn main() {}
28+

0 commit comments

Comments
 (0)