Merge branch 'feature/tez-fix' into 'dev'
Add a little bit of tez tests, fix cameligo lexer bug See merge request ligolang/ligo!97
This commit is contained in:
commit
de057bc318
@ -276,7 +276,7 @@ rule scan = parse
|
|||||||
|
|
||||||
| integer as n { Token.Int (n, Z.of_string n) }
|
| integer as n { Token.Int (n, Z.of_string n) }
|
||||||
| integer as n "p" { Token.Nat (n ^ "p", Z.of_string n) }
|
| integer as n "p" { Token.Nat (n ^ "p", Z.of_string n) }
|
||||||
| integer as tz "tz" { Token.Mtz (tz ^ "tz", Z.of_string tz) }
|
| integer as tz "tz" { Token.Mtz (tz ^ "tz", Z.mul (Z.of_int 1_000_000) (Z.of_string tz)) }
|
||||||
| decimal as tz "tz" {
|
| decimal as tz "tz" {
|
||||||
match format_tz tz with
|
match format_tz tz with
|
||||||
Some z -> Token.Mtz (tz ^ "tz", z)
|
Some z -> Token.Mtz (tz ^ "tz", z)
|
||||||
|
4
src/test/contracts/tez.ligo
Normal file
4
src/test/contracts/tez.ligo
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
const add_tez : tez = 21mtz + 21mtz;
|
||||||
|
const sub_tez : tez = 21mtz - 20mtz;
|
||||||
|
(* is this enough? *)
|
||||||
|
const not_enough_tez : tez = 4611686018427387903mtz;
|
5
src/test/contracts/tez.mligo
Normal file
5
src/test/contracts/tez.mligo
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
let add_tez : tez = 0.000021tz + 0.000021tz
|
||||||
|
let sub_tez : tez = 0.000021tz - 0.000020tz
|
||||||
|
let not_enough_tez : tez = 4611686018427.387903tz
|
||||||
|
|
||||||
|
let add_more_tez : tez = 100tz + 10tz + 1tz + 0.1tz + 0.01tz + 0.001tz
|
@ -787,6 +787,21 @@ let website2_ligo () : unit result =
|
|||||||
e_pair (e_typed_list [] t_operation) (e_int (op 42 n)) in
|
e_pair (e_typed_list [] t_operation) (e_int (op 42 n)) in
|
||||||
expect_eq_n program "main" make_input make_expected
|
expect_eq_n program "main" make_input make_expected
|
||||||
|
|
||||||
|
let tez_ligo () : unit result =
|
||||||
|
let%bind program = type_file "./contracts/tez.ligo" in
|
||||||
|
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
|
||||||
|
ok ()
|
||||||
|
|
||||||
|
let tez_mligo () : unit result =
|
||||||
|
let%bind program = mtype_file "./contracts/tez.mligo" in
|
||||||
|
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 "add_more_tez" (e_mutez 111111000) in
|
||||||
|
ok ()
|
||||||
|
|
||||||
let main = test_suite "Integration (End to End)" [
|
let main = test_suite "Integration (End to End)" [
|
||||||
test "type alias" type_alias ;
|
test "type alias" type_alias ;
|
||||||
test "function" function_ ;
|
test "function" function_ ;
|
||||||
@ -844,6 +859,8 @@ let main = test_suite "Integration (End to End)" [
|
|||||||
test "lambda mligo" lambda_mligo ;
|
test "lambda mligo" lambda_mligo ;
|
||||||
test "lambda ligo" lambda_ligo ;
|
test "lambda ligo" lambda_ligo ;
|
||||||
(* test "lambda2 mligo" lambda2_mligo ; *)
|
(* test "lambda2 mligo" lambda2_mligo ; *)
|
||||||
|
test "tez (ligo)" tez_ligo ;
|
||||||
|
test "tez (mligo)" tez_mligo ;
|
||||||
test "website1 ligo" website1_ligo ;
|
test "website1 ligo" website1_ligo ;
|
||||||
test "website2 ligo" website2_ligo ;
|
test "website2 ligo" website2_ligo ;
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user