Commits

camlspotter  committed ce2eec4

autotest for dcamlexamples

  • Participants
  • Parent commits 73718f4
  • Branches gcaml

Comments (0)

Files changed (3)

File dcamlexamples/auto-test.pl

+#!/usr/bin/perl
+
+use strict;
+
+sub test {
+  my $file = $_[0];
+  if( $file =~ /dummy/ ){ return; }
+  my $result = `../byterun/ocamlrun ../ocaml -I ../stdlib/ $file 2>&1`;
+  chop $result;
+  $result =~ s/\n/ /g;
+  $result =~ s/File "[^"]+", //g;
+  # $result =~ s/Error: .*/Error!/g;
+  $result =~ s/\s+/ /g;
+  if( $? == 11 ){ $result = "Seg fault!!!"; }
+  elsif( $? == 512 ){ $result = "ERROR: $result"; }
+  elsif( $? != 0 ){ $result = "$?!!!"; }
+  else { $result = "OK"; }
+  if( $file =~ /error/ && $result =~ /^ERROR/ ){
+      $result = "OK (error)";
+  }
+  print "$file:\t$result\n";
+  while (<IN>) { print $_; }
+}
+
+`cd ..; make ocaml`;
+for my $f (@ARGV) {
+    test($f);
+}

File dcamlexamples/ex021_sum_error.ml

+module Sum = struct
+
+  type 'a t = 'a -> int
+
+  let sum $:t = t
+
+end
+
+module Int = struct
+
+  let sum : int Sum.t = fun x -> x
+
+end
+
+module List = struct
+
+  let sum = function
+    | [] -> 0
+    | x::xs -> Sum.sum x + Sum.sum xs
+	(* This causes infinite loops at dispatch creation.
+	   $'Caml is not yet clever enough to the second call
+	   of [sum] by [sum]
+	*)
+end
+
+module Overloaded : sig
+
+  type 'a t 
+
+  val sum : $:'a t -> 'a -> int
+
+  val int : int t
+  val list : $:'a t -> 'a list t
+
+end = struct
+
+  include Sum
+  let int = Int.sum
+  let float = Sum.sum
+
+end
+
+let () =
+  assert ([[]; [1]; [2;3]; [4;5;6]] = 21)
+;;

File dcamlexamples/ex021_sum_fail.ml

-module Sum = struct
-
-  type 'a t = 'a -> int
-
-  let sum $:t = t
-
-end
-
-module Int = struct
-
-  let sum : int Sum.t = fun x -> x
-
-end
-
-module List = struct
-
-  let sum = function
-    | [] -> 0
-    | x::xs -> Sum.sum x + Sum.sum xs
-	(* This causes infinite loops at dispatch creation.
-	   $'Caml is not yet clever enough to the second call
-	   of [sum] by [sum]
-	*)
-end
-
-module Overloaded : sig
-
-  type 'a t 
-
-  val sum : $:'a t -> 'a -> int
-
-  val int : int t
-  val list : $:'a t -> 'a list t
-
-end = struct
-
-  include Sum
-  let int = Int.sum
-  let float = Sum.sum
-
-end
-
-let () =
-  assert ([[]; [1]; [2;3]; [4;5;6]] = 21)
-;;