diff options
author | chriseth <c@ethdev.com> | 2015-07-01 03:08:34 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-07-03 23:25:30 +0800 |
commit | a393acd0b26d6c9cc2bd7c74730fdfb9d6fc9ed6 (patch) | |
tree | b6d7098348915e3663cda20dc9c42d93b5af7bb2 /libsolidity/SolidityNameAndTypeResolution.cpp | |
parent | 3350f1d304c8f8ff01c2af506f7aca98bc9cdc40 (diff) | |
download | dexon-solidity-a393acd0b26d6c9cc2bd7c74730fdfb9d6fc9ed6.tar.gz dexon-solidity-a393acd0b26d6c9cc2bd7c74730fdfb9d6fc9ed6.tar.zst dexon-solidity-a393acd0b26d6c9cc2bd7c74730fdfb9d6fc9ed6.zip |
Struct constructors.
Diffstat (limited to 'libsolidity/SolidityNameAndTypeResolution.cpp')
-rw-r--r-- | libsolidity/SolidityNameAndTypeResolution.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index 4914ef97..50fcdbbe 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2056,6 +2056,47 @@ BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(struct_constructor) +{ + char const* sourceCode = R"( + contract C { + struct S { uint a; bool x; } + function f() { + S memory s = S(1, true); + } + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode)); +} + +BOOST_AUTO_TEST_CASE(struct_constructor_nested) +{ + char const* sourceCode = R"( + contract C { + struct X { uint x1; uint x2; } + struct S { uint s1; uint[3] s2; X s3; } + function f() { + uint[3] memory s2; + S memory s = S(1, s2, X(4, 5)); + } + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode)); +} + +BOOST_AUTO_TEST_CASE(struct_named_constructor) +{ + char const* sourceCode = R"( + contract C { + struct S { uint a; bool x; } + function f() { + S memory s = S({a: 1, x: true}); + } + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode)); +} + BOOST_AUTO_TEST_SUITE_END() } |