Skip to content

Commit c7107cb

Browse files
committed
---
yaml --- r: 15709 b: refs/heads/try c: c2382f9 h: refs/heads/master i: 15707: 35c1eb1 v: v3
1 parent 5057e3b commit c7107cb

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: f32d9f4853e878cdd721d5120aea023e901f81d4
5+
refs/heads/try: c2382f9ebf1ad668df7624955268f4485068449a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import to_str::*;
2+
import to_str::to_str;
3+
4+
class cat {
5+
priv {
6+
let mut meows : uint;
7+
fn meow() {
8+
#error("Meow");
9+
self.meows += 1u;
10+
if self.meows % 5u == 0u {
11+
self.how_hungry += 1;
12+
}
13+
}
14+
}
15+
16+
let mut how_hungry : int;
17+
let name : str;
18+
19+
new(in_x : uint, in_y : int, in_name: str)
20+
{ self.meows = in_x; self.how_hungry = in_y; self.name = in_name; }
21+
22+
fn speak() { self.meow(); }
23+
24+
fn eat() -> bool {
25+
if self.how_hungry > 0 {
26+
#error("OM NOM NOM");
27+
self.how_hungry -= 2;
28+
ret true;
29+
}
30+
else {
31+
#error("Not hungry!");
32+
ret false;
33+
}
34+
}
35+
}
36+
37+
impl of to_str for cat {
38+
fn to_str() -> str { self.name }
39+
}
40+
41+
fn print_out<T: to_str>(thing: T, expected: str) {
42+
let actual = thing.to_str();
43+
#debug("%s", actual);
44+
assert(actual == expected);
45+
}
46+
47+
fn main() {
48+
let nyan : to_str = cat(0u, 2, "nyan") as to_str;
49+
print_out(nyan, "nyan");
50+
}

0 commit comments

Comments
 (0)