~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to testsuite/tests/basic-more/morematch.ml

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Glondu
  • Date: 2011-04-21 21:35:08 UTC
  • mfrom: (1.1.11 upstream) (12.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110421213508-kg34453aqmb0moha
* Fixes related to -output-obj with g++ (in debian/patches):
  - add Declare-primitive-name-table-as-const-char
  - add Avoid-multiple-declarations-in-generated-.c-files-in
  - fix Embed-bytecode-in-C-object-when-using-custom: the closing
    brace for extern "C" { ... } was missing in some cases

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(**************************************************************)
 
2
(*  This suite tests the pattern-matching compiler            *)
 
3
(*  it should just compile and run.                           *)
 
4
(*  While compiling the following messages are normal:        *)
 
5
(**************************************************************)
 
6
 
 
7
(*
 
8
File "morematch.ml", line 38, characters 10-93:
 
9
Warning: this pattern-matching is not exhaustive.
 
10
Here is an example of a value that is not matched:
 
11
0
 
12
File "morematch.ml", line 376, characters 2-15:
 
13
Warning: this match case is unused.
 
14
File "morematch.ml", line 443, characters 2-7:
 
15
Warning: this match case is unused.
 
16
*)
 
17
 
 
18
let test msg f arg r =
 
19
  if f arg <> r then begin
 
20
    prerr_endline msg ;
 
21
    failwith "Malaise"
 
22
  end
 
23
;;
 
24
 
 
25
type t = A | B | C | D | E | F
 
26
  ;;
 
27
 
 
28
let f x = match x with
 
29
| A | B | C -> 1
 
30
| D | E -> 2
 
31
| F -> 3;;
 
32
 
 
33
test "un" f C 1 ;
 
34
test "un" f D 2 ;
 
35
test "un" f F 3 ; ()
 
36
;;
 
37
 
 
38
let g x = match x with
 
39
  1 -> 1
 
40
| 2 -> 2
 
41
| 3 -> 3
 
42
| 4 | 5 -> 4
 
43
| 6 -> 5
 
44
| 7 | 8 -> 6
 
45
| 9 -> 7
 
46
| _ -> assert false
 
47
;;
 
48
 
 
49
test "deux" g 5 4 ;
 
50
test "deux" g 6 5 ;
 
51
test "deux" g 9 7 ; ()
 
52
;;
 
53
 
 
54
  
 
55
let g x = match x with
 
56
  1 -> 1
 
57
| 2 -> 2
 
58
| 3 -> 3
 
59
| 4 | 5 -> 4
 
60
| 6 -> 5   
 
61
| 7 | 8 -> 6
 
62
| 9 -> 7
 
63
| _ -> 8;;
 
64
 
 
65
test "trois" g 10 8
 
66
;;
 
67
 
 
68
let g x= match  x with
 
69
  1 -> 1
 
70
| 2 -> 2
 
71
| 3 -> 3
 
72
| 4 | 5 -> 4
 
73
| 6 -> 5   
 
74
| 4|5|7 -> 100
 
75
| 7 | 8 -> 6
 
76
| 9 -> 7
 
77
| _ -> 8;;
 
78
test "quatre" g 4 4 ;
 
79
test "quatre" g 7 100 ; ()
 
80
;;
 
81
 
 
82
(*
 
83
File "morematch.ml", line 73, characters 2-5:
 
84
Warning U: this sub-pattern is unused.
 
85
File "morematch.ml", line 74, characters 2-3:
 
86
Warning U: this sub-pattern is unused.
 
87
*)
 
88
 
 
89
let h x =
 
90
 match x with
 
91
   (1,1) -> 1
 
92
| (2|3), 1 -> 2
 
93
| 2,(2|3) -> 3
 
94
| (4,4) -> 5
 
95
| _ -> 100
 
96
;;
 
97
 
 
98
test "cinq" h (2,2) 3 ;
 
99
test "cinq" h (2,1) 2 ;
 
100
test "cinq" h (2,4) 100 ; ()
 
101
;;
 
102
 
 
103
(* idem hh (2,5) *)
 
104
 
 
105
let hh x = match x with
 
106
| 1,1 -> 1
 
107
| 2,1 -> 2
 
108
| (2|3),(1|2|3|4) -> 3
 
109
| 2,5 -> 4
 
110
| (4,4) -> 5
 
111
| _ -> 100
 
112
;;
 
113
 
 
114
let hhh x = match x with
 
115
| 1,1 -> 1
 
116
| (2|3),1 -> 2
 
117
| 2,2 -> 3
 
118
| _ -> 100
 
119
;;
 
120
 
 
121
let h x =
 
122
 match x with
 
123
   (1,1) -> 1
 
124
| 3,1 -> 2
 
125
| 2,(2|3) -> 3
 
126
| (4,4) -> 5
 
127
| _ -> 100
 
128
;;
 
129
 
 
130
let h x = match x with
 
131
  1 -> 1
 
132
| 2|3 -> 2
 
133
| 4 -> 4
 
134
| 5 -> 5
 
135
| 6|7 -> 6
 
136
| 8 -> 8
 
137
| _ -> 100
 
138
;;
 
139
let f x = match x with
 
140
| ((1|2),(3|4))|((3|4),(1|2)) -> 1
 
141
| (3,(5|6)) -> 2
 
142
| _ -> 3
 
143
;;
 
144
 
 
145
test "six" f (1,3) 1 ;
 
146
test "six" f (3,2) 1 ;
 
147
test "six" f (3,5) 2 ;
 
148
test "six" f (3,7) 3 ; ()
 
149
;;
 
150
 
 
151
type tt = {a : bool list ; b : bool}
 
152
 
 
153
let f = function
 
154
  | {a=([]|[true])} -> 1
 
155
  | {a=false::_}|{b=(true|false)}    -> 2
 
156
;;
 
157
 
 
158
test "sept" f {a=[] ; b = true} 1 ;
 
159
test "sept" f {a=[true] ; b = false} 1 ;
 
160
test "sept" f {a=[false ; true] ; b = true} 2 ;
 
161
test "sept" f {a=[false] ; b = false} 2 ; ()
 
162
;;
 
163
 
 
164
let f = function
 
165
  | (([]|[true]),_) -> 1
 
166
  | (false::_,_)|(_,(true|false)) -> 2
 
167
;;
 
168
 
 
169
test "huit" f ([],true) 1 ;
 
170
test "huit" f ([true],false) 1 ;
 
171
test "huit" f ([false ; true], true) 2 ;
 
172
test "huit" f ([false], false) 2 ; ()
 
173
;;
 
174
 
 
175
 
 
176
let split_cases = function
 
177
   | `Nil | `Cons _ as x -> `A x
 
178
   | `Snoc _ as x -> `B x
 
179
;;
 
180
 
 
181
test "oubli" split_cases `Nil (`A `Nil);
 
182
test "oubli" split_cases (`Cons 1) (`A (`Cons 1));
 
183
test "oubli" split_cases (`Snoc 1) (`B (`Snoc 1)) ; ()
 
184
;;
 
185
 
 
186
type t1 = A of int | B of int
 
187
let f1 = function
 
188
  | (A x | B x) -> x
 
189
;;
 
190
 
 
191
test "neuf" f1 (A 1) 1 ;
 
192
test "neuf" f1 (B 1) 1 ;
 
193
;;
 
194
 
 
195
type coucou = A of int | B of int * int | C
 
196
;;
 
197
 
 
198
 
 
199
let g = function
 
200
  | (A x | B (_,x)) -> x
 
201
  | C -> 0
 
202
;;
 
203
 
 
204
 
 
205
test "dix" g (A 1) 1 ;
 
206
test "dix" g (B (1,2)) 2 ;
 
207
;;
 
208
 
 
209
 
 
210
 
 
211
let h = function
 
212
  | ([x]|[1 ; x ]|[1 ; 2 ; x]) -> x
 
213
  | _ -> 0
 
214
;;
 
215
 
 
216
test "encore" h [1] 1 ;
 
217
test "encore" h [1;2] 2 ;
 
218
test "encore" h [1;2;3] 3 ;
 
219
test "encore" h [0 ; 0] 0 ; ()
 
220
;;
 
221
 
 
222
let f = function
 
223
| (x,(0 as y)) | (y,x) -> y-x
 
224
;;
 
225
 
 
226
test "foo1" f (1,0) (-1);
 
227
test "foo1" f (1,2) (-1)
 
228
;;
 
229
 
 
230
 
 
231
let f = function (([]|[_]) as x)|(_::([] as x))|(_::_::x)  -> x
 
232
;;
 
233
 
 
234
test "zob" f [] [] ;
 
235
test "zob" f [1] [1] ;
 
236
test "zob" f [1;2;3] [3]
 
237
;;
 
238
 
 
239
 
 
240
type zob = A | B | C | D of zob * int | E of zob * zob
 
241
 
 
242
let rec f = function
 
243
  | (A | B | C) -> A
 
244
  | D (x,i) -> D (f x,i)
 
245
  | E (x,_) -> D (f x,0)
 
246
;;
 
247
 
 
248
 
 
249
test "fin" f B A ;
 
250
test "fin" f (D (C,1)) (D (A,1)) ;
 
251
test "fin" f (E (C,A)) (D (A,0)) ; ()
 
252
;;
 
253
 
 
254
type length = 
 
255
    Char of int | Pixel of int | Percent of int | No of string | Default
 
256
 
 
257
let length = function
 
258
  | Char n -> n | Pixel n -> n
 
259
  | _       -> 0
 
260
;;
 
261
 
 
262
test "length" length (Char 10) 10 ;
 
263
test "length" length (Pixel 20) 20 ;
 
264
test "length" length Default 0 ;
 
265
test "length" length (Percent 100) 0 ; ()
 
266
;;
 
267
 
 
268
let length2 = function
 
269
  | Char n -> n | Percent n -> n
 
270
  | _       -> 0
 
271
;;
 
272
 
 
273
test "length2" length2 (Char 10) 10 ;
 
274
test "length2" length2 (Pixel 20) 0 ;
 
275
test "length2" length2 Default 0 ;
 
276
test "length2" length2(Percent 100) 100 ; ()
 
277
;;
 
278
 
 
279
let length3 = function
 
280
  | Char _ | No _ -> true
 
281
  | _ -> false
 
282
;;
 
283
 
 
284
test "length3" length3 (Char 10) true ;
 
285
test "length3" length3 (No "") true ;
 
286
test "length3" length3 (Pixel 20) false ;
 
287
test "length3" length3 Default false ;
 
288
test "length3" length3(Percent 100) false ; ()
 
289
;;
 
290
 
 
291
type hevea = A | B | C
 
292
 
 
293
let h x = match x with
 
294
| A -> 1
 
295
| B|C -> 2
 
296
;;
 
297
 
 
298
test "hevea" h A 1 ;
 
299
test "hevea" h B 2 ;
 
300
test "hevea" h B 2 ; ()
 
301
;;
 
302
type lambda =
 
303
    Lvar of int
 
304
  | Lconst of int
 
305
  | Lapply of lambda * lambda list
 
306
  | Lfunction of bool  * int list * lambda
 
307
  | Llet of  bool * int * lambda * lambda
 
308
  | Lletrec of (int * lambda) list * lambda
 
309
  | Lprim of string * lambda list
 
310
  | Lswitch of lambda * lambda_switch
 
311
  | Lstaticfail
 
312
  | Lcatch of lambda * lambda
 
313
  | Lstaticraise of int * lambda list
 
314
  | Lstaticcatch of lambda * (int * int list) * lambda
 
315
  | Ltrywith of lambda * int * lambda
 
316
  | Lifthenelse of lambda * lambda * lambda
 
317
  | Lsequence of lambda * lambda
 
318
  | Lwhile of lambda * lambda
 
319
  | Lfor of int * lambda * lambda * bool * lambda
 
320
  | Lassign of int * lambda
 
321
  | Lsend of lambda * lambda * lambda list
 
322
  | Levent of lambda * lambda_event
 
323
  | Lifused of int * lambda
 
324
and lambda_switch =
 
325
  { sw_numconsts: int;                  (* Number of integer cases *)
 
326
    sw_consts: (int * lambda) list;     (* Integer cases *)
 
327
    sw_numblocks: int;                  (* Number of tag block cases *)
 
328
    sw_blocks: (int * lambda) list;     (* Tag block cases *)
 
329
    sw_checked: bool ;                  (* True if bound checks needed *)
 
330
    sw_nofail: bool}                    (* True if should not fail *)
 
331
and lambda_event =
 
332
  { lev_loc: int;
 
333
    lev_kind: bool ;
 
334
    lev_repr: int ref option;
 
335
    lev_env: int list }
 
336
 
 
337
let rec approx_present v l = true
 
338
 
 
339
let rec lower_bind v arg lam = match lam with
 
340
| Lifthenelse (cond, ifso, ifnot) -> 1
 
341
| Lswitch (ls,({sw_consts=[i,act] ; sw_blocks = []} as _sw))
 
342
    when not (approx_present v ls) -> 2
 
343
| Lswitch (ls,({sw_consts=[] ; sw_blocks = [i,act]} as _sw))
 
344
    when not (approx_present v ls) -> 3
 
345
| Llet (true , vv, lv, l) -> 4
 
346
| _ -> 5
 
347
;;
 
348
 
 
349
test "lower_bind" (lower_bind 0 0) (Llet (true,0, Lvar 1, Lvar 2)) 4 ;
 
350
test "lower_bind" (lower_bind 0 0) (Lvar 0) 5 ;
 
351
test "lower_bind" (lower_bind 0 0) (Lifthenelse (Lvar 0, Lvar 1, Lvar 2)) 1
 
352
;;
 
353
 
 
354
 
 
355
type field_kind =
 
356
    Fvar of field_kind option ref
 
357
  | Fpresent
 
358
  | Fabsent
 
359
 
 
360
let unify_kind (k1, k2) =  match k1, k2 with
 
361
    (Fvar r, (Fvar _ | Fpresent))             -> 1
 
362
  | (Fpresent, Fvar r)                        -> 2
 
363
  | (Fpresent, Fpresent)                      -> 3
 
364
  | _                                         -> 4
 
365
 
 
366
 
 
367
let r = ref (Some Fpresent)
 
368
;;
 
369
 
 
370
test "unify"  unify_kind (Fvar r, Fpresent) 1 ;
 
371
test "unify"  unify_kind (Fvar r, Fvar r) 1 ;
 
372
test "unify"  unify_kind (Fvar r, Fabsent) 4 ;
 
373
test "unify"  unify_kind (Fpresent, Fvar r) 2 ;
 
374
test "unify"  unify_kind (Fpresent, Fpresent) 3 ;
 
375
test "unify"  unify_kind (Fabsent, Fpresent) 4 ; ()
 
376
;;
 
377
 
 
378
 
 
379
type youyou = A | B | C | D of youyou
 
380
 
 
381
let foo (k1, k2) = match k1,k2 with
 
382
| D _, (A|D _) -> 1
 
383
| (A|B),D _ -> 2
 
384
| C,_       -> 3
 
385
| _, (A|B|C) -> 4
 
386
;;
 
387
 
 
388
test "foo2" foo (D A,A) 1 ;
 
389
test "foo2" foo (D A,B) 4 ;
 
390
test "foo2" foo (A,A) 4 ; ()
 
391
;;
 
392
 
 
393
type yaya = A | B
 
394
;;
 
395
 
 
396
let yaya = function
 
397
| A,_,_ -> 1
 
398
| _,A,_ -> 2
 
399
| B,B,_ -> 3
 
400
| A,_,(100|103) -> 5
 
401
;;
 
402
 
 
403
test "yaya" yaya (A,A,0) 1 ;
 
404
test "yaya" yaya (B,A,0) 2 ;
 
405
test "yaya" yaya (B,B,100) 3 ; ()
 
406
;;
 
407
 
 
408
(*
 
409
let yoyo =  function
 
410
| [],_,_ -> 1
 
411
| _,[],_ -> 2
 
412
| _::_,_::_,_ -> 3
 
413
| [],_,(100|103|104) -> 5
 
414
| [],_,(100|103) -> 6
 
415
| [],_,(1000|1001|1002|20000) -> 7
 
416
;;
 
417
 
 
418
test "yoyo" yoyo ([],[],0) 1 ;
 
419
test "yoyo" yoyo ([1],[],0) 2 ;
 
420
test "yoyo" yoyo ([1],[1],100) 3 ; ()
 
421
;;
 
422
 
 
423
let youyou = function
 
424
  | (100|103|104) -> 1
 
425
  | (100|103|101) -> 2
 
426
  | (1000|1001|1002|20000) -> 3
 
427
  | _ -> -1
 
428
;;
 
429
 
 
430
test "youyou" youyou 100 1 ;
 
431
test "youyou" youyou 101 2 ;
 
432
test "youyou" youyou 1000 3
 
433
;;
 
434
*)
 
435
type autre =
 
436
  |  C | D | E of autre | F of autre * autre | H of autre | I | J | K of string
 
437
 
 
438
let rec autre = function
 
439
| C,_,_ -> 1
 
440
| _,C,_ -> 2
 
441
| D,D,_ -> 3
 
442
| (D|F (_,_)|H _|K _),_,_ -> 4
 
443
| (_, (D|I|E _|F (_, _)|H _|K _), _) -> 8
 
444
| (J,J,((C|D) as x |E x|F (_,x))) | (J,_,((C|J) as x)) -> autre (x,x,x)
 
445
| (J, J, (I|H _|K _)) -> 9
 
446
| I,_,_ -> 6
 
447
| E _,_,_ -> 7
 
448
;;
 
449
(*
 
450
File "morematch.ml", line 437, characters 43-44:
 
451
Warning U: this sub-pattern is unused.
 
452
*)
 
453
test "autre" autre (J,J,F (D,D)) 3 ;
 
454
test "autre" autre (J,J,D) 3 ;
 
455
test "autre" autre (J,J,I) 9 ;
 
456
test "autre" autre (H I,I,I) 4 ;
 
457
test "autre" autre (J,J,H I) 9 ; ()
 
458
;;
 
459
 
 
460
 
 
461
type youpi = YA | YB | YC
 
462
and hola = X | Y | Z | T of hola | U of hola | V of hola
 
463
 
 
464
let xyz = function
 
465
| YA,_,_ -> 1
 
466
| _,YA,_ -> 2
 
467
| YB,YB,_ -> 3
 
468
| ((YB|YC), (YB|YC), (X|Y|Z|V _|T _)) -> 6
 
469
| _,_,(X|U _) -> 8
 
470
| _,_,Y -> 5
 
471
;;
 
472
(*
 
473
File "morematch.ml", line 459, characters 7-8:
 
474
Warning U: this sub-pattern is unused.
 
475
File "morematch.ml", line 460, characters 2-7:
 
476
Warning U: this match case is unused.
 
477
*)
 
478
test "xyz" xyz (YC,YC,X) 6 ;
 
479
test "xyz" xyz (YC,YB,U X) 8 ;
 
480
test "xyz" xyz (YB,YC,X) 6 ; ()
 
481
;;
 
482
 
 
483
 
 
484
(* Ce test est pour le compilo lui-meme *)
 
485
let eq (x,y) = x=y
 
486
;;
 
487
 
 
488
test "eq" eq ("coucou", "coucou") true ; ()
 
489
;;
 
490
 
 
491
(* Test des gardes, non trivial *)
 
492
 
 
493
let is_none = function
 
494
  | None -> true
 
495
  | _ -> false
 
496
 
 
497
let garde x = match x with
 
498
| (Some _, _) when is_none (snd x) -> 1
 
499
| (Some (pc, _), Some pc') when pc = pc' -> 2
 
500
| _ -> 3
 
501
;;
 
502
 
 
503
test "garde" garde (Some (1,1),None) 1 ;
 
504
test "garde" garde (Some (1,1),Some 1) 2 ;
 
505
test "garde" garde (Some (2,1),Some 1) 3 ; ()
 
506
;;
 
507
 
 
508
let orstring = function
 
509
  | ("A"|"B"|"C") -> 2
 
510
  | "D" -> 3
 
511
  | _ -> 4
 
512
;;
 
513
 
 
514
test "orstring" orstring "A" 2 ;
 
515
test "orstring" orstring "B" 2 ;
 
516
test "orstring" orstring "C" 2 ;
 
517
test "orstring" orstring "D" 3 ;
 
518
test "orstring" orstring "E" 4 ; ()
 
519
;;
 
520
 
 
521
type var_t = [`Variant of [ `Some of string | `None | `Foo] ]
 
522
 
 
523
let crash (pat:var_t) =
 
524
      match pat with
 
525
      | `Variant (`Some tag) -> tag
 
526
      | `Variant (`None) -> "none"
 
527
      | _ -> "foo"
 
528
 
 
529
;;
 
530
 
 
531
test "crash" crash (`Variant `None) "none" ;
 
532
test "crash" crash (`Variant (`Some "coucou")) "coucou" ;
 
533
test "crash" crash (`Variant (`Foo)) "foo" ; ()
 
534
;;
 
535
 
 
536
let flatgarde c =
 
537
let x,y = c in
 
538
match x,y with
 
539
| (1,2)|(2,3) when y=2 -> 1
 
540
| (1,_)|(_,3) -> 2
 
541
| _ -> 3
 
542
;;
 
543
 
 
544
test "flatgarde" flatgarde (1,2) 1 ;
 
545
test "flatgarde" flatgarde (1,3) 2 ;
 
546
test "flatgarde" flatgarde (2,3) 2 ;
 
547
test "flatgarde" flatgarde (2,4) 3 ; ()
 
548
;;
 
549
 
 
550
 
 
551
(* Les bugs de jerome *)
 
552
type f =
 
553
  | ABSENT 
 
554
  | FILE
 
555
  | SYMLINK
 
556
  | DIRECTORY
 
557
 
 
558
type r =
 
559
  | Unchanged
 
560
  | Deleted
 
561
  | Modified
 
562
  | PropsChanged
 
563
  | Created
 
564
 
 
565
let replicaContent2shortString rc =
 
566
    let (typ, status) = rc in
 
567
    match typ, status with
 
568
      _, Unchanged             -> "        "
 
569
    | ABSENT, Deleted         -> "deleted "
 
570
    | FILE, Created           -> "new file"
 
571
    | FILE, Modified          -> "changed "
 
572
    | FILE, PropsChanged      -> "props   "
 
573
    | SYMLINK, Created        -> "new link"
 
574
    | SYMLINK, Modified       -> "chgd lnk"
 
575
    | DIRECTORY, Created      -> "new dir "
 
576
    | DIRECTORY, Modified     -> "chgd dir"
 
577
    | DIRECTORY, PropsChanged -> "props   "
 
578
    (* Cases that can't happen... *)
 
579
 
 
580
    | ABSENT, (Created | Modified | PropsChanged)
 
581
    | SYMLINK, PropsChanged
 
582
    | (FILE|SYMLINK|DIRECTORY), Deleted
 
583
                                -> "assert false"
 
584
;;
 
585
 
 
586
 
 
587
test "jerome_constr" 
 
588
   replicaContent2shortString (ABSENT, Unchanged) "        " ;
 
589
test "jerome_constr" 
 
590
   replicaContent2shortString (ABSENT, Deleted) "deleted " ;
 
591
test "jerome_constr" 
 
592
   replicaContent2shortString (FILE, Modified) "changed " ;
 
593
test "jerome_constr" 
 
594
   replicaContent2shortString (DIRECTORY, PropsChanged) "props   " ;
 
595
test "jerome_constr" 
 
596
   replicaContent2shortString (FILE, Deleted) "assert false" ;
 
597
test "jerome_constr" 
 
598
   replicaContent2shortString (SYMLINK, Deleted) "assert false" ;
 
599
test "jerome_constr" 
 
600
   replicaContent2shortString (SYMLINK, PropsChanged) "assert false" ;
 
601
test "jerome_constr" 
 
602
   replicaContent2shortString (DIRECTORY, Deleted) "assert false" ;
 
603
test "jerome_constr" 
 
604
   replicaContent2shortString (ABSENT, Created) "assert false" ;
 
605
test "jerome_constr" 
 
606
   replicaContent2shortString (ABSENT, Modified) "assert false" ;
 
607
test "jerome_constr" 
 
608
   replicaContent2shortString (ABSENT, PropsChanged) "assert false" ;
 
609
;;
 
610
 
 
611
 
 
612
let replicaContent2shortString rc =
 
613
    let (typ, status) = rc in
 
614
    match typ, status with
 
615
      _, `Unchanged             -> "        "
 
616
    | `ABSENT, `Deleted         -> "deleted "
 
617
    | `FILE, `Created           -> "new file"
 
618
    | `FILE, `Modified          -> "changed "
 
619
    | `FILE, `PropsChanged      -> "props   "
 
620
    | `SYMLINK, `Created        -> "new link"
 
621
    | `SYMLINK, `Modified       -> "chgd lnk"
 
622
    | `DIRECTORY, `Created      -> "new dir "
 
623
    | `DIRECTORY, `Modified     -> "chgd dir"
 
624
    | `DIRECTORY, `PropsChanged -> "props   "
 
625
    (* Cases that can't happen... *)
 
626
 
 
627
    | `ABSENT, (`Created | `Modified | `PropsChanged)
 
628
    | `SYMLINK, `PropsChanged
 
629
    | (`FILE|`SYMLINK|`DIRECTORY), `Deleted
 
630
                                -> "assert false"
 
631
;;
 
632
 
 
633
 
 
634
test "jerome_variant" 
 
635
   replicaContent2shortString (`ABSENT, `Unchanged) "        " ;
 
636
test "jerome_variant" 
 
637
   replicaContent2shortString (`ABSENT, `Deleted) "deleted " ;
 
638
test "jerome_variant" 
 
639
   replicaContent2shortString (`FILE, `Modified) "changed " ;
 
640
test "jerome_variant" 
 
641
   replicaContent2shortString (`DIRECTORY, `PropsChanged) "props   " ;
 
642
test "jerome_variant" 
 
643
   replicaContent2shortString (`FILE, `Deleted) "assert false" ;
 
644
test "jerome_variant" 
 
645
   replicaContent2shortString (`SYMLINK, `Deleted) "assert false" ;
 
646
test "jerome_variant" 
 
647
   replicaContent2shortString (`SYMLINK, `PropsChanged) "assert false" ;
 
648
test "jerome_variant" 
 
649
   replicaContent2shortString (`DIRECTORY, `Deleted) "assert false" ;
 
650
test "jerome_variant" 
 
651
   replicaContent2shortString (`ABSENT, `Created) "assert false" ;
 
652
test "jerome_variant" 
 
653
   replicaContent2shortString (`ABSENT, `Modified) "assert false" ;
 
654
test "jerome_variant" 
 
655
   replicaContent2shortString (`ABSENT, `PropsChanged) "assert false" ;
 
656
;;
 
657
 
 
658
(* bug 319 *)
 
659
 
 
660
type ab = A of int | B of int
 
661
type cd = C | D
 
662
 
 
663
let ohl = function
 
664
  | (A (p) | B (p)), C -> p
 
665
  | (A (p) | B (p)), D -> p
 
666
;;
 
667
 
 
668
test "ohl" ohl (A 0,C) 0 ;
 
669
test "ohl" ohl (B 0,D) 0 ; ()
 
670
;;
 
671
 
 
672
(* bug 324 *)
 
673
type pottier =
 
674
  | A
 
675
  | B
 
676
;;
 
677
 
 
678
let pottier x =
 
679
  match x with
 
680
  | (( (A, 1) | (B, 2)),A) -> false
 
681
  | _ -> true
 
682
;;
 
683
 
 
684
test "pottier" pottier ((B,2),A) false ;
 
685
test "pottier" pottier ((B,2),B) true ;
 
686
test "pottier" pottier ((A,2),A) true ; ()
 
687
;;
 
688
 
 
689
(* bug 325 in bytecode compiler *)
 
690
let coquery q =  match q with
 
691
| y,0,([modu;defs]| [defs;modu;_]) -> y+defs-modu
 
692
| _ -> 0
 
693
;;
 
694
 
 
695
test "coquery" coquery (1,0,[1 ; 2 ; 3]) 0 ;
 
696
test "coquery" coquery (1,0,[1 ; 2]) 2 ; ()
 
697
;;
 
698
 
 
699
(*
 
700
  Two other variable in or-pat tests
 
701
*)
 
702
type vars = A of int | B of (int * int) | C
 
703
;;
 
704
 
 
705
 
 
706
let vars1 = function
 
707
  | (A x | B (_,x)) -> x
 
708
  | C -> 0
 
709
;;
 
710
 
 
711
test "vars1" vars1 (A 1) 1 ;
 
712
test "vars1" vars1 (B (1,2)) 2 ; ()
 
713
;;
 
714
 
 
715
let vars2 = function
 
716
  | ([x]|[1 ; x ]|[1 ; 2 ; x]) -> x
 
717
  | _ -> 0
 
718
;;
 
719
 
 
720
test"vars2" vars2 [1] 1 ;
 
721
test"vars2" vars2 [1;2] 2 ;
 
722
test"vars2" vars2 [1;2;3] 3 ;
 
723
test"vars2" vars2 [0 ; 0] 0 ; ()
 
724
;;
 
725
 
 
726
(* Bug 342 *)
 
727
type eber = {x:int; y: int; z:bool}
 
728
 
 
729
let eber = function
 
730
  | {x=a; z=true}
 
731
  | {y=a; z=false} -> a
 
732
;;
 
733
 
 
734
test "eber" eber {x=0 ; y=1 ; z=true} 0 ;
 
735
test "eber" eber {x=1 ; y=0 ; z=false} 0 ; ()
 
736
;;
 
737
 
 
738
 
 
739
(* Enchainement des test d'intervalle *)
 
740
 
 
741
let escaped = function
 
742
  | '"' | '\\' | '\n' | '\t' -> 2
 
743
  | c -> 1
 
744
;;
 
745
 
 
746
test "escaped" escaped '"' 2 ;
 
747
test "escaped" escaped '\\' 2 ;
 
748
test "escaped" escaped '\n' 2 ;
 
749
test "escaped" escaped '\t' 2 ;
 
750
test "escaped" escaped '\000' 1 ;
 
751
test "escaped" escaped ' ' 1 ;
 
752
test "escaped" escaped '\000' 1 ;
 
753
test "escaped" escaped '[' 1 ;
 
754
test "escaped" escaped ']' 1 ;
 
755
test "escaped" escaped '!' 1 ;
 
756
test "escaped" escaped '#' 1 ;
 
757
()
 
758
;;
 
759
 
 
760
(* For compilation speed (due to J. Garigue) *)
 
761
exception Unknown_Reply of int
 
762
 
 
763
type command_reply =
 
764
   RPL_TRYAGAIN
 
765
 | RPL_TRACEEND
 
766
 | RPL_TRACELOG
 
767
 | RPL_ADMINEMAIL
 
768
 | RPL_ADMINLOC2
 
769
 | RPL_ADMINLOC1
 
770
 | RPL_ADMINME
 
771
 | RPL_LUSERME
 
772
 | RPL_LUSERCHANNELS
 
773
 | RPL_LUSERUNKNOWN
 
774
 | RPL_LUSEROP
 
775
 | RPL_LUSERCLIENT
 
776
 | RPL_STATSDLINE
 
777
 | RPL_STATSDEBUG
 
778
 | RPL_STATSDEFINE
 
779
 | RPL_STATSBLINE
 
780
 | RPL_STATSPING
 
781
 | RPL_STATSSLINE
 
782
 | RPL_STATSHLINE
 
783
 | RPL_STATSOLINE
 
784
 | RPL_STATSUPTIME
 
785
 | RPL_STATSLLINE
 
786
 | RPL_STATSVLINE
 
787
 | RPL_SERVLISTEND
 
788
 | RPL_SERVLIST
 
789
 | RPL_SERVICE
 
790
 | RPL_ENDOFSERVICES
 
791
 | RPL_SERVICEINFO
 
792
 | RPL_UMODEIS
 
793
 | RPL_ENDOFSTATS
 
794
 | RPL_STATSYLINE
 
795
 | RPL_STATSQLINE
 
796
 | RPL_STATSKLINE
 
797
 | RPL_STATSILINE
 
798
 | RPL_STATSNLINE
 
799
 | RPL_STATSCLINE
 
800
 | RPL_STATSCOMMANDS
 
801
 | RPL_STATSLINKINFO
 
802
 | RPL_TRACERECONNECT
 
803
 | RPL_TRACECLASS
 
804
 | RPL_TRACENEWTYPE
 
805
 | RPL_TRACESERVICE
 
806
 | RPL_TRACESERVER
 
807
 | RPL_TRACEUSER
 
808
 | RPL_TRACEOPERATOR
 
809
 | RPL_TRACEUNKNOWN
 
810
 | RPL_TRACEHANDSHAKE
 
811
 | RPL_TRACECONNECTING
 
812
 | RPL_TRACELINK
 
813
 | RPL_NOUSERS
 
814
 | RPL_ENDOFUSERS
 
815
 | RPL_USERS
 
816
 | RPL_USERSSTART
 
817
 | RPL_TIME
 
818
 | RPL_NOTOPERANYMORE
 
819
 | RPL_MYPORTIS
 
820
 | RPL_YOURESERVICE
 
821
 | RPL_REHASHING
 
822
 | RPL_YOUREOPER
 
823
 | RPL_ENDOFMOTD
 
824
 | RPL_MOTDSTART
 
825
 | RPL_ENDOFINFO
 
826
 | RPL_INFOSTART
 
827
 | RPL_MOTD
 
828
 | RPL_INFO
 
829
 | RPL_ENDOFBANLIST
 
830
 | RPL_BANLIST
 
831
 | RPL_ENDOFLINKS
 
832
 | RPL_LINKS
 
833
 | RPL_CLOSEEND
 
834
 | RPL_CLOSING
 
835
 | RPL_KILLDONE
 
836
 | RPL_ENDOFNAMES
 
837
 | RPL_NAMREPLY
 
838
 | RPL_ENDOFWHO
 
839
 | RPL_WHOREPLY
 
840
 | RPL_VERSION
 
841
 | RPL_SUMMONING
 
842
 | RPL_INVITING
 
843
 | RPL_TOPIC
 
844
 | RPL_NOTOPIC
 
845
 | RPL_CHANNELMODEIS
 
846
 | RPL_LISTEND
 
847
 | RPL_LIST
 
848
 | RPL_LISTSTART
 
849
 | RPL_WHOISCHANNELS
 
850
 | RPL_ENDOFWHOIS
 
851
 | RPL_WHOISIDLE
 
852
 | RPL_WHOISCHANOP
 
853
 | RPL_ENDOFWHOWAS
 
854
 | RPL_WHOWASUSER
 
855
 | RPL_WHOISOPERATOR
 
856
 | RPL_WHOISSERVER
 
857
 | RPL_WHOISUSER
 
858
 | RPL_NOWAWAY
 
859
 | RPL_UNAWAY
 
860
 | RPL_TEXT
 
861
 | RPL_ISON
 
862
 | RPL_USERHOST
 
863
 | RPL_AWAY
 
864
 | RPL_NONE
 
865
 
 
866
let get_command_reply n =
 
867
match n with
 
868
   263    ->     RPL_TRYAGAIN
 
869
 | 319    ->     RPL_WHOISCHANNELS
 
870
 | 318    ->     RPL_ENDOFWHOIS
 
871
 | 317    ->     RPL_WHOISIDLE
 
872
 | 316    ->     RPL_WHOISCHANOP
 
873
 | 369    ->     RPL_ENDOFWHOWAS
 
874
 | 314    ->     RPL_WHOWASUSER
 
875
 | 313    ->     RPL_WHOISOPERATOR
 
876
 | 312    ->     RPL_WHOISSERVER
 
877
 | 311    ->     RPL_WHOISUSER
 
878
 | 262    ->     RPL_TRACEEND
 
879
 | 261    ->     RPL_TRACELOG
 
880
 | 259    ->     RPL_ADMINEMAIL
 
881
 | 258    ->     RPL_ADMINLOC2
 
882
 | 257    ->     RPL_ADMINLOC1
 
883
 | 256    ->     RPL_ADMINME
 
884
 | 255    ->     RPL_LUSERME
 
885
 | 254    ->     RPL_LUSERCHANNELS
 
886
 | 253    ->     RPL_LUSERUNKNOWN
 
887
 | 252    ->     RPL_LUSEROP
 
888
 | 251    ->     RPL_LUSERCLIENT
 
889
 | 250    ->     RPL_STATSDLINE
 
890
 | 249    ->     RPL_STATSDEBUG
 
891
 | 248    ->     RPL_STATSDEFINE
 
892
 | 247    ->     RPL_STATSBLINE
 
893
 | 246    ->     RPL_STATSPING
 
894
 | 245    ->     RPL_STATSSLINE
 
895
 | 244    ->     RPL_STATSHLINE
 
896
 | 243    ->     RPL_STATSOLINE
 
897
 | 242    ->     RPL_STATSUPTIME
 
898
 | 241    ->     RPL_STATSLLINE
 
899
 | 240    ->     RPL_STATSVLINE
 
900
 | 235    ->     RPL_SERVLISTEND
 
901
 | 234    ->     RPL_SERVLIST
 
902
 | 233    ->     RPL_SERVICE
 
903
 | 232    ->     RPL_ENDOFSERVICES
 
904
 | 231    ->     RPL_SERVICEINFO
 
905
 | 221    ->     RPL_UMODEIS
 
906
 | 219    ->     RPL_ENDOFSTATS
 
907
 | 218    ->     RPL_STATSYLINE
 
908
 | 217    ->     RPL_STATSQLINE
 
909
 | 216    ->     RPL_STATSKLINE
 
910
 | 215    ->     RPL_STATSILINE
 
911
 | 214    ->     RPL_STATSNLINE
 
912
 | 213    ->     RPL_STATSCLINE
 
913
 | 212    ->     RPL_STATSCOMMANDS
 
914
 | 211    ->     RPL_STATSLINKINFO
 
915
 | 210    ->     RPL_TRACERECONNECT
 
916
 | 209    ->     RPL_TRACECLASS
 
917
 | 208    ->     RPL_TRACENEWTYPE
 
918
 | 207    ->     RPL_TRACESERVICE
 
919
 | 206    ->     RPL_TRACESERVER
 
920
 | 205    ->     RPL_TRACEUSER
 
921
 | 204    ->     RPL_TRACEOPERATOR
 
922
 | 203    ->     RPL_TRACEUNKNOWN
 
923
 | 202    ->     RPL_TRACEHANDSHAKE
 
924
 | 201    ->     RPL_TRACECONNECTING
 
925
 | 200    ->     RPL_TRACELINK
 
926
 | 395    ->     RPL_NOUSERS
 
927
 | 394    ->     RPL_ENDOFUSERS
 
928
 | 393    ->     RPL_USERS
 
929
 | 392    ->     RPL_USERSSTART
 
930
 | 391    ->     RPL_TIME
 
931
 | 385    ->     RPL_NOTOPERANYMORE
 
932
 | 384    ->     RPL_MYPORTIS
 
933
 | 383    ->     RPL_YOURESERVICE
 
934
 | 382    ->     RPL_REHASHING
 
935
 | 381    ->     RPL_YOUREOPER
 
936
 | 376    ->     RPL_ENDOFMOTD
 
937
 | 375    ->     RPL_MOTDSTART
 
938
 | 374    ->     RPL_ENDOFINFO
 
939
 | 373    ->     RPL_INFOSTART
 
940
 | 372    ->     RPL_MOTD
 
941
 | 371    ->     RPL_INFO
 
942
 | 368    ->     RPL_ENDOFBANLIST
 
943
 | 367    ->     RPL_BANLIST
 
944
 | 365    ->     RPL_ENDOFLINKS
 
945
 | 364    ->     RPL_LINKS
 
946
 | 363    ->     RPL_CLOSEEND
 
947
 | 362    ->     RPL_CLOSING
 
948
 | 361    ->     RPL_KILLDONE
 
949
 | 366    ->     RPL_ENDOFNAMES
 
950
 | 353    ->     RPL_NAMREPLY
 
951
 | 315    ->     RPL_ENDOFWHO
 
952
 | 352    ->     RPL_WHOREPLY
 
953
 | 351    ->     RPL_VERSION
 
954
 | 342    ->     RPL_SUMMONING
 
955
 | 341    ->     RPL_INVITING
 
956
 | 332    ->     RPL_TOPIC
 
957
 | 331    ->     RPL_NOTOPIC
 
958
 | 324    ->     RPL_CHANNELMODEIS
 
959
 | 323    ->     RPL_LISTEND
 
960
 | 322    ->     RPL_LIST
 
961
 | 321    ->     RPL_LISTSTART
 
962
 | 306    ->     RPL_NOWAWAY
 
963
 | 305    ->     RPL_UNAWAY
 
964
 | 304    ->     RPL_TEXT
 
965
 | 303    ->     RPL_ISON
 
966
 | 302    ->     RPL_USERHOST
 
967
 | 301    ->     RPL_AWAY
 
968
 | 300    ->     RPL_NONE
 
969
 | _ -> raise (Unknown_Reply n)
 
970
 
 
971
(* Bug 454 *)
 
972
type  habert_a=
 
973
  | A of habert_c
 
974
  | B of habert_c
 
975
  
 
976
and habert_c= {lvar:int; lassoc: habert_c;lnb:int} 
 
977
  
 
978
  
 
979
let habert=function
 
980
  | (A {lnb=i}|B {lnb=i}) when i=0 -> 1
 
981
  | A {lassoc=({lnb=j});lnb=i} -> 2
 
982
  | _ -> 3
 
983
;;
 
984
 
 
985
let rec ex0 = {lvar=0 ; lnb=0 ; lassoc=ex1}
 
986
and ex1 = {lvar=1 ; lnb=1 ; lassoc=ex0} in
 
987
 
 
988
test "habert" habert (A ex0) 1 ;
 
989
test "habert" habert (B ex0) 1 ;
 
990
test "habert" habert (A ex1) 2 ;
 
991
test "habert" habert (B ex1) 3 ;
 
992
 
 
993
(* Problems with interval test in arithmetic mod 2^31, bug #359 *)
 
994
(* From manuel Fahndrich *)
 
995
 
 
996
type type_expr = [
 
997
  | `TTuple of type_expr list
 
998
  | `TConstr of type_expr list
 
999
  | `TVar of string
 
1000
  | `TVariant of string list
 
1001
  | `TBlock of int
 
1002
  | `TCopy of type_expr
 
1003
  ] 
 
1004
 
 
1005
and recurs_type_expr = [
 
1006
  | `TTuple of type_expr list
 
1007
  | `TConstr of type_expr list
 
1008
  | `TVariant of string list
 
1009
  ] 
 
1010
 
 
1011
 
 
1012
let rec maf te =
 
1013
    match te with
 
1014
    | `TCopy te -> 1
 
1015
    | `TVar _ -> 2
 
1016
    | `TBlock _ -> 2
 
1017
    | #recurs_type_expr as desc ->
 
1018
 
 
1019
        let te =
 
1020
          (match desc with
 
1021
            `TTuple tl ->
 
1022
              4
 
1023
          | `TConstr tl ->
 
1024
              5
 
1025
          | `TVariant (row) ->
 
1026
              6
 
1027
                )
 
1028
        in
 
1029
 
 
1030
        te
 
1031
;;
 
1032
 
 
1033
let base = `TBlock 0
 
1034
;;
 
1035
 
 
1036
test "maf" maf (`TCopy base) 1 ;
 
1037
test "maf" maf (`TVar "test") 2 ;
 
1038
test "maf" maf (`TBlock 0) 2 ;
 
1039
test "maf" maf (`TTuple []) 4 ;
 
1040
test "maf" maf (`TConstr []) 5 ;
 
1041
test "maf" maf (`TVariant []) 6
 
1042
;;
 
1043
 
 
1044
(* PR#1310
 
1045
  Using ``get_args'' in place or an ad-hoc ``matcher'' function for tuples.
 
1046
  Has made the compiler [3.05] to fail.
 
1047
*)
 
1048
type t_seb = Uin | Uout
 
1049
;;
 
1050
 
 
1051
let rec seb = function
 
1052
  | ((i, Uin) | (i, Uout)), Uout -> 1
 
1053
  | ((j, Uin) | (j, Uout)), Uin ->  2
 
1054
;;
 
1055
 
 
1056
test "seb" seb ((0,Uin),Uout) 1 ;
 
1057
test "seb" seb ((0,Uout),Uin) 2 ;
 
1058
()
 
1059
;;
 
1060
 
 
1061
(* Talk with Jacques
 
1062
     - type 'b is still open ??
 
1063
     - better case generation, accept intervals of size 1 when ok_inter is
 
1064
       false (in Switch)
 
1065
*)
 
1066
 
 
1067
(*
 
1068
File "morematch.ml", line 1060, characters 8-65:
 
1069
Warning: this pattern-matching is not exhaustive.
 
1070
Here is an example of a value that is not matched:
 
1071
A `D
 
1072
*)
 
1073
type ('a, 'b) t_j = A of 'a | B of 'b * 'a | C
 
1074
 
 
1075
let f = function
 
1076
  | A (`A|`C) -> 0
 
1077
  | B (`B,`D) -> 1
 
1078
  | C -> 2
 
1079
 
 
1080
let g x = try f x with Match_failure _ -> 3
 
1081
 
 
1082
let _ =
 
1083
  test "jacques" g (A `A) 0 ;
 
1084
  test "jacques" g (A `C) 0 ;
 
1085
  test "jacques" g (B (`B,`D)) 1 ;
 
1086
  test "jacaues" g C 2 ;
 
1087
(*  test "jacques" g (B (`A,`D)) 3 ; (* type incorrect expected behavior ? *)*)
 
1088
  ()
 
1089
 
 
1090
(*
 
1091
  Compilation bug, segfault, because of incorrect compilation
 
1092
  of unused match case .. -> "11"
 
1093
*)
 
1094
 
 
1095
type t_l = A | B
 
1096
 
 
1097
let f = function
 
1098
  |  _, _, _, _, _, _, _, _, _, _, _, _, _, B, _, _ -> "0"
 
1099
  |  _, _, _, B, A, _, _, _, _, _, _, _, _, _, _, _ -> "1"
 
1100
  |  _, _, _, B, _, A, _, _, A, _, _, _, _, _, _, _ -> "2"
 
1101
  |  _, _, _, _, _, _, _, _, _, _, B, A, _, A, _, _ -> "3"
 
1102
  |  _, _, _, _, _, _, _, B, _, _, _, _, B, _, A, A -> "4"
 
1103
  |  A, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "5"
 
1104
  |  _, _, _, _, _, _, _, B, _, B, _, _, _, _, _, _ -> "6"
 
1105
  |  _, B, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "7"
 
1106
  |  _, A, A, _, A, _, B, _, _, _, _, _, _, _, _, B -> "8"
 
1107
  |  _, _, _, _, B, _, _, _, _, _, _, _, _, _, B, _ -> "9"
 
1108
  |  _, _, _, _, _, _, _, _, _, _, _, B, _, _, _, _ -> "10"
 
1109
  |  _, _, _, _, _, A, _, _, _, _, B, _, _, _, _, _ -> "11"
 
1110
  |  B, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "12"
 
1111
  |  _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "13"
 
1112
 
 
1113
(*
 
1114
File "morematch.ml", line 1094, characters 5-51:
 
1115
Warning: this match case is unused.
 
1116
File "morematch.ml", line 1096, characters 5-51:
 
1117
Warning: this match case is unused.
 
1118
*)
 
1119
let _  =
 
1120
  test "luc"  f (B, A, A, A, A, A, A, A, A, A, A, B, A, A, A, A) "10" ;
 
1121
  test "luc"  f (B, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A) "12" ;
 
1122
 ()
 
1123
 
 
1124
(*
 
1125
  By Gilles Peskine, compilation raised some assert false i make_failactionneg
 
1126
*)
 
1127
 
 
1128
type bg = [
 
1129
  | `False
 
1130
  | `True
 
1131
  ]
 
1132
  
 
1133
type vg = [
 
1134
  | `A
 
1135
  | `B
 
1136
  | `U of int
 
1137
  | `V of int
 
1138
  ]
 
1139
 
 
1140
type tg = {
 
1141
    v : vg;
 
1142
    x : bg;
 
1143
  }
 
1144
 
 
1145
let predg x = true 
 
1146
 
 
1147
let rec gilles o = match o with
 
1148
  | {v = (`U data | `V data); x = `False} when predg o -> 1
 
1149
  | {v = (`A|`B) ; x = `False}
 
1150
  | {v = (`U _ | `V _); x = `False}
 
1151
  | {v = _ ; x = `True}
 
1152
    -> 2
 
1153
 
 
1154
(*
 
1155
  Match in trywith should always have a default case
 
1156
*)
 
1157
 
 
1158
exception Found of string * int
 
1159
exception Error of string
 
1160
 
 
1161
 
 
1162
let lucexn  e =
 
1163
  try
 
1164
    try  raise e  with Error msg -> msg
 
1165
  with Found (s,r) -> s^string_of_int r
 
1166
 
 
1167
let () =
 
1168
  test "lucexn1" lucexn  (Error "coucou") "coucou" ;
 
1169
  test "lucexn2" lucexn (Found ("int: ",0)) "int: 0" ;
 
1170
  ()