94 lines
5.6 KiB
Nix
94 lines
5.6 KiB
Nix
{
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
outputs = { self, nixpkgs }: let
|
|
system = "x86_64-linux";
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in {
|
|
bigint-lib = pkgs.callPackage ./lib.nix { };
|
|
packages.${system}.default = with self.bigint-lib; pkgs.writeText "bigint-test" (let
|
|
toS' = x: if builtins.isBool x
|
|
then if x
|
|
then "true"
|
|
else "false"
|
|
else if isBigInt x then bigIntToString x
|
|
else toString x;
|
|
compare = name: f: x: y: "${name} ${bigIntToString x} ${bigIntToString y} = ${toS' (f x y)}";
|
|
in ''
|
|
${bigIntToString (toBigInt 123)}
|
|
${bigIntToString (toBigInt (-123))}
|
|
${bigIntToString (toBigInt (-0))}
|
|
${bigIntToString (toBigInt 0)}
|
|
|
|
${compare "bigIntEquals" bigIntEquals (toBigInt (0)) (toBigInt (1))}
|
|
${compare "bigIntEquals" bigIntEquals (toBigInt (-1)) (toBigInt (1))}
|
|
${compare "bigIntEquals" bigIntEquals (toBigInt (2)) (toBigInt (2))}
|
|
${compare "bigIntEquals" bigIntEquals (toBigInt (0)) (toBigInt (-0))}
|
|
|
|
${compare "bigIntGreaterThan" bigIntGreaterThan (toBigInt 0) (toBigInt 0)}
|
|
${compare "bigIntGreaterThan" bigIntGreaterThan (toBigInt 12345) (toBigInt 9999)}
|
|
${compare "bigIntGreaterThan" bigIntGreaterThan (toBigInt 9999) (toBigInt 12345)}
|
|
${compare "bigIntGreaterThan" bigIntGreaterThan (toBigInt 99999) (toBigInt 12345)}
|
|
${compare "bigIntGreaterThan" bigIntGreaterThan (toBigInt (-99999)) (toBigInt 12345)}
|
|
${compare "bigIntGreaterThan" bigIntGreaterThan (toBigInt 99999) (toBigInt (-12345))}
|
|
${compare "bigIntGreaterThan" bigIntGreaterThan (toBigInt (-99999)) (toBigInt (-12345))}
|
|
|
|
${compare "bigIntLessThan" bigIntLessThan (toBigInt 0) (toBigInt 0)}
|
|
${compare "bigIntLessThan" bigIntLessThan (toBigInt 12345) (toBigInt 9999)}
|
|
${compare "bigIntLessThan" bigIntLessThan (toBigInt 9999) (toBigInt 12345)}
|
|
${compare "bigIntLessThan" bigIntLessThan (toBigInt 99999) (toBigInt 12345)}
|
|
${compare "bigIntLessThan" bigIntLessThan (toBigInt (-99999)) (toBigInt 12345)}
|
|
${compare "bigIntLessThan" bigIntLessThan (toBigInt 99999) (toBigInt (-12345))}
|
|
${compare "bigIntLessThan" bigIntLessThan (toBigInt (-99999)) (toBigInt (-12345))}
|
|
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt 0) (toBigInt 0)}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt 1) (toBigInt 2)}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt 1) (toBigInt (-2))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt 5) (toBigInt (-10))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (-2)) (toBigInt 1)}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (-10)) (toBigInt 5)}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt 100000000) (toBigInt (-1))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (-1)) (toBigInt 100000000)}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt 200000000) (toBigInt (-2))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (-2)) (toBigInt 200000000)}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt 99) (toBigInt 99)}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (-1)) (toBigInt (-2))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (-99)) (toBigInt (-99))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (99)) (toBigInt (-99))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (-99)) (toBigInt (99))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt (-99)) (toBigInt (99))}
|
|
${compare "bigIntAdd" bigIntAdd (toBigInt 100000000) (toBigInt 1)}
|
|
|
|
${compare "bigIntSub" bigIntSub (toBigInt 0) (toBigInt 0)}
|
|
${compare "bigIntSub" bigIntSub (toBigInt 1) (toBigInt 2)}
|
|
${compare "bigIntSub" bigIntSub (toBigInt 100000000) (toBigInt (-1))}
|
|
${compare "bigIntSub" bigIntSub (toBigInt (-1)) (toBigInt 100000000)}
|
|
${compare "bigIntSub" bigIntSub (toBigInt 200000000) (toBigInt (-2))}
|
|
${compare "bigIntSub" bigIntSub (toBigInt (-2)) (toBigInt 200000000)}
|
|
${compare "bigIntSub" bigIntSub (toBigInt 99) (toBigInt 99)}
|
|
${compare "bigIntSub" bigIntSub (toBigInt (-1)) (toBigInt (-2))}
|
|
${compare "bigIntSub" bigIntSub (toBigInt (-99)) (toBigInt (-99))}
|
|
${compare "bigIntSub" bigIntSub (toBigInt (99)) (toBigInt (-99))}
|
|
${compare "bigIntSub" bigIntSub (toBigInt (-99)) (toBigInt (99))}
|
|
${compare "bigIntSub" bigIntSub (toBigInt (-99)) (toBigInt (99))}
|
|
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 0) (toBigInt 0)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 100) (toBigInt 0)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 100) (toBigInt 1)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 100) (toBigInt 2)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 100) (toBigInt 100)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 1) (toBigInt 2)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 100000000) (toBigInt (-1))}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt (-1)) (toBigInt 100000000)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 200000000) (toBigInt (-2))}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt (-2)) (toBigInt 200000000)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt 99) (toBigInt 99)}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt (-1)) (toBigInt (-2))}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt (-99)) (toBigInt (-99))}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt (99)) (toBigInt (-99))}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt (-99)) (toBigInt (99))}
|
|
${compare "bigIntMultiply" bigIntMultiply (toBigInt (-99)) (toBigInt (99))}
|
|
'');
|
|
};
|
|
}
|