Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ocaml-integers for openSUSE:Factory checked in at 2026-07-17 01:38:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ocaml-integers (Old) and /work/SRC/openSUSE:Factory/.ocaml-integers.new.24530 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ocaml-integers" Fri Jul 17 01:38:15 2026 rev:4 rq:1365552 version:0.8.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ocaml-integers/ocaml-integers.changes 2022-04-06 21:51:35.067503457 +0200 +++ /work/SRC/openSUSE:Factory/.ocaml-integers.new.24530/ocaml-integers.changes 2026-07-17 01:40:11.718590944 +0200 @@ -1,0 +2,6 @@ +Tue Jul 7 07:07:07 UTC 2026 - [email protected] + +- Update to version 0.8.0 + see included CHANGES.md file for details + +------------------------------------------------------------------- Old: ---- ocaml-integers-0.7.0.tar.xz New: ---- ocaml-integers-0.8.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ocaml-integers.spec ++++++ --- /var/tmp/diff_new_pack.8K16vk/_old 2026-07-17 01:40:12.346612150 +0200 +++ /var/tmp/diff_new_pack.8K16vk/_new 2026-07-17 01:40:12.350612284 +0200 @@ -1,7 +1,7 @@ # # spec file for package ocaml-integers # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,19 +16,17 @@ # Name: ocaml-integers -Version: 0.7.0 +Version: 0.8.0 Release: 0 %{?ocaml_preserve_bytecode} Summary: Various signed and unsigned integer types for OCaml License: MIT -Group: Development/Languages/OCaml - -URL: https://github.com/ocamllabs/ocaml-integers +ExclusiveArch: aarch64 ppc64le riscv64 s390x x86_64 +URL: https://opam.ocaml.org/packages/integers/ Source0: %name-%version.tar.xz - BuildRequires: ocaml BuildRequires: ocaml-dune -BuildRequires: ocaml-rpm-macros >= 20220222 +BuildRequires: ocaml-rpm-macros >= 20260707 BuildRequires: ocamlfind(stdlib-shims) %description @@ -38,8 +36,7 @@ %package devel Summary: Development files for %name -Group: Development/Languages/OCaml -Requires: %name = %version +Requires: %name = %version-%release %description devel The %name-devel package contains libraries and signature files for ++++++ _service ++++++ --- /var/tmp/diff_new_pack.8K16vk/_old 2026-07-17 01:40:12.406614176 +0200 +++ /var/tmp/diff_new_pack.8K16vk/_new 2026-07-17 01:40:12.410614311 +0200 @@ -1,7 +1,7 @@ <services> - <service name="tar_scm" mode="disabled"> + <service name="tar_scm" mode="manual"> <param name="filename">ocaml-integers</param> - <param name="revision">a494765d5bdc1f771eea56d552bd6c1d2ba971cd</param> + <param name="revision">7e4350eff1d1823530c5cade13f4472f2eeb2356</param> <param name="scm">git</param> <param name="submodules">disable</param> <param name="url">https://github.com/ocamllabs/ocaml-integers.git</param> @@ -9,10 +9,10 @@ <param name="versionrewrite-pattern">[v]?([^\+]+)(.*)</param> <param name="versionrewrite-replacement">\1</param> </service> - <service name="recompress" mode="disabled"> + <service name="recompress" mode="manual"> <param name="file">*.tar</param> <param name="compression">xz</param> </service> - <service name="set_version" mode="disabled"/> + <service name="set_version" mode="manual"/> </services> ++++++ ocaml-integers-0.7.0.tar.xz -> ocaml-integers-0.8.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/.github/workflows/test.yml new/ocaml-integers-0.8.0/.github/workflows/test.yml --- old/ocaml-integers-0.7.0/.github/workflows/test.yml 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/.github/workflows/test.yml 2026-05-18 10:27:16.000000000 +0200 @@ -1,51 +1,34 @@ name: Integers on: - - pull_request - - push - - workflow_dispatch + push: + branches: [ master ] + pull_request: + branches: [ master ] jobs: tests: strategy: fail-fast: false matrix: - include: - - os: ubuntu-latest - ocaml-compiler: 4.03.x - - os: ubuntu-latest - ocaml-compiler: 4.04.x - - os: ubuntu-latest - ocaml-compiler: 4.05.x - - os: ubuntu-latest - ocaml-compiler: 4.06.x - - os: ubuntu-latest - ocaml-compiler: 4.07.x - - os: ubuntu-latest - ocaml-compiler: 4.08.x - - os: ubuntu-latest - ocaml-compiler: 4.09.x - - os: ubuntu-latest - ocaml-compiler: 4.10.x - - os: ubuntu-latest - ocaml-compiler: 4.11.x - - os: ubuntu-latest - ocaml-compiler: 4.12.x - - os: ubuntu-latest - ocaml-compiler: 4.13.x - - os: windows-latest - ocaml-compiler: 4.13.1 - - os: macos-latest - ocaml-compiler: 4.13.1 + os: + - ubuntu-latest + - windows-latest + - macos-latest + + ocaml-compiler: + - 4.14 + - 5.2 + - 5.3 runs-on: ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v6 - name: Use OCaml ${{ matrix.ocaml-compiler }} - uses: ocaml/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: ${{ matrix.ocaml-compiler }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/.travis.yml new/ocaml-integers-0.8.0/.travis.yml --- old/ocaml-integers-0.7.0/.travis.yml 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,35 +0,0 @@ -language: c -sudo: required -install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh -script: bash -ex .travis-opam.sh -env: - - OCAML_VERSION=4.02 - - OCAML_VERSION=4.03 - - OCAML_VERSION=4.04 - - OCAML_VERSION=4.05 - - OCAML_VERSION=4.06 - - OCAML_VERSION=4.07 - - OCAML_VERSION=4.08 - - OCAML_VERSION=4.09 - - OCAML_VERSION=4.10 -os: - - linux - - osx -matrix: - exclude: - - os: osx - env: OCAML_VERSION=4.02 - - os: osx - env: OCAML_VERSION=4.03 - - os: osx - env: OCAML_VERSION=4.04 - - os: osx - env: OCAML_VERSION=4.05 - - os: osx - env: OCAML_VERSION=4.06 - - os: osx - env: OCAML_VERSION=4.07 - - os: osx - env: OCAML_VERSION=4.08 - - os: osx - env: OCAML_VERSION=4.09 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/CHANGES.md new/ocaml-integers-0.8.0/CHANGES.md --- old/ocaml-integers-0.7.0/CHANGES.md 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/CHANGES.md 2026-05-18 10:27:16.000000000 +0200 @@ -1,3 +1,9 @@ +v0.8.0 2026-05-18 +----------------- + +* add Signed.Int8 and Signed.Int16 modules (@tmcgilchrist, @brendanzab, @zbaylin, @yallop, #54) +* improve top-level printer installation (@brendanzab, #52) + v0.7.0 2022-03-23 ----------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/README.md new/ocaml-integers-0.8.0/README.md --- old/ocaml-integers-0.7.0/README.md 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/README.md 2026-05-18 10:27:16.000000000 +0200 @@ -57,6 +57,6 @@ [int32]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Int32.html [int64]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Int64.html [nativeint]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Nativeint.html -[doc]: https://ocamllabs.github.io/ocaml-integers/api.docdir/ +[doc]: https://yallop.github.io/ocaml-integers/api.docdir/ [integers_stubs_js]: https://github.com/o1-labs/integers_stubs_js [js_of_ocaml]: https://github.com/ocsigen/js_of_ocaml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/integers.opam new/ocaml-integers-0.8.0/integers.opam --- old/ocaml-integers-0.7.0/integers.opam 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/integers.opam 2026-05-18 10:27:16.000000000 +0200 @@ -16,7 +16,7 @@ ] depends: [ - "ocaml" {>= "4.02"} + "ocaml" {>= "4.03"} "dune" {>= "1.0"} "stdlib-shims" ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/src/ocaml_integers.h new/ocaml-integers-0.8.0/src/ocaml_integers.h --- old/ocaml-integers-0.7.0/src/ocaml_integers.h 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/src/ocaml_integers.h 2026-05-18 10:27:16.000000000 +0200 @@ -26,9 +26,15 @@ #define Integers_val_uint8(t) ((Val_int((uint8_t)t))) #define Integers_val_uint16(t) ((Val_int((uint16_t)t))) +#define Integers_val_int8(t) ((Val_int((int8_t)t))) +#define Integers_val_int16(t) ((Val_int((int16_t)t))) + #define Uint8_val(V) ((uint8_t)(Int_val(V))) #define Uint16_val(V) ((uint16_t)(Int_val(V))) #define Uint32_val(V) (*((uint32_t *) Data_custom_val(V))) #define Uint64_val(V) (*((uint64_t *) Data_custom_val(V))) +#define Int8_val(V) ((int8_t)(Int_val(V))) +#define Int16_val(V) ((int16_t)(Int_val(V))) + #endif /* INTEGERS_UNSIGNED_STUBS_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/src/signed.ml new/ocaml-integers-0.8.0/src/signed.ml --- old/ocaml-integers-0.7.0/src/signed.ml 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/src/signed.ml 2026-05-18 10:27:16.000000000 +0200 @@ -62,8 +62,78 @@ let (asr) = shift_right end +module type Small = sig + val bits : int +end + +module MakeSmall(S : Small) = +struct + let shift = Sys.int_size - S.bits + let trunc i = (i lsl shift) asr shift + + module Basics = + struct + type t = int + external to_int : t -> int = "%identity" + + let to_string i = Printf.sprintf "%d" i + let to_hexstring i = let m = 1 lsl S.bits in + Printf.sprintf "%x" ((i + m) mod m) + let max_int = pred (1 lsl pred S.bits) + let min_int = -(1 lsl pred S.bits) + let of_string s = + match int_of_string_opt s with + | Some i when i >= min_int && i <= max_int -> i + | _ -> Printf.ksprintf failwith "Int%d.of_string" S.bits + + let add : t -> t -> t = fun x y -> trunc (x + y) + let sub : t -> t -> t = fun x y -> trunc (x - y) + let mul : t -> t -> t = fun x y -> trunc (x * y) + let div : t -> t -> t = ( / ) + let rem : t -> t -> t = ( mod ) + let logand : t -> t -> t = ( land ) + let logor : t -> t -> t = ( lor ) + let logxor : t -> t -> t = ( lxor ) + let shift_left : t -> int -> t = fun x y -> trunc (x lsl y) + let shift_right : t -> int -> t = ( asr ) + let shift_right_logical : t -> int -> t = fun x y -> ((x lsl shift) lsr y) asr shift + let of_int : int -> t = trunc + let of_string_opt s = try Some (of_string s) with Failure _ -> None + let zero = 0 + let one = 1 + let minus_one = -1 + let lognot = lnot + let succ : t -> t = fun x -> trunc (Stdlib.succ x) + let pred : t -> t = fun x -> trunc (Stdlib.pred x) + let compare : t -> t -> int = Stdlib.compare + let equal : t -> t -> bool = Stdlib.( = ) + let min : t -> t -> t = Stdlib.min + let max : t -> t -> t = Stdlib.max + end + include Basics + module Infix = MakeInfix(Basics) + let pp fmt x = Format.fprintf fmt "%s" (to_string x) + let pp_hex fmt x = Format.fprintf fmt "%s" (to_hexstring x) + let neg = fun x -> trunc (- x) + let abs = fun x -> trunc (abs x) + let of_int64 = fun x -> trunc (Int64.to_int x) + let to_int64 = Int64.of_int + let of_nativeint = fun x -> trunc (Nativeint.to_int x) + let to_nativeint = Nativeint.of_int +end + external format_int : string -> int -> string = "caml_format_int" +module Int8 = MakeSmall( +struct + let bits = 8 +end) + +module Int16 = MakeSmall( +struct + let bits = 16 +end) + module Int = struct module Basics = @@ -111,11 +181,9 @@ let pp_hex fmt n = Format.fprintf fmt "%x" n end -module Int32 = +module Int32 = struct [@@@ocaml.warning "-32"] - (* Int32.equal was introduced in OCaml 4.03.0 *) - let equal (x:int32) (y:int32) = x = y (* Int32.of_string_opt was introduced in OCaml 4.5b0.0 *) let of_string_opt s = try Some (Int32.of_string s) with Failure _ -> None include Int32 @@ -131,11 +199,9 @@ let to_hexstring n = Format.asprintf "%lx" n end -module Int64 = +module Int64 = struct [@@@ocaml.warning "-32"] - (* Int64.equal was introduced in OCaml 4.03.0 *) - let equal (x:int64) (y:int64) = x = y (* Int32.of_string_opt was introduced in OCaml 4.5b0.0 *) let of_string_opt s = try Some (Int64.of_string s) with Failure _ -> None include Int64 @@ -155,6 +221,8 @@ external llong_size : unit -> int = "integers_ulonglong_size" let of_byte_size : int -> (module S) = function + | 1 -> (module Int8) + | 2 -> (module Int16) | 4 -> (module Int32) | 8 -> (module Int64) | _ -> invalid_arg "Signed.of_byte_size" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/src/signed.mli new/ocaml-integers-0.8.0/src/signed.mli --- old/ocaml-integers-0.7.0/src/signed.mli 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/src/signed.mli 2026-05-18 10:27:16.000000000 +0200 @@ -56,6 +56,12 @@ end (** Signed integer operations *) +module Int8 : S with type t = private int +(** Signed 8-bit integer type and operations. *) + +module Int16 : S with type t = private int +(** Signed 16-bit integer type and operations. *) + module Int : S with type t = int (** Signed integer type and operations. *) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/test/dune new/ocaml-integers-0.8.0/test/dune --- old/ocaml-integers-0.7.0/test/dune 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/test/dune 2026-05-18 10:27:16.000000000 +0200 @@ -1,5 +1,5 @@ (tests (package integers) (libraries integers) - (names hexprinting uint64conversions uint32conversions)) + (names hexprinting uint64conversions uint32conversions smallsint)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/test/hexprinting.ml new/ocaml-integers-0.8.0/test/hexprinting.ml --- old/ocaml-integers-0.7.0/test/hexprinting.ml 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/test/hexprinting.ml 2026-05-18 10:27:16.000000000 +0200 @@ -7,8 +7,12 @@ let () = print_endline "Hexstring test: ?" +let () = Printexc.record_backtrace true + let () = assert Signed.Int.(to_hexstring (of_string "0x23") = "23"); + assert Signed.Int8.(to_hexstring (of_string "0x23") = "23"); + assert Signed.Int16.(to_hexstring (of_string "0x23") = "23"); assert Signed.Int32.(to_hexstring (of_string "0x23") = "23"); assert Signed.Int64.(to_hexstring (of_string "0x23") = "23"); assert Unsigned.UInt8.(to_hexstring (of_string "0x23") = "23"); @@ -18,14 +22,21 @@ () let () = + assert Signed.Int.(to_hexstring (of_string "0xDeadBeef") = "deadbeef"); + assert Signed.Int8.(to_hexstring (of_string "0xD") = "d"); + assert Signed.Int16.(to_hexstring (of_string "0xDea") = "dea"); assert Signed.Int32.(to_hexstring (of_string "0xDeadBeef") = "deadbeef"); assert Signed.Int64.(to_hexstring (of_string "0xDeadBeef") = "deadbeef"); + assert Unsigned.UInt8.(to_hexstring (of_string "0xDe") = "de"); + assert Unsigned.UInt16.(to_hexstring (of_string "0xDead") = "dead"); assert Unsigned.UInt32.(to_hexstring (of_string "0xDeadBeef") = "deadbeef"); assert Unsigned.UInt64.(to_hexstring (of_string "0xDeadBeef") = "deadbeef"); () let () = assert Signed.Int.(to_hexstring (of_string "0x0") = "0"); + assert Signed.Int8.(to_hexstring (of_string "0x0") = "0"); + assert Signed.Int16.(to_hexstring (of_string "0x0") = "0"); assert Signed.Int32.(to_hexstring (of_string "0x0") = "0"); assert Signed.Int64.(to_hexstring (of_string "0x0") = "0"); assert Unsigned.UInt8.(to_hexstring (of_string "0x0") = "0"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/test/smallsint.ml new/ocaml-integers-0.8.0/test/smallsint.ml --- old/ocaml-integers-0.7.0/test/smallsint.ml 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-integers-0.8.0/test/smallsint.ml 2026-05-18 10:27:16.000000000 +0200 @@ -0,0 +1,417 @@ +let () = print_endline "Small signed int operations test: ?" + +(* --- Int8 tests --- *) + +(* Asserting max and min integers are correct *) +let () = + let open Signed.Int8 in + assert (to_int max_int = 127); + assert (to_int min_int = (-128)); + () + +(* Asserting that of_int truncates to 8 bits *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 0 zero); + assert (check 1 one); + assert (check (-1) minus_one); + assert (check 127 (of_int 127)); + (* of_int truncates: 128 wraps to -128 in 8-bit signed *) + assert (check (-128) (of_int 128)); + assert (check (-64) (of_int 192)); + () + +(* Asserting that roundtrip int -> string -> int conversions survive *) +let () = + let open Signed.Int8 in + let check i = + let str = to_string i in + equal i (of_string str) + in + assert (check (of_int 0)); + assert (check (of_int 1)); + assert (check (of_int 127)); + assert (check (of_int (-1))); + assert (check (of_int (-128))); + () + +(* Asserting that addition performs as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 1 (add zero one)); + assert (check (-128) (add max_int one)); + assert (check (-65) (add max_int (of_int 64))); + () + +(* Asserting that subtraction performs as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check (-1) (sub zero one)); + assert (check 127 (sub min_int one)); + assert (check 64 (sub min_int (of_int 64))); + () + +(* Asserting that multiplication performs as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check (-1) (mul minus_one one)); + assert (check (-128) (mul minus_one min_int)); + assert (check (-2) (mul max_int (of_int 2))); + () + +(* Asserting that division and remainder perform as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 63 (div max_int (of_int 2))); + assert (check (-64) (div min_int (of_int 2))); + assert (check 1 (rem max_int (of_int 2))); + assert (check 0 (rem min_int (of_int 2))); + () + +(* Asserting that bitwise operations perform as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 0 (logand (of_int 0x0F) (of_int 0x70))); + assert (check 0x7F (logor (of_int 0x0F) (of_int 0x70))); + assert (check 0x7F (logxor (of_int 0x0F) (of_int 0x70))); + assert (check 0 (logxor max_int max_int)); + assert (check 0 (logand zero max_int)); + assert (check (-1) (lognot zero)); + assert (check 0 (lognot minus_one)); + () + +(* Asserting that shift operations perform as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 2 (shift_left one 1)); + assert (check (-128) (shift_left one 7)); + assert (check (-1) (shift_right minus_one 1)); + assert (check 63 (shift_right max_int 1)); + assert (check (-1) (shift_right_logical minus_one 0)); + assert (check 127 (shift_right_logical minus_one 1)); + () + +(* Asserting that neg and abs perform as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check (-1) (neg one)); + assert (check 1 (neg minus_one)); + assert (check 1 (abs one)); + assert (check 1 (abs minus_one)); + assert (check 127 (abs max_int)); + () + +(* Asserting that succ and pred perform as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 1 (succ zero)); + assert (check (-1) (pred zero)); + assert (check (-128) (succ max_int)); + assert (check 127 (pred min_int)); + () + +(* Asserting that compare and equal perform as expected *) +let () = + let open Signed.Int8 in + assert (equal zero zero); + assert (equal max_int max_int); + assert (not (equal zero one)); + assert (compare zero one < 0); + assert (compare one zero > 0); + assert (compare min_int max_int < 0); + assert (Stdlib.( = ) (max zero one) one); + assert (Stdlib.( = ) (min zero one) zero); + () + +(* Asserting that integer parsing performs as expected *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 1 (of_string "1")); + assert (check 127 (of_string "127")); + assert (check (-128) (of_string "-128")); + assert (try (ignore (of_string "128"); false) with Failure _ -> true); + assert (try (ignore (of_string "-129"); false) with Failure _ -> true); + assert (check (-1) (of_string "-1")); + assert (check 0b01 (of_string "0b01")); + assert (check (-0b01) (of_string "-0b01")); + assert (check 0xf (of_string "0xf")); + assert (check (-0xf) (of_string "-0xf")); + assert (check 0x7f (of_string "0x7f")); + assert (check (-0x80) (of_string "-0x80")); + assert (try (ignore (of_string "0x80"); false) with Failure _ -> true); + assert (try (ignore (of_string "-0x81"); false) with Failure _ -> true); + assert (Signed.Int8.of_string_opt "127" <> None); + assert (Signed.Int8.of_string_opt "bad" = None); + () + +(* Asserting that integer printing performs as expected *) +let () = + let open Signed.Int8 in + assert (to_string one = "1"); + assert (to_string (of_int 127) = "127"); + (* of_int truncates: 128 wraps to -128 in 8-bit signed *) + assert (to_string (of_int 128) = "-128"); + assert (to_string (of_int (-128)) = "-128"); + (* of_int truncates: -129 wraps to 127 in 8-bit signed *) + assert (to_string (of_int (-129)) = "127"); + assert (to_string (of_int (-1)) = "-1"); + (* hexstring prints unsigned two's complement representation *) + assert (to_hexstring (of_int 0xf) = "f"); + assert (to_hexstring max_int = "7f"); + assert (to_hexstring min_int = "80"); + assert (to_hexstring (of_int (-0x7f)) = "81"); + () + +(* Asserting that of_int64/to_int64 conversions work *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 0 (of_int64 0L)); + assert (check 1 (of_int64 1L)); + assert (check 127 (of_int64 127L)); + assert (check (-128) (of_int64 128L)); + assert (Int64.equal (to_int64 one) 1L); + assert (Int64.equal (to_int64 minus_one) (-1L)); + assert (Int64.equal (to_int64 max_int) 127L); + assert (Int64.equal (to_int64 min_int) (-128L)); + () + +(* Asserting that of_nativeint/to_nativeint conversions work *) +let () = + let open Signed.Int8 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 0 (of_nativeint 0n)); + assert (check 127 (of_nativeint 127n)); + assert (check (-128) (of_nativeint 128n)); + assert (Nativeint.equal (to_nativeint one) 1n); + assert (Nativeint.equal (to_nativeint minus_one) (-1n)); + () + +(* --- Int16 tests --- *) + +(* Asserting max and min integers are correct *) +let () = + let open Signed.Int16 in + assert (to_int max_int = 32767); + assert (to_int min_int = (-32768)); + () + +(* Asserting that of_int truncates to 16 bits *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 0 zero); + assert (check 1 one); + assert (check (-1) minus_one); + assert (check 32767 (of_int 32767)); + (* of_int truncates: 32768 wraps to -32768 in 16-bit signed *) + assert (check (-32768) (of_int 32768)); + assert (check (-1) (of_int 65535)); + () + +(* Asserting that roundtrip int -> string -> int conversions survive *) +let () = + let open Signed.Int16 in + let check i = + let str = to_string i in + equal i (of_string str) + in + assert (check (of_int 0)); + assert (check (of_int 1)); + assert (check (of_int 32767)); + assert (check (of_int (-1))); + assert (check (of_int (-32768))); + () + +(* Asserting that addition performs as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 1 (add zero one)); + assert (check (-32768) (add max_int one)); + assert (check (-1) (add max_int (of_int 32768))); + () + +(* Asserting that subtraction performs as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check (-1) (sub zero one)); + assert (check 32767 (sub min_int one)); + () + +(* Asserting that multiplication performs as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check (-1) (mul minus_one one)); + assert (check (-32768) (mul minus_one min_int)); + assert (check (-2) (mul max_int (of_int 2))); + () + +(* Asserting that division and remainder perform as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 16383 (div max_int (of_int 2))); + assert (check (-16384) (div min_int (of_int 2))); + assert (check 1 (rem max_int (of_int 2))); + assert (check 0 (rem min_int (of_int 2))); + () + +(* Asserting that bitwise operations perform as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 0 (logand (of_int 0x00FF) (of_int 0x7F00))); + assert (check 0x7FFF (logor (of_int 0x00FF) (of_int 0x7F00))); + assert (check 0x7FFF (logxor (of_int 0x00FF) (of_int 0x7F00))); + assert (check 0 (logxor max_int max_int)); + assert (check (-1) (lognot zero)); + assert (check 0 (lognot minus_one)); + () + +(* Asserting that shift operations perform as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 2 (shift_left one 1)); + assert (check (-32768) (shift_left one 15)); + assert (check (-1) (shift_right minus_one 1)); + assert (check 16383 (shift_right max_int 1)); + assert (check (-1) (shift_right_logical minus_one 0)); + assert (check 32767 (shift_right_logical minus_one 1)); + () + +(* Asserting that neg and abs perform as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check (-1) (neg one)); + assert (check 1 (neg minus_one)); + assert (check 1 (abs one)); + assert (check 1 (abs minus_one)); + assert (check 32767 (abs max_int)); + () + +(* Asserting that succ and pred perform as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 1 (succ zero)); + assert (check (-1) (pred zero)); + assert (check (-32768) (succ max_int)); + assert (check 32767 (pred min_int)); + () + +(* Asserting that compare and equal perform as expected *) +let () = + let open Signed.Int16 in + assert (equal zero zero); + assert (equal max_int max_int); + assert (not (equal zero one)); + assert (compare zero one < 0); + assert (compare one zero > 0); + assert (compare min_int max_int < 0); + assert (Stdlib.( = ) (max zero one) one); + assert (Stdlib.( = ) (min zero one) zero); + () + +(* Asserting that integer parsing performs as expected *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 1 (of_string "1")); + assert (check 32767 (of_string "32767")); + assert (check (-32768) (of_string "-32768")); + assert (try (ignore (of_string "32768"); false) with Failure _ -> true); + assert (try (ignore (of_string "-32769"); false) with Failure _ -> true); + assert (check (-1) (of_string "-1")); + assert (check 0b01 (of_string "0b01")); + assert (check (-0b01) (of_string "-0b01")); + assert (check 0xff (of_string "0xff")); + assert (check (-0xff) (of_string "-0xff")); + assert (check 0x7fff (of_string "0x7fff")); + assert (check (-0x8000) (of_string "-0x8000")); + assert (try (ignore (of_string "0x8000"); false) with Failure _ -> true); + assert (try (ignore (of_string "-0x8001"); false) with Failure _ -> true); + assert (Signed.Int16.of_string_opt "32767" <> None); + assert (Signed.Int16.of_string_opt "bad" = None); + () + +(* Asserting that integer printing performs as expected *) +let () = + let open Signed.Int16 in + assert (to_string one = "1"); + assert (to_string (of_int 32767) = "32767"); + (* of_int truncates: 32768 wraps to -32768 in 16-bit signed *) + assert (to_string (of_int 32768) = "-32768"); + assert (to_string (of_int (-32768)) = "-32768"); + assert (to_string (of_int (-1)) = "-1"); + (* hexstring prints unsigned two's complement representation *) + assert (to_hexstring (of_int 0xff) = "ff"); + assert (to_hexstring max_int = "7fff"); + assert (to_hexstring min_int = "8000"); + assert (to_hexstring (of_int (-1)) = "ffff"); + () + +(* Asserting that of_int64/to_int64 conversions work *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 0 (of_int64 0L)); + assert (check 1 (of_int64 1L)); + assert (check 32767 (of_int64 32767L)); + assert (check (-32768) (of_int64 32768L)); + assert (Int64.equal (to_int64 one) 1L); + assert (Int64.equal (to_int64 minus_one) (-1L)); + assert (Int64.equal (to_int64 max_int) 32767L); + assert (Int64.equal (to_int64 min_int) (-32768L)); + () + +(* Asserting that of_nativeint/to_nativeint conversions work *) +let () = + let open Signed.Int16 in + let check expected res = + Stdlib.( = ) expected (to_int res) in + assert (check 0 (of_nativeint 0n)); + assert (check 32767 (of_nativeint 32767n)); + assert (check (-32768) (of_nativeint 32768n)); + assert (Nativeint.equal (to_nativeint one) 1n); + assert (Nativeint.equal (to_nativeint minus_one) (-1n)); + () + +let () = print_endline "Small signed int operations test: ✓" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/top/dune new/ocaml-integers-0.8.0/top/dune --- old/ocaml-integers-0.7.0/top/dune 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/top/dune 2026-05-18 10:27:16.000000000 +0200 @@ -2,6 +2,5 @@ (name integers_top) (public_name integers.top) (modes byte) - (wrapped false) (synopsis "toplevel pretty printers") (libraries integers compiler-libs)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/top/install_integer_printers.ml new/ocaml-integers-0.8.0/top/install_integer_printers.ml --- old/ocaml-integers-0.7.0/top/install_integer_printers.ml 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/top/install_integer_printers.ml 2026-05-18 10:27:16.000000000 +0200 @@ -1,19 +1,17 @@ (* Adapted from Anil Madhavapeddy's ocaml-uri package. *) -let _ = Integer_printers.format_sint - -let printers = [ "Integer_printers.format_sint"; - "Integer_printers.format_long"; - "Integer_printers.format_llong"; - "Integer_printers.format_uchar"; - "Integer_printers.format_uint8"; - "Integer_printers.format_uint16"; - "Integer_printers.format_uint32"; - "Integer_printers.format_uint64"; - "Integer_printers.format_ushort"; - "Integer_printers.format_uint"; - "Integer_printers.format_ulong"; - "Integer_printers.format_ullong";] +let printers = [ "fun fmt v -> Format.fprintf fmt \"<sint %s>\" (Signed.SInt.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<long %s>\" (Signed.Long.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<llong %s>\" (Signed.LLong.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<uchar %s>\" (Unsigned.UChar.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<uint8 %s>\" (Unsigned.UInt8.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<uint16 %s>\" (Unsigned.UInt16.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<uint32 %s>\" (Unsigned.UInt32.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<uint64 %s>\" (Unsigned.UInt64.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<ushort %s>\" (Unsigned.UShort.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<uint %s>\" (Unsigned.UInt.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<ulong %s>\" (Unsigned.ULong.to_string v)"; + "fun fmt v -> Format.fprintf fmt \"<ullong %s>\" (Unsigned.ULLong.to_string v)";] let eval_string ?(print_outcome = false) ?(err_formatter = Format.err_formatter) str = @@ -21,12 +19,22 @@ let phrase = !Toploop.parse_toplevel_phrase lexbuf in Toploop.execute_phrase print_outcome err_formatter phrase -let rec install_printers = function - | [] -> true - | printer :: printers -> - let cmd = Printf.sprintf "#install_printer %s;;" printer in - eval_string cmd && install_printers printers +let install_printer printer = + begin + ignore (eval_string (Printf.sprintf "let _printer = %s;;" printer)); + ignore (eval_string (Printf.sprintf "#install_printer _printer;;")); + end + +let is_utop () = + Hashtbl.mem Toploop.directive_table "utop_help" [@@ocaml.warning "-3"] let () = - if not (install_printers printers) then - Format.eprintf "Problem installing integer-printers@." + (* Preload the toplevel environment and integers library if we are in utop. + This is done to ensure the required modules are in scope before the + printers are installed, as dune will not do this automatically. *) + if is_utop () then begin + Toploop.initialize_toplevel_env (); + ignore (eval_string "#require \"integers\";;"); + end; + + List.iter install_printer printers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/top/install_integer_printers.mli new/ocaml-integers-0.8.0/top/install_integer_printers.mli --- old/ocaml-integers-0.7.0/top/install_integer_printers.mli 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/top/install_integer_printers.mli 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -(* This file is intentionally left almost blank. *) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/top/integer_printers.ml new/ocaml-integers-0.8.0/top/integer_printers.ml --- old/ocaml-integers-0.7.0/top/integer_printers.ml 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/top/integer_printers.ml 1970-01-01 01:00:00.000000000 +0100 @@ -1,31 +0,0 @@ -(* - * Copyright (c) 2013 Jeremy Yallop. - * - * This file is distributed under the terms of the MIT License. - * See the file LICENSE for details. - *) - -let format_sint fmt v = - Format.fprintf fmt "<sint %s>" (Signed.SInt.to_string v) -let format_long fmt v = - Format.fprintf fmt "<long %s>" (Signed.Long.to_string v) -let format_llong fmt v = - Format.fprintf fmt "<llong %s>" (Signed.LLong.to_string v) -let format_uchar fmt v = - Format.fprintf fmt "<uchar %s>" (Unsigned.UChar.to_string v) -let format_uint8 fmt v = - Format.fprintf fmt "<uint8 %s>" (Unsigned.UInt8.to_string v) -let format_uint16 fmt v = - Format.fprintf fmt "<uint16 %s>" (Unsigned.UInt16.to_string v) -let format_uint32 fmt v = - Format.fprintf fmt "<uint32 %s>" (Unsigned.UInt32.to_string v) -let format_uint64 fmt v = - Format.fprintf fmt "<uint64 %s>" (Unsigned.UInt64.to_string v) -let format_ushort fmt v = - Format.fprintf fmt "<ushort %s>" (Unsigned.UShort.to_string v) -let format_uint fmt v = - Format.fprintf fmt "<uint %s>" (Unsigned.UInt.to_string v) -let format_ulong fmt v = - Format.fprintf fmt "<ulong %s>" (Unsigned.ULong.to_string v) -let format_ullong fmt v = - Format.fprintf fmt "<ullong %s>" (Unsigned.ULLong.to_string v) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-integers-0.7.0/top/integer_printers.mli new/ocaml-integers-0.8.0/top/integer_printers.mli --- old/ocaml-integers-0.7.0/top/integer_printers.mli 2022-03-23 18:13:12.000000000 +0100 +++ new/ocaml-integers-0.8.0/top/integer_printers.mli 1970-01-01 01:00:00.000000000 +0100 @@ -1,21 +0,0 @@ -(* - * Copyright (c) 2013 Jeremy Yallop. - * - * This file is distributed under the terms of the MIT License. - * See the file LICENSE for details. - *) - -open Format - -val format_sint : formatter -> Signed.SInt.t -> unit -val format_long : formatter -> Signed.Long.t -> unit -val format_llong : formatter -> Signed.LLong.t -> unit -val format_uchar : formatter -> Unsigned.UChar.t -> unit -val format_uint8 : formatter -> Unsigned.UInt8.t -> unit -val format_uint16 : formatter -> Unsigned.UInt16.t -> unit -val format_uint32 : formatter -> Unsigned.UInt32.t -> unit -val format_uint64 : formatter -> Unsigned.UInt64.t -> unit -val format_ushort : formatter -> Unsigned.UShort.t -> unit -val format_uint : formatter -> Unsigned.UInt.t -> unit -val format_ulong : formatter -> Unsigned.ULong.t -> unit -val format_ullong : formatter -> Unsigned.ULLong.t -> unit
