2011-08-22 15:53:39 -05:00
|
|
|
fn test_stack_assign() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let s: ~str = ~"a";
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, s);
|
2012-07-14 00:57:48 -05:00
|
|
|
let t: ~str = ~"a";
|
2011-09-02 17:34:58 -05:00
|
|
|
assert (s == t);
|
2012-07-14 00:57:48 -05:00
|
|
|
let u: ~str = ~"b";
|
2011-09-02 17:34:58 -05:00
|
|
|
assert (s != u);
|
2011-08-22 15:53:39 -05:00
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn test_heap_lit() { ~"a big string"; }
|
2011-08-22 15:53:39 -05:00
|
|
|
|
2011-08-22 16:33:31 -05:00
|
|
|
fn test_heap_assign() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let s: ~str = ~"a big ol' string";
|
|
|
|
let t: ~str = ~"a big ol' string";
|
2011-09-02 17:34:58 -05:00
|
|
|
assert (s == t);
|
2012-07-14 00:57:48 -05:00
|
|
|
let u: ~str = ~"a bad ol' string";
|
2011-09-02 17:34:58 -05:00
|
|
|
assert (s != u);
|
2011-08-22 16:33:31 -05:00
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn test_heap_log() { let s = ~"a big ol' string"; log(debug, s); }
|
2011-08-22 18:12:42 -05:00
|
|
|
|
2011-08-22 18:39:18 -05:00
|
|
|
fn test_stack_add() {
|
2012-07-14 00:57:48 -05:00
|
|
|
assert (~"a" + ~"b" == ~"ab");
|
|
|
|
let s: ~str = ~"a";
|
|
|
|
assert (s + s == ~"aa");
|
|
|
|
assert (~"" + ~"" == ~"");
|
2011-08-22 18:39:18 -05:00
|
|
|
}
|
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
fn test_stack_heap_add() { assert (~"a" + ~"bracadabra" == ~"abracadabra"); }
|
2011-08-22 18:39:18 -05:00
|
|
|
|
|
|
|
fn test_heap_add() {
|
2012-07-14 00:57:48 -05:00
|
|
|
assert (~"this should" + ~" totally work" == ~"this should totally work");
|
2011-08-22 18:39:18 -05:00
|
|
|
}
|
|
|
|
|
2011-08-22 19:35:38 -05:00
|
|
|
fn test_append() {
|
2012-07-14 00:57:48 -05:00
|
|
|
let mut s = ~"";
|
|
|
|
s += ~"a";
|
|
|
|
assert (s == ~"a");
|
2011-08-22 19:35:38 -05:00
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
let mut s = ~"a";
|
|
|
|
s += ~"b";
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, s);
|
2012-07-14 00:57:48 -05:00
|
|
|
assert (s == ~"ab");
|
2011-08-22 19:35:38 -05:00
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
let mut s = ~"c";
|
|
|
|
s += ~"offee";
|
|
|
|
assert (s == ~"coffee");
|
2011-08-22 19:35:38 -05:00
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
s += ~"&tea";
|
|
|
|
assert (s == ~"coffee&tea");
|
2011-08-22 19:35:38 -05:00
|
|
|
}
|
|
|
|
|
2011-08-22 15:53:39 -05:00
|
|
|
fn main() {
|
|
|
|
test_stack_assign();
|
|
|
|
test_heap_lit();
|
2011-08-22 16:33:31 -05:00
|
|
|
test_heap_assign();
|
2011-08-22 18:12:42 -05:00
|
|
|
test_heap_log();
|
2011-08-22 18:39:18 -05:00
|
|
|
test_stack_add();
|
|
|
|
test_stack_heap_add();
|
|
|
|
test_heap_add();
|
2011-08-22 19:35:38 -05:00
|
|
|
test_append();
|
2011-09-02 17:34:58 -05:00
|
|
|
}
|