Project

General

Profile

Revision df924fb3 src/mutation.ml

View differences:

src/mutation.ml
339 339
  else if Random.int 100 > threshold_random_int then
340 340
    Random.int 10
341 341
  else if Random.int 100 > threshold_switch_int then
342
    let idx = Random.int (List.length !int_consts) in
343
    List.nth !int_consts idx
342
    try
343
	let idx = Random.int (List.length !int_consts) in
344
        List.nth !int_consts idx
345
    with _ -> i
344 346
  else
345 347
    i
346 348
  
......
590 592
    else 
591 593
      let random_mutation = 
592 594
	match Random.int 6 with
593
	| 5 -> IncrIntCst (Random.int (IntSet.cardinal !records.consts))
594
	| 4 -> DecrIntCst (Random.int (IntSet.cardinal !records.consts))
595
	| 3 -> SwitchIntCst (Random.int (IntSet.cardinal !records.consts), Random.int (-1 + IntSet.cardinal !records.consts))
596
	| 2 -> Pre (Random.int !records.nb_pre)
597
	| 1 -> Boolexpr (Random.int !records.nb_boolexpr)
595
	| 5 -> IncrIntCst (try Random.int (IntSet.cardinal !records.consts) with _ -> 0)
596
	| 4 -> DecrIntCst (try Random.int (IntSet.cardinal !records.consts) with _ -> 0)
597
	| 3 -> SwitchIntCst ((try Random.int (IntSet.cardinal !records.consts) with _ -> 0), (try Random.int (-1 + IntSet.cardinal !records.consts) with _ -> 0))
598
	| 2 -> Pre (try Random.int !records.nb_pre with _ -> 0)
599
	| 1 -> Boolexpr (try Random.int !records.nb_boolexpr with _ -> 0)
598 600
	| 0 -> let bindings = OpCount.bindings !records.nb_op in
599
	       let op, nb_op = List.nth bindings (Random.int (List.length bindings)) in
600
	       let new_op = List.nth (op_mutation op) (Random.int (List.length (op_mutation op))) in
601
	       Op (op, Random.int nb_op, new_op)
601
	       let op, nb_op = List.nth bindings (try Random.int (List.length bindings) with _ -> 0) in
602
	       let new_op = List.nth (op_mutation op) (try Random.int (List.length (op_mutation op)) with _ -> 0) in
603
	       Op (op, (try Random.int nb_op with _ -> 0), new_op)
602 604
	| _ -> assert false
603 605
      in
604 606
      if List.mem random_mutation mutants then

Also available in: Unified diff