Skip to content

Commit

Permalink
Installation fixes + safe-string compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierleroy committed Oct 13, 2017
1 parent afa3e7c commit 1fc316b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 40 deletions.
6 changes: 6 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Release 1.1 (2017-10-13):

- Install .cmx files as well.
- Fix permissions on installed files.
- Make tests compatible with safe strings.

Release 1.0 (2017-06-04):

- Fix build rule for nums.cmxs.
Expand Down
9 changes: 5 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ OCAMLOPT=ocamlopt
OCAMLDEP=ocamldep
OCAMLMKLIB=ocamlmklib
OCAMLFIND=ocamlfind
INSTALL=install
INSTALL_DATA=install -m 644
INSTALL_DLL=install
STDLIBDIR=$(shell $(OCAMLC) -where)

include $(STDLIBDIR)/Makefile.config
Expand Down Expand Up @@ -74,7 +75,7 @@ nat_stubs.$(O): bng.h nat.h

TOINSTALL=nums.cma libnums.$(A) $(CMIS) $(CMIS:.cmi=.mli) $(CMIS:.cmi=.cmti)
ifneq "$(ARCH)" "none"
TOINSTALL+=nums.cmxa nums.$(A)
TOINSTALL+=nums.cmxa nums.$(A) $(CMIS:.cmi=.cmx)
endif
ifeq "$(NATDYNLINK)" "true"
TOINSTALL+=nums.cmxs
Expand All @@ -83,9 +84,9 @@ TOINSTALL_STUBS=dllnums.$(SO)

install:
$(OCAMLFIND) install num META
$(INSTALL) $(TOINSTALL) $(STDLIBDIR)
$(INSTALL_DATA) $(TOINSTALL) $(STDLIBDIR)
ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true"
$(INSTALL) $(TOINSTALL_STUBS) $(STDLIBDIR)/stublibs
$(INSTALL_DLL) $(TOINSTALL_STUBS) $(STDLIBDIR)/stublibs
endif

uninstall:
Expand Down
2 changes: 2 additions & 0 deletions test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ let end_tests () =
let eq = (==);;
let eq_int (i: int) (j: int) = (i = j);;
let eq_string (i: string) (j: string) = (i = j);;
let eq_bytes (i: bytes) (j: bytes) = (i = j);;
let eq_bytes_string (i: bytes) (j: string) = (i = Bytes.of_string j);;
let eq_nativeint (i: nativeint) (j: nativeint) = (i = j);;
let eq_int32 (i: int32) (j: int32) = (i = j);;
let eq_int64 (i: int64) (j: int64) = (i = j);;
Expand Down
72 changes: 36 additions & 36 deletions test/test_ratios.ml
Original file line number Diff line number Diff line change
Expand Up @@ -965,72 +965,72 @@ msd_ratio (create_ratio (big_int_of_int 0) (big_int_of_int 0))
testing_function "round_futur_last_digit"
;;

let s = "+123456" in
test 1 eq (round_futur_last_digit s 1 (pred (String.length s)),
let s = Bytes.of_string "+123456" in
test 1 eq (round_futur_last_digit s 1 (pred (Bytes.length s)),
false) &&
test 2 eq_string (s, "+123466")
test 2 eq_bytes_string (s, "+123466")
;;

let s = "123456" in
test 3 eq (round_futur_last_digit s 0 (String.length s), false) &&
test 4 eq_string (s, "123466")
let s = Bytes.of_string "123456" in
test 3 eq (round_futur_last_digit s 0 (Bytes.length s), false) &&
test 4 eq_bytes_string (s, "123466")
;;

let s = "-123456" in
test 5 eq (round_futur_last_digit s 1 (pred (String.length s)),
let s = Bytes.of_string "-123456" in
test 5 eq (round_futur_last_digit s 1 (pred (Bytes.length s)),
false) &&
test 6 eq_string (s, "-123466")
test 6 eq_bytes_string (s, "-123466")
;;

let s = "+123496" in
test 7 eq (round_futur_last_digit s 1 (pred (String.length s)),
let s = Bytes.of_string "+123496" in
test 7 eq (round_futur_last_digit s 1 (pred (Bytes.length s)),
false) &&
test 8 eq_string (s, "+123506")
test 8 eq_bytes_string (s, "+123506")
;;

let s = "123496" in
test 9 eq (round_futur_last_digit s 0 (String.length s), false) &&
test 10 eq_string (s, "123506")
let s = Bytes.of_string "123496" in
test 9 eq (round_futur_last_digit s 0 (Bytes.length s), false) &&
test 10 eq_bytes_string (s, "123506")
;;

let s = "-123496" in
test 11 eq (round_futur_last_digit s 1 (pred (String.length s)),
let s = Bytes.of_string "-123496" in
test 11 eq (round_futur_last_digit s 1 (pred (Bytes.length s)),
false) &&
test 12 eq_string (s, "-123506")
test 12 eq_bytes_string (s, "-123506")
;;

let s = "+996" in
test 13 eq (round_futur_last_digit s 1 (pred (String.length s)),
let s = Bytes.of_string "+996" in
test 13 eq (round_futur_last_digit s 1 (pred (Bytes.length s)),
true) &&
test 14 eq_string (s, "+006")
test 14 eq_bytes_string (s, "+006")
;;

let s = "996" in
test 15 eq (round_futur_last_digit s 0 (String.length s), true) &&
test 16 eq_string (s, "006")
let s = Bytes.of_string "996" in
test 15 eq (round_futur_last_digit s 0 (Bytes.length s), true) &&
test 16 eq_bytes_string (s, "006")
;;

let s = "-996" in
test 17 eq (round_futur_last_digit s 1 (pred (String.length s)),
let s = Bytes.of_string "-996" in
test 17 eq (round_futur_last_digit s 1 (pred (Bytes.length s)),
true) &&
test 18 eq_string (s, "-006")
test 18 eq_bytes_string (s, "-006")
;;

let s = "+6666666" in
test 19 eq (round_futur_last_digit s 1 (pred (String.length s)),
let s = Bytes.of_string "+6666666" in
test 19 eq (round_futur_last_digit s 1 (pred (Bytes.length s)),
false) &&
test 20 eq_string (s, "+6666676")
test 20 eq_bytes_string (s, "+6666676")
;;

let s = "6666666" in
test 21 eq (round_futur_last_digit s 0 (String.length s), false) &&
test 22 eq_string (s, "6666676")
let s = Bytes.of_string "6666666" in
test 21 eq (round_futur_last_digit s 0 (Bytes.length s), false) &&
test 22 eq_bytes_string (s, "6666676")
;;

let s = "-6666666" in
test 23 eq (round_futur_last_digit s 1 (pred (String.length s)),
let s = Bytes.of_string "-6666666" in
test 23 eq (round_futur_last_digit s 1 (pred (Bytes.length s)),
false) &&
test 24 eq_string (s, "-6666676")
test 24 eq_bytes_string (s, "-6666676")
;;

testing_function "approx_ratio_fix"
Expand Down

0 comments on commit 1fc316b

Please sign in to comment.