Added correct handling of undef.
[perl4caml.git] / examples / test.ml
index f06fe5b..490401e 100644 (file)
@@ -1,11 +1,14 @@
 (* Simple test of the API.
  * Copyright (C) 2003 Merjis Ltd.
- * $Id: test.ml,v 1.4 2003-10-16 08:54:56 rich Exp $
+ * $Id: test.ml,v 1.7 2004-11-25 22:16:17 rich Exp $
  *)
 
 open Printf
 
 let () =
+  (* Perform a full collection - good way to find bugs in initialization code*)
+  Gc.full_major ();
+
   (* Load "test.pl". *)
   Perl.eval "require 'examples/test.pl'";
 
@@ -45,5 +48,10 @@ let () =
   let sv = Perl.call_method obj "get_foo" [] in
   printf "TestClass.foo is %d\n" (Perl.int_of_sv sv); flush stdout;
 
-  (* Destroy the interpreter. *)
-  Perl.destroy (Perl.current_interpreter ())
+  (* Create an undef value and test it. *)
+  let undef = Perl.sv_undef () in
+  printf "sv_is_undef (undef) = %s\n"
+    (string_of_bool (Perl.sv_is_undef undef));
+
+  (* Perform a full collection - good way to find GC/allocation bugs. *)
+  Gc.full_major ()