/
istr.rs
62 lines (51 loc) · 1.19 KB
/
istr.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
fn test_stack_assign() {
let s: str = "a";
log(debug, s);
let t: str = "a";
assert (s == t);
let u: str = "b";
assert (s != u);
}
fn test_heap_lit() { "a big string"; }
fn test_heap_assign() {
let s: str = "a big ol' string";
let t: str = "a big ol' string";
assert (s == t);
let u: str = "a bad ol' string";
assert (s != u);
}
fn test_heap_log() { let s = "a big ol' string"; log(debug, s); }
fn test_stack_add() {
assert ("a" + "b" == "ab");
let s: str = "a";
assert (s + s == "aa");
assert ("" + "" == "");
}
fn test_stack_heap_add() { assert ("a" + "bracadabra" == "abracadabra"); }
fn test_heap_add() {
assert ("this should" + " totally work" == "this should totally work");
}
fn test_append() {
let mut s = "";
s += "a";
assert (s == "a");
let mut s = "a";
s += "b";
log(debug, s);
assert (s == "ab");
let mut s = "c";
s += "offee";
assert (s == "coffee");
s += "&tea";
assert (s == "coffee&tea");
}
fn main() {
test_stack_assign();
test_heap_lit();
test_heap_assign();
test_heap_log();
test_stack_add();
test_stack_heap_add();
test_heap_add();
test_append();
}