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
This commit is contained in:
RJ Catalano
2016-05-09 11:41:02 -05:00
committed by VoR0220
parent a1a2eac5fd
commit 93295ae8f8
5 changed files with 354 additions and 263 deletions
+298 -208
View File
@@ -3354,6 +3354,303 @@ 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"(
contract test {
function f() {
uint[fixed(3.56)] a;
}
}
)";
BOOST_CHECK(!success(text));
}
BOOST_AUTO_TEST_CASE(array_declaration_with_fixed_literal)
{
char const* text = R"(
contract test {
function f() {
uint[3.56] a;
}
}
)";
BOOST_CHECK(!success(text));
}
BOOST_AUTO_TEST_CASE(mapping_with_fixed_literal)
{
char const* text = R"(
contract test {
mapping(fixed => string) fixedString;
function f() {
fixedString[3.14] = "Pi";
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(inline_array_fixed_type)
{
char const* text = R"(
contract test {
function f() {
fixed[3] memory a = [fixed(3.5), fixed(4.1234), fixed(967.32)];
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(inline_array_fixed_rationals)
{
char const* text = R"(
contract test {
function f() {
ufixed8x16[3] memory a = [3.5, 4.1234, 2.5];
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(size_capabilities_of_fixed_point_types)
{
char const* text = R"(
contract test {
function f() {
ufixed0x64 a = 0.12345678;
ufixed8x0 b = 12345678.0;
ufixed0x64 c = 0.00000009;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(var_capable_of_holding_constant_rationals)
{
char const* text = R"(
contract test {
function f() {
var a = 0.12345678;
var b = 12345678.0;
var c = 0.00000009;
}
}
)";
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_CASE(valid_fraction_fixed_type)
{
char const* text = R"(
contract test {
function f(){
fixed8x8 a = (2**24)/127;
fixed0x8 b = 1/256;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(valid_fixed_types)
{
char const* text = R"(
contract test {
function f(){
fixed8x8 a = 87654321.12345678;
fixed16x16 b = a**2;
fixed24x24 c = b**3;
fixed32x32 d = b**2;
fixed40x40 e = a**5;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(fixed_type_int_conversion)
{
char const* text = R"(
contract test {
function f() {
uint128 a = 3;
int128 b = 4;
fixed c = b;
ufixed d = a;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(fixed_type_const_int_conversion)
{
char const* text = R"(
contract test {
function f() {
fixed c = 3;
ufixed d = 4;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(fixed_type_literal)
{
char const* text = R"(
contract test {
function f() {
fixed a = 3.14;
ufixed d = 2.555555;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(fixed_type_literal_expression)
{
char const* text = R"(
contract test {
function f() {
fixed a = 3.14 * 3;
ufixed b = 4 - 2.555555;
fixed c = 1.0 / 3.0;
ufixed d = 599 + .5367;
ufixed e = 35.245 % 12.9;
ufixed f = 1.2 % 2.00000;
fixed g = 2 ** -2;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(uint_array_declaration_with_fixed_type)
{
char const* text = R"(
@@ -3367,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 {
@@ -3543,216 +3840,9 @@ BOOST_AUTO_TEST_CASE(rational_bitand_binary_operation)
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(invalid_non_mod_8_fixed_types)
{
char const* text = R"(
contract test {
function f(){
fixed8x10 a = 12345678.1234567890;
}
}
)";
BOOST_CHECK(!success(text));
}
BOOST_AUTO_TEST_CASE(valid_fixed_types)
{
char const* text = R"(
contract test {
function f(){
fixed8x8 a = 87654321.12345678;
fixed16x16 b = a**2;
fixed24x24 c = b**(1.5);
fixed32x32 d = b**2;
fixed40x40 e = a**5;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(fixed_type_int_conversion)
{
char const* text = R"(
contract test {
function f() {
uint128 a = 3;
int128 b = 4;
fixed c = b;
ufixed d = a;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(fixed_type_const_int_conversion)
{
char const* text = R"(
contract test {
function f() {
fixed c = 3;
ufixed d = 4;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(fixed_type_literal)
{
char const* text = R"(
contract test {
function f() {
fixed a = 3.14;
ufixed d = 2.555555;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(fixed_type_literal_expression)
{
char const* text = R"(
contract test {
function f() {
fixed a = 3.14 * 3;
ufixed b = 4 - 2.555555;
fixed c = 1.0 / 3.0;
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;
}
}
)";
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"(
contract test {
function f() {
uint[fixed(3.56)] a;
}
}
)";
BOOST_CHECK(!success(text));
}
BOOST_AUTO_TEST_CASE(array_declaration_with_fixed_literal)
{
char const* text = R"(
contract test {
function f() {
uint[3.56] a;
}
}
)";
BOOST_CHECK(!success(text));
}
BOOST_AUTO_TEST_CASE(mapping_with_fixed_literal)
{
char const* text = R"(
contract test {
mapping(fixed => string) fixedString;
function f() {
fixedString[3.14] = "Pi";
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(inline_array_fixed_type)
{
char const* text = R"(
contract test {
function f() {
fixed[3] memory a = [fixed(3.5), fixed(4.1234), fixed(967.32)];
}
}
)";
BOOST_CHECK(success(text));
}
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];
}
}
)";
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() {
fixed0x8 a = 0.12345678;
fixed8x0 b = 12345678.0;
fixed0x8 c = 0.00000009;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_CASE(var_capable_of_holding_fixed_constants)
{
char const* text = R"(
contract test {
function f() {
var a = 0.12345678;
var b = 12345678.0;
var c = 0.00000009;
}
}
)";
BOOST_CHECK(success(text));
}
BOOST_AUTO_TEST_SUITE_END()
}