Skip to content

Commit b39d469

Browse files
committed
---
yaml --- r: 1960 b: refs/heads/master c: cf16f4f h: refs/heads/master v: v3
1 parent 87d23dd commit b39d469

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: c27b72e323d1aabb0eeb9939feb5584bc28ba9e9
2+
refs/heads/master: cf16f4f7e5bf5d37fc0e254e3c7ccdf0623c50d3
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// xfail-boot
2+
// xfail-stage0
3+
// -*- rust -*-
4+
5+
// Tests for standalone blocks as expressions with dynamic type sizes
6+
7+
type compare[T] = fn(&T t1, &T t2) -> bool;
8+
9+
fn test_generic[T](&T expected, &compare[T] eq) {
10+
let T actual = { expected };
11+
check (eq(expected, actual));
12+
}
13+
14+
fn test_bool() {
15+
fn compare_bool(&bool b1, &bool b2) -> bool {
16+
ret b1 == b2;
17+
}
18+
auto eq = bind compare_bool(_, _);
19+
test_generic[bool](true, eq);
20+
}
21+
22+
23+
fn test_tup() {
24+
type t = tup(int, int);
25+
fn compare_tup(&t t1, &t t2) -> bool {
26+
ret t1 == t2;
27+
}
28+
auto eq = bind compare_tup(_, _);
29+
test_generic[t](tup(1, 2), eq);
30+
}
31+
32+
fn test_vec() {
33+
fn compare_vec(&vec[int] v1, &vec[int] v2) -> bool {
34+
ret v1 == v2;
35+
}
36+
auto eq = bind compare_vec(_, _);
37+
test_generic[vec[int]](vec(1, 2), eq);
38+
}
39+
40+
fn test_box() {
41+
fn compare_box(&@bool b1, &@bool b2) -> bool {
42+
ret *b1 == *b2;
43+
}
44+
auto eq = bind compare_box(_, _);
45+
test_generic[@bool](@true, eq);
46+
}
47+
48+
fn main() {
49+
test_bool();
50+
test_tup();
51+
// FIXME: These two don't pass yet
52+
test_vec();
53+
test_box();
54+
}
55+
56+

0 commit comments

Comments
 (0)