Expose tez/tez division

This commit is contained in:
Tom Jack 2019-10-11 14:35:23 -05:00
parent d6badf030c
commit d87d0aab73
3 changed files with 16 additions and 1 deletions

View File

@ -438,6 +438,8 @@ module Typer = struct
then ok @@ t_int () else
if eq_1 a (t_tez ()) && eq_1 b (t_nat ())
then ok @@ t_tez () else
if eq_1 a (t_tez ()) && eq_1 b (t_tez ())
then ok @@ t_nat () else
simple_fail "Dividing with wrong types"
let mod_ = typer_2 "MOD" @@ fun a b ->

View File

@ -1,4 +1,12 @@
const add_tez : tez = 21mtz + 0.000021tz;
const sub_tez : tez = 21mtz - 20mtz;
(* is this enough? *)
(* This is not enough. *)
const not_enough_tez : tez = 4611686018427387903mtz;
const nat_mul_tez : tez = 1n * 100mtz;
const tez_mul_nat : tez = 100mtz * 10n;
const tez_div_tez1 : nat = 100mtz / 1mtz;
const tez_div_tez2 : nat = 100mtz / 90mtz;
const tez_div_tez3 : nat = 100mtz / 110mtz;

View File

@ -829,6 +829,11 @@ let tez_ligo () : unit result =
let%bind _ = expect_eq_evaluate program "add_tez" (e_mutez 42) in
let%bind _ = expect_eq_evaluate program "sub_tez" (e_mutez 1) in
let%bind _ = expect_eq_evaluate program "not_enough_tez" (e_mutez 4611686018427387903) in
let%bind _ = expect_eq_evaluate program "nat_mul_tez" (e_mutez 100) in
let%bind _ = expect_eq_evaluate program "tez_mul_nat" (e_mutez 1000) in
let%bind _ = expect_eq_evaluate program "tez_div_tez1" (e_nat 100) in
let%bind _ = expect_eq_evaluate program "tez_div_tez2" (e_nat 1) in
let%bind _ = expect_eq_evaluate program "tez_div_tez3" (e_nat 0) in
ok ()
let tez_mligo () : unit result =