OSDN Git Service

[REFACTORING] Remove test-assist module
authormzp <mzpppp@gmail.com>
Mon, 10 Nov 2008 01:47:39 +0000 (10:47 +0900)
committermzp <mzpppp@gmail.com>
Mon, 10 Nov 2008 01:47:39 +0000 (10:47 +0900)
Old version, I use custom syntax for OUnit. Now, I use the OUnit's operator directly.

OMakefile
camlp4/OMakefile [deleted file]
camlp4/TestCaseCollector.ml [deleted file]
test/OMakefile
test/runner.mlp [deleted file]
test/test_closuretrans.ml
test/test_codegen.ml
test/test_sexp.ml
test/util.ml

index 0ee4699..053f577 100644 (file)
--- a/OMakefile
+++ b/OMakefile
@@ -1,10 +1,13 @@
 .PHONY: clean integrate
-.SUBDIRS: test src util camlp4
+.SUBDIRS: test src util
 
 clean:
        rm -f *~ *.omc
 
+habc-scm: src/habc-scm
+       cp src/habc-scm .
+
 integrate: src/habc-scm
        sh example/test.sh example/*.scm
 
-.DEFAULT: src/habc-scm
+.DEFAULT: habc-scm
diff --git a/camlp4/OMakefile b/camlp4/OMakefile
deleted file mode 100644 (file)
index db08e88..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-.PHONY: clean
-
-OCAMLINCLUDES += +camlp4
-NATIVE_ENABLED = false
-BYTE_ENABLED = true
-OCAMLPPFLAGS  += -pp camlp4of
-OCAMLDEPFLAGS += $(OCAMLPPFLAGS)
-
-OCamlProgram(TestCaseCollector , TestCaseCollector)
-
-clean:
-       rm -f  *.cm[iox] *.o *.omc *.opt *.run *~
\ No newline at end of file
diff --git a/camlp4/TestCaseCollector.ml b/camlp4/TestCaseCollector.ml
deleted file mode 100644 (file)
index 1dd9750..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-module Id = struct
-  let name = "TestCaseCollector"
-  let version = "1.0"
-end
-
-open Camlp4
-module Make(Syntax : Sig.Camlp4Syntax) = struct
-  open Sig
-  include Syntax
-
-  let (@@) f g = f g
-  let start_with pre str =
-    let n =
-      String.length pre in
-    let m = 
-      String.length str in
-      if n > m then
-       false
-      else
-       pre = (String.sub str 0 n)
-
-  EXTEND Gram
-    GLOBAL: str_item;
-    str_item: LEVEL "top"
-      [[ "test"; name = LIDENT; "=" ; e = expr ->
-          let s = 
-            Printf.sprintf "%s(line %d)" (Loc.file_name _loc) (Loc.start_line _loc) in
-            <:str_item< let _ = Testtbl.add $`str:s$ $str:name$ (fun () -> $exp:e$) >> 
-       ]];
-  END
-end
-
-let module M = Register.OCamlSyntaxExtension(Id)(Make) in
-  ()
index ad57227..99476ee 100644 (file)
@@ -39,7 +39,7 @@ BYTE_ENABLED = true
 #
 
 OCAMLFLAGS    += -thread
-OCAMLPPFLAGS += -pp "camlp4o ../camlp4/TestCaseCollector.cmo"
+OCAMLPPFLAGS += 
 OCAMLDEPFLAGS += $(OCAMLPPFLAGS)
 
 ################################################
@@ -68,30 +68,16 @@ OCAML_LIBS += ../src/habc-scm
 
 OCAML_OTHER_LIBS += threads
 
-OCamlProgram($(PROGRAM), $(FILES) runner)
+OCamlProgram($(PROGRAM), $(FILES))
 
-.DEFAULT: check
+#############################################################
+#
+# PHONY Target
+# 
+.DEFAULT: $(PROGRAM)
 
 check: $(PROGRAM)
        ./$(PROGRAM)
 
-################################################
-# Dependcy rule
-
-CAMLP4FILES[] =
-       ../camlp4/TestCaseCollector.cmo
-
-
-runner.h: $(addsuffix .ml, $(FILES))
-       @rm -f $@
-       foreach(name, $^)
-               @echo open $(capitalize $(removesuffix $(name))) >> $@
-
-
-.SCANNER: scan-ocaml-%.ml: %.ml $(CAMLP4FILES)
-       section 
-               OCAMLDEPFLAGS += -pp 'camlp4o $(CAMLP4FILES)'
-               $(OCamlScanner $<)
-
 clean:
        rm -f  $(PROGRAM) *.cm[iox] *.o *.omc *.opt *.run *~ runner.h
diff --git a/test/runner.mlp b/test/runner.mlp
deleted file mode 100644 (file)
index 9360f5a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "runner.h"
-
-let _ =
-  Testtbl.run_test () 
-
index 730dc7b..7953d7a 100644 (file)
@@ -4,6 +4,9 @@ open Util
 open ClosureTrans
 open OUnit
 
+let compile_string str =
+  ClosTrans.trans @@ Lisp.compile_string str
+
 let ok x y =
   OUnit.assert_equal
     ~printer:(fun x-> (Std.dump (List.map Ast.to_string_stmt x) ^ "\n"))
index 6f021e4..1c85b83 100644 (file)
@@ -7,6 +7,9 @@ open Util
 open OUnit
 
 (** util function *)
+let compile_string str =
+  ClosTrans.trans @@ Lisp.compile_string str
+
 let string_of_insts xs =
   let ys =
     String.concat "; \n\t" @@ List.map string_of_instruction xs in
index 0b90c47..3726205 100644 (file)
@@ -1,50 +1,56 @@
 open Base
 open Sexp
+open OUnit
 
-let assert_equal sexp str =
+let ok sexp str =
   let sexp' =
     parse_string str in
-    OUnit.assert_equal 
+    OUnit.assert_equal
       ~printer:(String.concat ";\n" $ List.map Sexp.to_string) 
       sexp 
       sexp'
-  
-test empty =
-    assert_equal [] "";
-    assert_equal [] "; foo bar"
 
-test int =
-    assert_equal [(Int 42)] "42";
-    assert_equal [(Int ~-42)] "-42"
-
-test bool =
-    assert_equal [(Bool true)]  "#t";
-    assert_equal [(Bool false)] "#f"
-
-test float =
-    assert_equal [(Float 42.)] "42."
-
-test string =
-    assert_equal [(String "")]        "\"\"";
-    assert_equal [(String "foo")]     "\"foo\"";
-    assert_equal [(String "foo\"x")]  "\"foo\\\"x\"";
-    assert_equal [(String "foo\"")]   "\"foo\\\"\"";
-
-test symbol =
-    assert_equal [(String "foo")]  "\"foo\"";
-    assert_equal [(String "+")]    "\"+\"";
-    assert_equal [(Symbol ".")]    "."
-
-test add =
-    assert_equal [List [Symbol "+";Int 1; Int 2]] "(+ 1 2)"
-
-test list =
-    assert_equal [List [Symbol "print";String "hello"]] "(print \"hello\")"
-
-test bracket_list =
-    assert_equal [List [Symbol "print";String "hello"]] "[print \"hello\"]"
-
-test quote =
-    assert_equal [List [Symbol "quote";Symbol "hello"]] "(quote hello)";
-    assert_equal [List [Symbol "quote";Symbol "hello"]] "'hello";
+let _ =
+  ("S expression module test" >::: [
+     "empty" >::
+       (fun () ->
+         ok [] "";
+         ok [] "; foo bar");
+     "int" >::
+       (fun () ->
+         ok [(Int 42)] "42";
+         ok [(Int ~-42)] "-42");
+     "bool" >::
+       (fun () ->
+         ok [(Bool true)]  "#t";
+         ok [(Bool false)] "#f");
+     "float" >::
+       (fun () ->
+         ok [(Float 42.)] "42.";
+         ok [(Float 42.5)] "42.5");
+     "string" >::
+       (fun () ->
+         ok [(String "")]        "\"\"";
+         ok [(String "foo")]     "\"foo\"";
+         ok [(String "foo\"x")]  "\"foo\\\"x\"";
+         ok [(String "foo\"")]   "\"foo\\\"\"");
+     "symbol" >::
+       (fun () ->
+         ok [(String "foo")]  "\"foo\"";
+         ok [(String "+")]    "\"+\"";
+         ok [(Symbol ".")]    ".");
+     "+" >::
+       (fun () ->
+         ok [List [Symbol "+";Int 1; Int 2]] "(+ 1 2)");
+     "call" >::
+       (fun () ->
+         ok [List [Symbol "print";String "hello"]] "(print \"hello\")");
+     "bracket" >::
+       (fun () ->
+         ok [List [Symbol "print";String "hello"]] "[print \"hello\"]");
+     "quote" >::
+       (fun () ->
+         ok [List [Symbol "quote";Symbol "hello"]] "(quote hello)";
+         ok [List [Symbol "quote";Symbol "hello"]] "'hello")
+   ]) +> run_test_tt
 
index 3b5d96b..eb398b3 100644 (file)
@@ -1,13 +1,9 @@
 open Base
 
-let assert_equal ?(msg="") =
-  OUnit.assert_equal ~msg:msg ~printer:Std.dump
-    
 let ok ?(msg="") =
   OUnit.assert_equal ~msg:msg ~printer:Std.dump
 
 let assert_raises =
   OUnit.assert_raises
 
-let compile_string str =
-  ClosTrans.trans @@ Lisp.compile_string str
+