From 29880946550649d93a93dbf6dcd4ef7fc1f099d5 Mon Sep 17 00:00:00 2001 From: Lukasz Rubaszewski Date: Thu, 21 Sep 2023 18:10:58 +0200 Subject: [PATCH] Add more failing compilation tests for pdec!() --- .../tests/dec_macros/src/dec_err_too_many_decimal_places.rs | 2 +- .../dec_macros/src/dec_err_too_many_decimal_places.stderr | 4 ++-- .../dec_macros/src/pdec_err_empty_fractional_part_1.rs | 5 +++++ .../dec_macros/src/pdec_err_empty_fractional_part_1.stderr | 5 +++++ .../dec_macros/src/pdec_err_empty_fractional_part_2.rs | 5 +++++ .../dec_macros/src/pdec_err_empty_fractional_part_2.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_empty_integral_part.rs | 5 +++++ .../dec_macros/src/pdec_err_empty_integral_part.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_expected_expr.rs | 5 +++++ .../tests/dec_macros/src/pdec_err_expected_expr.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_expr_not_supported.rs | 5 +++++ .../tests/dec_macros/src/pdec_err_expr_not_supported.stderr | 5 +++++ .../dec_macros/src/pdec_err_expr_unary_op_not_supported.rs | 5 +++++ .../src/pdec_err_expr_unary_op_not_supported.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_float_suffix.rs | 5 +++++ .../tests/dec_macros/src/pdec_err_float_suffix.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_int_suffix.rs | 5 +++++ .../tests/dec_macros/src/pdec_err_int_suffix.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_invalid_digit.rs | 5 +++++ .../tests/dec_macros/src/pdec_err_invalid_digit.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_literal_not_supported.rs | 5 +++++ .../dec_macros/src/pdec_err_literal_not_supported.stderr | 5 +++++ .../dec_macros/src/pdec_err_more_than_one_decimal_point.rs | 5 +++++ .../src/pdec_err_more_than_one_decimal_point.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_multiple_negations.rs | 5 +++++ .../tests/dec_macros/src/pdec_err_multiple_negations.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_negation_and_string.rs | 5 +++++ .../dec_macros/src/pdec_err_negation_and_string.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_overflow_1.rs | 6 ++++++ .../tests/dec_macros/src/pdec_err_overflow_1.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_overflow_2.rs | 5 +++++ .../tests/dec_macros/src/pdec_err_overflow_2.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_overflow_3.rs | 6 ++++++ .../tests/dec_macros/src/pdec_err_overflow_3.stderr | 5 +++++ .../tests/dec_macros/src/pdec_err_overflow_4.rs | 6 ++++++ .../tests/dec_macros/src/pdec_err_overflow_4.stderr | 5 +++++ .../dec_macros/src/pdec_err_too_many_decimal_places.rs | 5 +++++ .../dec_macros/src/pdec_err_too_many_decimal_places.stderr | 5 +++++ radix-engine-tests/tests/dec_macros/src/pdec_success.rs | 5 +++++ radix-engine-tests/tests/decimal.rs | 6 ++++-- 40 files changed, 195 insertions(+), 5 deletions(-) create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_1.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_1.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_2.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_2.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_empty_integral_part.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_empty_integral_part.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_expected_expr.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_expected_expr.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_expr_not_supported.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_expr_not_supported.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_expr_unary_op_not_supported.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_expr_unary_op_not_supported.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_float_suffix.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_float_suffix.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_int_suffix.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_int_suffix.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_invalid_digit.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_invalid_digit.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_literal_not_supported.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_literal_not_supported.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_more_than_one_decimal_point.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_more_than_one_decimal_point.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_multiple_negations.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_multiple_negations.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_negation_and_string.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_negation_and_string.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_1.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_1.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_2.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_2.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_3.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_3.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_4.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_4.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_too_many_decimal_places.rs create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_err_too_many_decimal_places.stderr create mode 100644 radix-engine-tests/tests/dec_macros/src/pdec_success.rs diff --git a/radix-engine-tests/tests/dec_macros/src/dec_err_too_many_decimal_places.rs b/radix-engine-tests/tests/dec_macros/src/dec_err_too_many_decimal_places.rs index 23d9ede929b..2394e84dd86 100644 --- a/radix-engine-tests/tests/dec_macros/src/dec_err_too_many_decimal_places.rs +++ b/radix-engine-tests/tests/dec_macros/src/dec_err_too_many_decimal_places.rs @@ -1,5 +1,5 @@ use radix_engine_interface::prelude::*; fn main() { - const X: Decimal = dec!(1.0000000000000000000000000); + const X: Decimal = dec!(1.0000000000000000001); } diff --git a/radix-engine-tests/tests/dec_macros/src/dec_err_too_many_decimal_places.stderr b/radix-engine-tests/tests/dec_macros/src/dec_err_too_many_decimal_places.stderr index 98ddd1aec0f..d0f16c918dd 100644 --- a/radix-engine-tests/tests/dec_macros/src/dec_err_too_many_decimal_places.stderr +++ b/radix-engine-tests/tests/dec_macros/src/dec_err_too_many_decimal_places.stderr @@ -1,5 +1,5 @@ error: A decimal cannot have more than eighteen decimal places. --> src/dec_err_too_many_decimal_places.rs:4:29 | -4 | const X: Decimal = dec!(1.0000000000000000000000000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4 | const X: Decimal = dec!(1.0000000000000000001); + | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_1.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_1.rs new file mode 100644 index 00000000000..5e71b3b7f5e --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_1.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: PreciseDecimal = pdec!(1.); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_1.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_1.stderr new file mode 100644 index 00000000000..4bbf709db8d --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_1.stderr @@ -0,0 +1,5 @@ +error: If there is a decimal point, the number must include at least one digit after it. + --> src/pdec_err_empty_fractional_part_1.rs:4:37 + | +4 | const X: PreciseDecimal = pdec!(1.); + | ^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_2.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_2.rs new file mode 100644 index 00000000000..8e9aa14b518 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_2.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!("1."); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_2.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_2.stderr new file mode 100644 index 00000000000..5f888de94fd --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_fractional_part_2.stderr @@ -0,0 +1,5 @@ +error: If there is a decimal point, the number must include at least one digit after it. + --> src/pdec_err_empty_fractional_part_2.rs:4:29 + | +4 | const X: Decimal = dec!("1."); + | ^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_integral_part.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_integral_part.rs new file mode 100644 index 00000000000..356f72f5a9d --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_integral_part.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: PreciseDecimal = pdec!(".0"); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_integral_part.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_integral_part.stderr new file mode 100644 index 00000000000..6867047726b --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_empty_integral_part.stderr @@ -0,0 +1,5 @@ +error: If there is a decimal point, the number must include at least one digit before it. Use a 0 if necessary. + --> src/pdec_err_empty_integral_part.rs:4:37 + | +4 | const X: PreciseDecimal = pdec!(".0"); + | ^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_expected_expr.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_expected_expr.rs new file mode 100644 index 00000000000..ddbcbbdd3ab --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_expected_expr.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!(.1); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_expected_expr.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_expected_expr.stderr new file mode 100644 index 00000000000..691e6c686ba --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_expected_expr.stderr @@ -0,0 +1,5 @@ +error: expected expression + --> src/pdec_err_expected_expr.rs:4:29 + | +4 | const X: Decimal = dec!(.1); + | ^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_not_supported.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_not_supported.rs new file mode 100644 index 00000000000..bfb19ca0973 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_not_supported.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!(a); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_not_supported.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_not_supported.stderr new file mode 100644 index 00000000000..48098a8ec7c --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_not_supported.stderr @@ -0,0 +1,5 @@ +error: This macro only supports string, integer and float literals. + --> src/pdec_err_expr_not_supported.rs:4:29 + | +4 | const X: Decimal = dec!(a); + | ^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_unary_op_not_supported.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_unary_op_not_supported.rs new file mode 100644 index 00000000000..aee012feeb4 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_unary_op_not_supported.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!(!1); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_unary_op_not_supported.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_unary_op_not_supported.stderr new file mode 100644 index 00000000000..a8982ffe16b --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_expr_unary_op_not_supported.stderr @@ -0,0 +1,5 @@ +error: This macro only supports string, integer and float literals. + --> src/pdec_err_expr_unary_op_not_supported.rs:4:29 + | +4 | const X: Decimal = dec!(!1); + | ^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_float_suffix.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_float_suffix.rs new file mode 100644 index 00000000000..fa6f8a03768 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_float_suffix.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!(11.12f64); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_float_suffix.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_float_suffix.stderr new file mode 100644 index 00000000000..2e71f7cbc0b --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_float_suffix.stderr @@ -0,0 +1,5 @@ +error: No suffix is allowed. Remove the f64. + --> src/pdec_err_float_suffix.rs:4:29 + | +4 | const X: Decimal = dec!(11.12f64); + | ^^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_int_suffix.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_int_suffix.rs new file mode 100644 index 00000000000..e7bdc225e49 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_int_suffix.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!(11_i64); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_int_suffix.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_int_suffix.stderr new file mode 100644 index 00000000000..f2adde67550 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_int_suffix.stderr @@ -0,0 +1,5 @@ +error: No suffix is allowed. Remove the i64. + --> src/pdec_err_int_suffix.rs:4:29 + | +4 | const X: Decimal = dec!(11_i64); + | ^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_invalid_digit.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_invalid_digit.rs new file mode 100644 index 00000000000..83456586b5e --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_invalid_digit.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!(11.12e3); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_invalid_digit.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_invalid_digit.stderr new file mode 100644 index 00000000000..9cb65ac7c1d --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_invalid_digit.stderr @@ -0,0 +1,5 @@ +error: There is an invalid character. + --> src/pdec_err_invalid_digit.rs:4:29 + | +4 | const X: Decimal = dec!(11.12e3); + | ^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_literal_not_supported.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_literal_not_supported.rs new file mode 100644 index 00000000000..4091d1e94ac --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_literal_not_supported.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!('a'); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_literal_not_supported.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_literal_not_supported.stderr new file mode 100644 index 00000000000..0020777a979 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_literal_not_supported.stderr @@ -0,0 +1,5 @@ +error: This macro only supports string, integer and float literals. + --> src/pdec_err_literal_not_supported.rs:4:29 + | +4 | const X: Decimal = dec!('a'); + | ^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_more_than_one_decimal_point.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_more_than_one_decimal_point.rs new file mode 100644 index 00000000000..2cf75486ad2 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_more_than_one_decimal_point.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!("1.000.0"); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_more_than_one_decimal_point.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_more_than_one_decimal_point.stderr new file mode 100644 index 00000000000..8cf114a1919 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_more_than_one_decimal_point.stderr @@ -0,0 +1,5 @@ +error: A decimal cannot have more than one decimal point. + --> src/pdec_err_more_than_one_decimal_point.rs:4:29 + | +4 | const X: Decimal = dec!("1.000.0"); + | ^^^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_multiple_negations.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_multiple_negations.rs new file mode 100644 index 00000000000..00b3a95fe1d --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_multiple_negations.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!(--1); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_multiple_negations.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_multiple_negations.stderr new file mode 100644 index 00000000000..c98760c32a4 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_multiple_negations.stderr @@ -0,0 +1,5 @@ +error: This macro only supports string, integer and float literals. + --> src/pdec_err_multiple_negations.rs:4:30 + | +4 | const X: Decimal = dec!(--1); + | ^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_negation_and_string.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_negation_and_string.rs new file mode 100644 index 00000000000..80c90e36eaa --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_negation_and_string.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!(-"112.3"); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_negation_and_string.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_negation_and_string.stderr new file mode 100644 index 00000000000..c2a618cef4b --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_negation_and_string.stderr @@ -0,0 +1,5 @@ +error: This macro only supports string, integer and float literals. + --> src/pdec_err_negation_and_string.rs:4:30 + | +4 | const X: Decimal = dec!(-"112.3"); + | ^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_1.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_1.rs new file mode 100644 index 00000000000..45f4da762a8 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_1.rs @@ -0,0 +1,6 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: PreciseDecimal = + pdec!(-57896044618658097711785492504343953926634.992332820282019728792003956564819969); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_1.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_1.stderr new file mode 100644 index 00000000000..c1837018b47 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_1.stderr @@ -0,0 +1,5 @@ +error: The number being too large to fit in a precise decimal + --> src/pdec_err_overflow_1.rs:5:16 + | +5 | pdec!(-57896044618658097711785492504343953926634.992332820282019728792003956564819969); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_2.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_2.rs new file mode 100644 index 00000000000..4b23f9669a7 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_2.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!("-3138550867693340381917894711603833208051.177722232017256449"); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_2.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_2.stderr new file mode 100644 index 00000000000..05199d13b5d --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_2.stderr @@ -0,0 +1,5 @@ +error: The number is too large to fit in a decimal. + --> src/pdec_err_overflow_2.rs:4:29 + | +4 | const X: Decimal = dec!("-3138550867693340381917894711603833208051.177722232017256449"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_3.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_3.rs new file mode 100644 index 00000000000..8accf5d23e6 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_3.rs @@ -0,0 +1,6 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: PreciseDecimal = + pdec!(57896044618658097711785492504343953926634.992332820282019728792003956564819968); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_3.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_3.stderr new file mode 100644 index 00000000000..7ede67ceca6 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_3.stderr @@ -0,0 +1,5 @@ +error: The number being too large to fit in a precise decimal + --> src/pdec_err_overflow_3.rs:5:15 + | +5 | pdec!(57896044618658097711785492504343953926634.992332820282019728792003956564819968); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_4.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_4.rs new file mode 100644 index 00000000000..1db316fdce7 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_4.rs @@ -0,0 +1,6 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: PreciseDecimal = + pdec!("57896044618658097711785492504343953926634.992332820282019728792003956564819968"); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_4.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_4.stderr new file mode 100644 index 00000000000..c0359e3f386 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_overflow_4.stderr @@ -0,0 +1,5 @@ +error: The number being too large to fit in a precise decimal + --> src/pdec_err_overflow_4.rs:5:15 + | +5 | pdec!("57896044618658097711785492504343953926634.992332820282019728792003956564819968"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_too_many_decimal_places.rs b/radix-engine-tests/tests/dec_macros/src/pdec_err_too_many_decimal_places.rs new file mode 100644 index 00000000000..87d6b204206 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_too_many_decimal_places.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: PreciseDecimal = pdec!(1.0000000000000000000000000000000000001); +} diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_err_too_many_decimal_places.stderr b/radix-engine-tests/tests/dec_macros/src/pdec_err_too_many_decimal_places.stderr new file mode 100644 index 00000000000..362bf2947c2 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_err_too_many_decimal_places.stderr @@ -0,0 +1,5 @@ +error: A precise decimal cannot have more than thirty-six decimal places. + --> src/pdec_err_too_many_decimal_places.rs:4:37 + | +4 | const X: PreciseDecimal = pdec!(1.0000000000000000000000000000000000001); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/radix-engine-tests/tests/dec_macros/src/pdec_success.rs b/radix-engine-tests/tests/dec_macros/src/pdec_success.rs new file mode 100644 index 00000000000..30f0c01d1d8 --- /dev/null +++ b/radix-engine-tests/tests/dec_macros/src/pdec_success.rs @@ -0,0 +1,5 @@ +use radix_engine_interface::prelude::*; + +fn main() { + const X: Decimal = dec!("1"); +} diff --git a/radix-engine-tests/tests/decimal.rs b/radix-engine-tests/tests/decimal.rs index dbe793ff5a6..0c1373b0dbd 100644 --- a/radix-engine-tests/tests/decimal.rs +++ b/radix-engine-tests/tests/decimal.rs @@ -8,7 +8,7 @@ use transaction::prelude::*; use trybuild; #[test] -fn test_dec_macro_try_build() { +fn test_dec_macro_try_compile() { // Change CARGO_MANIFEST_DIR to tests/dec_macros, where the dec_macros test crate is located. // By default 'trybuild' crate uses current manifest dir, but it does not work with // radix-engine-tests dir (presumably too complicated set of dependencies and features). @@ -24,6 +24,8 @@ fn test_dec_macro_try_build() { // Paths must be relative to the manifest_dir t.pass("src/dec_success.rs"); t.compile_fail("src/dec_err_*.rs"); + t.pass("src/pdec_success.rs"); + t.compile_fail("src/pdec_err_*.rs"); } #[test] @@ -87,7 +89,7 @@ fn test_dec_macro_valid() { } #[test] -fn test_pdec_macro() { +fn test_pdec_macro_valid() { let x1 = pdec!("1.1"); assert_eq!(x1, PreciseDecimal::try_from("1.1").unwrap());