From 165857b1d40ecb8a1bcf40eec9e371370ebe2541 Mon Sep 17 00:00:00 2001 From: Balajiganapathi S Date: Sat, 28 Oct 2017 16:33:11 +0530 Subject: Allow constant integer variables as array lengths. --- test/libsolidity/SolidityEndToEndTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/libsolidity/SolidityEndToEndTest.cpp') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 9a837113..c2f96aaa 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -2345,6 +2345,24 @@ BOOST_AUTO_TEST_CASE(constructor_static_array_argument) ABI_CHECK(callContractFunction("b(uint256)", u256(2)), encodeArgs(u256(4))); } +BOOST_AUTO_TEST_CASE(constant_var_as_array_length) +{ + char const* sourceCode = R"( + contract C { + uint constant LEN = 3; + uint[LEN] public a; + + function C(uint[LEN] _a) { + a = _a; + } + } + )"; + compileAndRun(sourceCode, 0, "C", encodeArgs(u256(1), u256(2), u256(3))); + ABI_CHECK(callContractFunction("a(uint256)", u256(0)), encodeArgs(u256(1))); + ABI_CHECK(callContractFunction("a(uint256)", u256(1)), encodeArgs(u256(2))); + ABI_CHECK(callContractFunction("a(uint256)", u256(2)), encodeArgs(u256(3))); +} + BOOST_AUTO_TEST_CASE(functions_called_by_constructor) { char const* sourceCode = R"( -- cgit v1.2.3 From 6dbc34e16ee8bda0e156ccb20a3fb8cb6ff52c92 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 21 Nov 2017 13:36:41 +0100 Subject: If statement for Iulia / inline assembly. --- test/libsolidity/SolidityEndToEndTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/libsolidity/SolidityEndToEndTest.cpp') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c2f96aaa..05dc9ba3 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -8032,6 +8032,24 @@ BOOST_AUTO_TEST_CASE(inline_assembly_embedded_function_call) ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1), u256(4), u256(7), u256(0x10))); } +BOOST_AUTO_TEST_CASE(inline_assembly_if) +{ + char const* sourceCode = R"( + contract C { + function f(uint a) returns (uint b) { + assembly { + if gt(a, 1) { b := 2 } + } + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + ABI_CHECK(callContractFunction("f(uint256)", u256(0)), encodeArgs(u256(0))); + ABI_CHECK(callContractFunction("f(uint256)", u256(1)), encodeArgs(u256(0))); + ABI_CHECK(callContractFunction("f(uint256)", u256(2)), encodeArgs(u256(2))); + ABI_CHECK(callContractFunction("f(uint256)", u256(3)), encodeArgs(u256(2))); +} + BOOST_AUTO_TEST_CASE(inline_assembly_switch) { char const* sourceCode = R"( -- cgit v1.2.3