File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ use std;
2
+
3
+ fn test_init_elt ( ) {
4
+ let vec[ uint] v = std. _vec . init_elt [ uint] ( uint ( 5 ) , uint ( 3 ) ) ;
5
+ check ( std. _vec . len [ uint] ( v) == uint ( 3 ) ) ;
6
+ check ( v. ( 0 ) == uint ( 5 ) ) ;
7
+ check ( v. ( 1 ) == uint ( 5 ) ) ;
8
+ check ( v. ( 2 ) == uint ( 5 ) ) ;
9
+ }
10
+
11
+ fn id ( uint x) -> uint {
12
+ ret x;
13
+ }
14
+ fn test_init_fn ( ) {
15
+ let fn( uint) ->uint op = id;
16
+ let vec[ uint] v = std. _vec . init_fn [ uint] ( op, uint ( 5 ) ) ;
17
+ // FIXME #108: Can't call templated function twice in the same
18
+ // program, at the moment.
19
+ //check (std._vec.len[uint](v) == uint(5));
20
+ check ( v. ( 0 ) == uint ( 0 ) ) ;
21
+ check ( v. ( 1 ) == uint ( 1 ) ) ;
22
+ check ( v. ( 2 ) == uint ( 2 ) ) ;
23
+ check ( v. ( 3 ) == uint ( 3 ) ) ;
24
+ check ( v. ( 4 ) == uint ( 4 ) ) ;
25
+ }
26
+
27
+ fn main ( ) {
28
+ test_init_elt ( ) ;
29
+ //XFAIL: test_init_fn(); // Segfaults.
30
+ }
You can’t perform that action at this time.
0 commit comments