File tree Expand file tree Collapse file tree 3 files changed +111
-2
lines changed Expand file tree Collapse file tree 3 files changed +111
-2
lines changed Original file line number Diff line number Diff line change
1
+ // xfail-boot
2
+ // -*- rust -*-
3
+
4
+ // Tests for alt as expressions resulting in boxed types
5
+
6
+ fn test_box ( ) {
7
+ auto res = alt ( true ) {
8
+ case ( true ) {
9
+ @100
10
+ }
11
+ } ;
12
+ check ( * res == 100 ) ;
13
+ }
14
+
15
+ fn test_str ( ) {
16
+ auto res = alt ( true ) {
17
+ case ( true ) {
18
+ "happy"
19
+ }
20
+ } ;
21
+ check ( res == "happy" ) ;
22
+ }
23
+
24
+ fn main ( ) {
25
+ test_box ( ) ;
26
+ test_str ( ) ;
27
+ }
Original file line number Diff line number Diff line change
1
+ // xfail-boot
2
+ // -*- rust -*-
3
+
4
+ // Tests for alt as expressions resulting in structural types
5
+
6
+ fn test_rec ( ) {
7
+ auto res = alt ( true ) {
8
+ case ( true ) {
9
+ rec ( i = 100 )
10
+ }
11
+ } ;
12
+ check ( res == rec ( i = 100 ) ) ;
13
+ }
14
+
15
+ fn test_tag ( ) {
16
+ tag mood {
17
+ happy;
18
+ sad;
19
+ }
20
+
21
+ auto res = alt ( true ) {
22
+ case ( true ) {
23
+ happy
24
+ }
25
+ case ( false ) {
26
+ sad
27
+ }
28
+ } ;
29
+ check ( res == happy) ;
30
+ }
31
+
32
+ fn main ( ) {
33
+ test_rec ( ) ;
34
+ test_tag ( ) ;
35
+ }
Original file line number Diff line number Diff line change 3
3
4
4
// Tests for using alt as an expression
5
5
6
- fn test ( ) {
6
+ fn test_basic ( ) {
7
7
let bool res = alt ( true ) {
8
8
case ( true ) {
9
9
true
@@ -25,6 +25,53 @@ fn test() {
25
25
check ( res) ;
26
26
}
27
27
28
+ fn test_inferrence ( ) {
29
+ auto res = alt ( true ) {
30
+ case ( true ) {
31
+ true
32
+ }
33
+ case ( false ) {
34
+ false
35
+ }
36
+ } ;
37
+ check ( res) ;
38
+ }
39
+
40
+ fn test_alt_as_alt_head ( ) {
41
+ // Yeah, this is kind of confusing ...
42
+ auto res = alt ( alt ( false ) { case ( true ) { true } case ( false ) { false } } ) {
43
+ case ( true ) {
44
+ false
45
+ }
46
+ case ( false ) {
47
+ true
48
+ }
49
+ } ;
50
+ check ( res) ;
51
+ }
52
+
53
+ fn test_alt_as_block_result ( ) {
54
+ auto res = alt ( false ) {
55
+ case ( true ) {
56
+ false
57
+ }
58
+ case ( false ) {
59
+ alt ( true ) {
60
+ case ( true ) {
61
+ true
62
+ }
63
+ case ( false ) {
64
+ false
65
+ }
66
+ }
67
+ }
68
+ } ;
69
+ check ( res) ;
70
+ }
71
+
28
72
fn main ( ) {
29
- test ( ) ;
73
+ test_basic ( ) ;
74
+ test_inferrence ( ) ;
75
+ test_alt_as_alt_head ( ) ;
76
+ test_alt_as_block_result ( ) ;
30
77
}
You can’t perform that action at this time.
0 commit comments