export
Shell. +=
- ounit-postproc(argv) =
- (grep "FAIL\|ERROR\|Error\|Fail" && exit 1) || exit 0
ocaml-clean(argv) =
rm -f *.cm[aiox] *.o *.omc *.opt *.run *~ $(argv) *.cmxa *.a *.spot *.spit *.annot
# ------------------------------
-# rules
+# camlp4 rules
# ------------------------------
public.UseCamlp4(files) =
protected.CAMLP4CMO = $(addprefix $(ROOT)/camlp4/,$(addsuffix .cmo,$(files)))
.SCANNER: scan-ocaml-%.ml: %.ml $(CAMLP4CMO)
+# ------------------------------
+# ounit rules
+# ------------------------------
+OUNIT_SRC_DIR=../src/
+OUNIT_LIBS[]=
+
+Shell. +=
+ ounit-postproc(argv) =
+ (grep "FAIL\|ERROR\|Error\|Fail" && exit 1) || exit 0
+
+public.OUnitTest(name,files) =
+ .PHONY: check check-$(name) clean
+ protected.src_files = $(addprefix $(OUNIT_SRC_DIR),$(files))
+ OCamlProgram($(name),$(name) $(src_files) $(OUNIT_LIBS))
+
+ check-$(name): $(name)$(EXE)
+ ./$(name)$(EXE) | ounit-postproc
+
+ check: check-$(name)
+
+ clean:
+ rm -f $(name)$(EXE)
+
+ export
+
+# ------------------------------
+# other rules
+# ------------------------------t
%.mli : %.mlip
@rm -f $@
@echo "(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *)" > $@
.PHONY: check clean
-################################################
-# Configuration.
-#
-
-
-#
-# This project requires ocamlfind
-#
-
USE_OCAMLFIND = true
OCAMLPACKS[] =
extlib
eprintln(You need to install ocamlfind and run "omake --configure".)
exit 1
-#
-# Include path
-#
-OCAMLINCLUDES += ../src
-
-#
-# Compile native or byte code?
-#
-# The default values are defined as follows:
-#
NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
BYTE_ENABLED = true
-#
-# Various options
-#
-# OCAMLFLAGS +=
-# OCAMLCFLAGS +=
-# OCAMLOPTFLAGS +=
-# OCAML_LINK_FLAGS +=
-# OCAML_BYTE_LINK_FLAGS +=
-# OCAML_NATIVE_LINK_FLAGS +=
-
-
-################################################
-# Build an OCaml program
-#
-
-FILES[] =
- testRule
- colorTest
-
+OCAMLINCLUDES += ../src
OCAMLINCLUDES += $(ROOT)/base/
-OCAML_LIBS += $(ROOT)/base/base
-
-PROGRAM = runner
-OCAML_LIBS += ../src/habc
-
-# OCAML_CLIBS +=
-# OCAML_OTHER_LIBS +=
-# OCAML_LIB_FLAGS +=
-OCamlProgram($(PROGRAM), $(FILES))
-
-.DEFAULT: $(PROGRAM)$(EXE)
+OCAML_LIBS += $(ROOT)/base/base
-check: $(PROGRAM)$(EXE)
- ./$(PROGRAM)$(EXE) | ounit-postproc
+OUnitTest(colorTest,color)
+OUnitTest(ruleTest,rule)
#
# PHONY TARGET
#
clean:
- ocaml-clean $(PROGRAM)
+ ocaml-clean
+
.PHONY: check clean
-################################################
-# Configuration.
-#
-
-
-#
-# This project requires ocamlfind
-#
-
USE_OCAMLFIND = true
OCAMLPACKS[] =
xml-light
eprintln(You need to install ocamlfind and run "omake --configure".)
exit 1
-#
-# Include path
-#
OCAMLINCLUDES += ../src
-#
-# Compile native or byte code?
-#
-# The default values are defined as follows:
-#
NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
BYTE_ENABLED = true
-#
-# Various options
-#
-# OCAMLFLAGS +=
-# OCAMLCFLAGS +=
-# OCAMLOPTFLAGS +=
-# OCAML_LINK_FLAGS +=
-# OCAML_BYTE_LINK_FLAGS +=
-# OCAML_NATIVE_LINK_FLAGS +=
-
-
-################################################
-# Build an OCaml program
-#
-
FILES[] =
testSupport
byteTest
swfmillTest
codeTest
-OCAMLINCLUDES += ../../base/
-OCAML_LIBS += ../../base/base
-
-PROGRAM = runner
-OCAML_LIBS += ../src/habc-xml
-
-# OCAML_CLIBS +=
-# OCAML_OTHER_LIBS +=
-# OCAML_LIB_FLAGS +=
-
-
-
-OCamlProgram($(PROGRAM), $(FILES))
-
-.DEFAULT: $(PROGRAM)$(EXE)
+OCAMLINCLUDES += $(ROOT)/base/
+OCAML_LIBS += $(ROOT)/base/base
-check: $(PROGRAM)$(EXE)
- ./$(PROGRAM)$(EXE) | ounit-postproc
+OUnitTest(byteTest ,byte parsec)
+OUnitTest(abcTest ,abc parsec disasm byte)
+OUnitTest(swfmillTest,swfmill easyXml abc code byte disasm parsec)
+OUnitTest(codeTest ,code easyXml)
#
# PHONY TARGET
#
clean:
- ocaml-clean $(PROGRAM)
+ ocaml-clean
open Base
open OUnit
-open TestSupport
+
+let ok x y =
+ OUnit.assert_equal ~printer:Std.dump x y
+
+let example name =
+ let ch =
+ open_in_bin @@ Printf.sprintf "../example/%s.abc" name in
+ Abc.of_stream @@ Byte.of_channel ch
let abc =
example "hello"
let of_list xs =
Stream.of_list xs
+let ok x y =
+ OUnit.assert_equal ~printer:Std.dump x y
+
let tests = ("byte module test" >::: [
- "u8 is single byte" >::
- (fun _ ->
+ "u8 is single byte" >::
+ (fun _ ->
ok 0 (u8 @@ of_list [0]));
"u16 is little endian" >::
(fun _ ->
ok 0x3F_FFl (u30 @@ of_list [0xFF;0x7F]));
"u30 is 3 bytes when value <= 0x7F 0xFF 0xFF" >::
(fun _ ->
- ok 0x7FFFl (u30 @@ of_list [0xFF;0xFF;0x01]);
+ ok 0x7FFFl (u30 @@ of_list [0xFF;0xFF;0x01]);
ok 0x1F_FFFFl (u30 @@ of_list [0xFF;0xFF;0x7F]));
"u30 is 4 bytes when value <= 0x7F 0xFF 0xFF 0xFF" >::
(fun _ ->
open Xml
open EasyXml
+let example name =
+ let ch =
+ open_in_bin @@ Printf.sprintf "../example/%s.abc" name in
+ Abc.of_stream @@ Byte.of_channel ch
+
let ok x y =
OUnit.assert_equal ~printer:Xml.to_string_fmt (normalize x) (normalize y)
let abc =
- TestSupport.example "hello"
+ example "hello"
let cpool =
Swfmill.of_cpool abc#constant_pool
let method_bodies =
Swfmill.of_method_bodies abc#method_body
-
-let _ =
+
+let _ =
("action module test" >::: [
"constants" >::
(fun () ->
);
"method info" >::
(fun _ ->
- flip ok methods @@ elem "methods" [
- element
+ flip ok methods @@ elem "methods" [
+ element
"MethodInfo"
["retType" ,"0";
"nameIndex" ,"1";
attr "OpPushString" ["index","2"];
attr "OpCallPropLex" ["name","2";"argc","1"];
attr "OpPop" [];
- attr "OpReturnVoid" []; ];
+ attr "OpReturnVoid" []; ];
elem "exceptions" [];
elem "traits" [] ]
]);