2
2
3
3
use std;
4
4
import std:: either:: * ;
5
- import std:: vec :: len;
5
+ import std:: ivec :: len;
6
6
7
7
fn test_either_left ( ) {
8
8
auto val = left ( 10 ) ;
@@ -19,57 +19,57 @@ fn test_either_right() {
19
19
}
20
20
21
21
fn test_lefts ( ) {
22
- auto input = [ left ( 10 ) ,
23
- right ( 11 ) ,
24
- left ( 12 ) ,
25
- right ( 13 ) ,
26
- left ( 14 ) ] ;
22
+ auto input = ~ [ left ( 10 ) ,
23
+ right ( 11 ) ,
24
+ left ( 12 ) ,
25
+ right ( 13 ) ,
26
+ left ( 14 ) ] ;
27
27
auto result = lefts ( input) ;
28
- assert ( result == [ 10 , 12 , 14 ] ) ;
28
+ assert ( result == ~ [ 10 , 12 , 14 ] ) ;
29
29
}
30
30
31
31
fn test_lefts_none ( ) {
32
- let vec [ t[ int, int] ] input = [ right ( 10 ) ,
32
+ let ( t[ int, int] ) [ ] input = ~ [ right ( 10 ) ,
33
33
right ( 10 ) ] ;
34
34
auto result = lefts ( input) ;
35
35
assert ( len ( result) == 0 u) ;
36
36
}
37
37
38
38
fn test_lefts_empty ( ) {
39
- let vec [ t[ int, int] ] input = [ ] ;
39
+ let ( t[ int, int] ) [ ] input = ~ [ ] ;
40
40
auto result = lefts ( input) ;
41
41
assert ( len ( result) == 0 u) ;
42
42
}
43
43
44
44
fn test_rights ( ) {
45
- auto input = [ left ( 10 ) ,
46
- right ( 11 ) ,
47
- left ( 12 ) ,
48
- right ( 13 ) ,
49
- left ( 14 ) ] ;
45
+ auto input = ~ [ left ( 10 ) ,
46
+ right ( 11 ) ,
47
+ left ( 12 ) ,
48
+ right ( 13 ) ,
49
+ left ( 14 ) ] ;
50
50
auto result = rights ( input) ;
51
- assert ( result == [ 11 , 13 ] ) ;
51
+ assert ( result == ~ [ 11 , 13 ] ) ;
52
52
}
53
53
54
54
fn test_rights_none ( ) {
55
- let vec [ t[ int, int] ] input = [ left ( 10 ) ,
55
+ let ( t[ int, int] ) [ ] input = ~ [ left ( 10 ) ,
56
56
left ( 10 ) ] ;
57
57
auto result = rights ( input) ;
58
58
assert ( len ( result) == 0 u) ;
59
59
}
60
60
61
61
fn test_rights_empty ( ) {
62
- let vec [ t[ int, int] ] input = [ ] ;
62
+ let ( t[ int, int] ) [ ] input = ~ [ ] ;
63
63
auto result = rights ( input) ;
64
64
assert ( len ( result) == 0 u) ;
65
65
}
66
66
67
67
fn test_partition ( ) {
68
- auto input = [ left ( 10 ) ,
69
- right ( 11 ) ,
70
- left ( 12 ) ,
71
- right ( 13 ) ,
72
- left ( 14 ) ] ;
68
+ auto input = ~ [ left ( 10 ) ,
69
+ right ( 11 ) ,
70
+ left ( 12 ) ,
71
+ right ( 13 ) ,
72
+ left ( 14 ) ] ;
73
73
auto result = partition ( input) ;
74
74
assert ( result. _0 . ( 0 ) == 10 ) ;
75
75
assert ( result. _0 . ( 1 ) == 12 ) ;
@@ -79,23 +79,23 @@ fn test_partition() {
79
79
}
80
80
81
81
fn test_partition_no_lefts ( ) {
82
- let vec [ t[ int, int] ] input = [ right ( 10 ) ,
82
+ let ( t[ int, int] ) [ ] input = ~ [ right ( 10 ) ,
83
83
right ( 11 ) ] ;
84
84
auto result = partition ( input) ;
85
85
assert ( len ( result. _0 ) == 0 u) ;
86
86
assert ( len ( result. _1 ) == 2 u) ;
87
87
}
88
88
89
89
fn test_partition_no_rights ( ) {
90
- let vec [ t[ int, int] ] input = [ left ( 10 ) ,
90
+ let ( t[ int, int] ) [ ] input = ~ [ left ( 10 ) ,
91
91
left ( 11 ) ] ;
92
92
auto result = partition ( input) ;
93
93
assert ( len ( result. _0 ) == 2 u) ;
94
94
assert ( len ( result. _1 ) == 0 u) ;
95
95
}
96
96
97
97
fn test_partition_empty ( ) {
98
- let vec [ t[ int, int] ] input = [ ] ;
98
+ let ( t[ int, int] ) [ ] input = ~ [ ] ;
99
99
auto result = partition ( input) ;
100
100
assert ( len ( result. _0 ) == 0 u) ;
101
101
assert ( len ( result. _1 ) == 0 u) ;
@@ -114,4 +114,4 @@ fn main() {
114
114
test_partition_no_lefts ( ) ;
115
115
test_partition_no_rights ( ) ;
116
116
test_partition_empty ( ) ;
117
- }
117
+ }
0 commit comments