aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRJ Catalano <rcatalano@macsales.com>2016-03-19 04:03:26 +0800
committerVoR0220 <catalanor0220@gmail.com>2016-05-10 00:41:02 +0800
commit93295ae8f8e92d075584d10ac21374f83c43f759 (patch)
treeb87523b2ed6dcfd19b4edae3aa21f02af12e5165 /test
parenta1a2eac5fde0cd6f5aed206958434d655f9a194f (diff)
downloaddexon-solidity-93295ae8f8e92d075584d10ac21374f83c43f759.tar.gz
dexon-solidity-93295ae8f8e92d075584d10ac21374f83c43f759.tar.zst
dexon-solidity-93295ae8f8e92d075584d10ac21374f83c43f759.zip
got exponents up and working with their inverse, changed a few of the tests....something is working that likely shouldn't be
slight changes to how to flip the rational negative around...still trying to figure it out tests added updated tests odd differences in trying soltest from solc binary, let me know if you can replicate test not working for odd reason fixed test problem with fixed literals...still need a way to log this error broken up the tests, added some, changed some things in types and began compiler work moar tests and prepping for rebuilding much of the types.cpp file further fixing infinite loop still happening but it's somewhere in the fixedPoint methodd fractional bits needed algo improved! Eliminated 2 errors Corrected problems with the previous commit. No infinite loops. Actually appear to have corrected an error
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp172
1 files changed, 131 insertions, 41 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 9c41dab8..42d06fd7 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -3354,6 +3354,32 @@ BOOST_AUTO_TEST_CASE(fixed_type_literal_expression)
BOOST_CHECK(success(text));
}
+BOOST_AUTO_TEST_CASE(fixed_type_invalid_size_conversion)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed a = 1/3;
+ ufixed248x8 b = a + 2.5;
+ }
+ }
+ )";
+ BOOST_CHECK(!success(text));
+}
+
+BOOST_AUTO_TEST_CASE(fixed_type_valid_size_conversion)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed a = 1/3;
+ ufixed248x8 b = ufixed248x8(a) + 2.5;
+ }
+ }
+ )";
+ BOOST_CHECK(!success(text));
+}
+
BOOST_AUTO_TEST_CASE(uint_array_declaration_with_fixed_type)
{
char const* text = R"(
@@ -3366,7 +3392,6 @@ BOOST_AUTO_TEST_CASE(uint_array_declaration_with_fixed_type)
BOOST_CHECK(!success(text));
}
-
BOOST_AUTO_TEST_CASE(array_declaration_with_fixed_literal)
{
char const* text = R"(
@@ -3404,7 +3429,7 @@ BOOST_AUTO_TEST_CASE(inline_array_fixed_type)
BOOST_CHECK(success(text));
}
-BOOST_AUTO_TEST_CASE(inline_array_fixed_literals)
+BOOST_AUTO_TEST_CASE(inline_array_fixed_rationals)
{
char const* text = R"(
contract test {
@@ -3416,25 +3441,14 @@ BOOST_AUTO_TEST_CASE(inline_array_fixed_literals)
BOOST_CHECK(success(text));
}
-BOOST_AUTO_TEST_CASE(zero_and_eight_variants_fixed)
-{
- char const* text = R"(
- contract A {
- fixed8x0 someInt = 4;
- fixed0x8 half = 0.5;
- }
- )";
- BOOST_CHECK(success(text));
-}
-
BOOST_AUTO_TEST_CASE(size_capabilities_of_fixed_point_types)
{
char const* text = R"(
contract test {
function f() {
- ufixed0x8 a = 0.12345678;
+ ufixed0x64 a = 0.12345678;
ufixed8x0 b = 12345678.0;
- ufixed0x8 c = 0.00000009;
+ ufixed0x64 c = 0.00000009;
}
}
)";
@@ -3547,18 +3561,18 @@ BOOST_AUTO_TEST_CASE(rational_bitand_binary_operation)
BOOST_CHECK(success(text));
}
-
-BOOST_AUTO_TEST_CASE(invalid_non_mod_8_fixed_types)
+BOOST_AUTO_TEST_CASE(valid_fraction_fixed_type)
{
char const* text = R"(
contract test {
function f(){
- fixed8x10 a = 12345678.1234567890;
+ fixed8x8 a = (2**24)/127;
+ fixed0x8 b = 1/256;
}
}
)";
- BOOST_CHECK(!success(text));
+ BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(valid_fixed_types)
@@ -3568,7 +3582,7 @@ BOOST_AUTO_TEST_CASE(valid_fixed_types)
function f(){
fixed8x8 a = 87654321.12345678;
fixed16x16 b = a**2;
- fixed24x24 c = b**(1.5);
+ fixed24x24 c = b**3;
fixed32x32 d = b**2;
fixed40x40 e = a**5;
}
@@ -3630,27 +3644,13 @@ BOOST_AUTO_TEST_CASE(fixed_type_literal_expression)
ufixed d = 599 + .5367;
ufixed e = 35.245 % 12.9;
ufixed f = 1.2 % 2.00000;
- //fixed g = 2 ** -1.5;
- //fixed h = -3 ** -5.8;
+ fixed g = 2 ** -2;
}
}
)";
BOOST_CHECK(success(text));
}
-BOOST_AUTO_TEST_CASE(fixed_type_literal_seconds_and_wei)
-{
- char const* text = R"(
- contract test {
- function f() {
- fixed a = 3.14 wei;
- ufixed b = 4.5 seconds;
- }
- }
- )";
- BOOST_CHECK(!success(text));
-}
-
BOOST_AUTO_TEST_CASE(uint_array_declaration_with_fixed_type)
{
char const* text = R"(
@@ -3664,7 +3664,7 @@ BOOST_AUTO_TEST_CASE(uint_array_declaration_with_fixed_type)
}
-BOOST_AUTO_TEST_CASE(array_declaration_with_fixed_literal)
+BOOST_AUTO_TEST_CASE(array_declaration_with_rational)
{
char const* text = R"(
contract test {
@@ -3706,7 +3706,7 @@ BOOST_AUTO_TEST_CASE(inline_array_fixed_literals)
char const* text = R"(
contract test {
function f() {
- fixed[3] memory a = [3.5, 4.1234, 967.32];
+ ufixed8x16[3] memory a = [3.5, 4.1234, 2.5];
}
}
)";
@@ -3729,16 +3729,16 @@ BOOST_AUTO_TEST_CASE(size_capabilities_of_fixed_point_types)
char const* text = R"(
contract test {
function f() {
- fixed0x8 a = 0.12345678;
- fixed8x0 b = 12345678.0;
- fixed0x8 c = 0.00000009;
+ ufixed0x8 a = 0.12345678;
+ ufixed8x0 b = 12345678.0;
+ ufixed0x8 c = 0.00000009;
}
}
)";
BOOST_CHECK(success(text));
}
-BOOST_AUTO_TEST_CASE(var_capable_of_holding_fixed_constants)
+BOOST_AUTO_TEST_CASE(var_capable_of_holding_constant_rationals)
{
char const* text = R"(
contract test {
@@ -3752,6 +3752,96 @@ BOOST_AUTO_TEST_CASE(var_capable_of_holding_fixed_constants)
BOOST_CHECK(success(text));
}
+BOOST_AUTO_TEST_CASE(invalid_rational_exponent_usage)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed8x8 a = 3 ** 1.5;
+ fixed24x24 b = 2 ** (1/2);
+ fixed40x40 c = 42 ** (-1/4);
+ fixed48x48 d = 16 ** -0.33;
+ }
+ }
+ )";
+ BOOST_CHECK(!success(text));
+}
+
+BOOST_AUTO_TEST_CASE(fixed_point_casting_exponents)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed a = 3 ** fixed(1.5);
+ fixed b = 2 ** fixed(1/2);
+ fixed c = 42 ** fixed(-1/4);
+ fixed d = 16 ** fixed(-0.33);
+ }
+ }
+ )";
+ BOOST_CHECK(success(text));
+}
+
+BOOST_AUTO_TEST_CASE(rational_unary_operation)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed a = +3.5134;
+ fixed b = -2.5145;
+ }
+ }
+ )";
+ BOOST_CHECK(success(text));
+}
+
+BOOST_AUTO_TEST_CASE(rational_bitnot_unary_operation)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed a = ~3.56;
+ }
+ }
+ )";
+ BOOST_CHECK(!success(text));
+}
+
+BOOST_AUTO_TEST_CASE(rational_bitor_binary_operation)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed a = 1.56 | 3;
+ }
+ }
+ )";
+ BOOST_CHECK(!success(text));
+}
+
+BOOST_AUTO_TEST_CASE(rational_bitxor_binary_operation)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed a = 1.56 ^ 3;
+ }
+ }
+ )";
+ BOOST_CHECK(!success(text));
+}
+
+BOOST_AUTO_TEST_CASE(rational_bitand_binary_operation)
+{
+ char const* text = R"(
+ contract test {
+ function f() {
+ fixed a = 1.56 & 3;
+ }
+ }
+ )";
+ BOOST_CHECK(!success(text));
+}
BOOST_AUTO_TEST_SUITE_END()