mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Even more license tests
This commit is contained in:
parent
0a3084abc0
commit
f0cb181545
@ -5,6 +5,8 @@
|
|||||||
EXCLUDE_FILES=(
|
EXCLUDE_FILES=(
|
||||||
"libsolutil/picosha2.h"
|
"libsolutil/picosha2.h"
|
||||||
"test/libsolutil/UTF8.cpp"
|
"test/libsolutil/UTF8.cpp"
|
||||||
|
"test/libsolidity/syntaxTests/license/license_cr_endings.sol"
|
||||||
|
"test/libsolidity/syntaxTests/license/license_crlf_endings.sol"
|
||||||
"test/libsolidity/syntaxTests/license/license_whitespace_trailing.sol"
|
"test/libsolidity/syntaxTests/license/license_whitespace_trailing.sol"
|
||||||
)
|
)
|
||||||
EXCLUDE_FILES_JOINED=$(printf "%s\|" "${EXCLUDE_FILES[@]}")
|
EXCLUDE_FILES_JOINED=$(printf "%s\|" "${EXCLUDE_FILES[@]}")
|
||||||
|
@ -432,6 +432,124 @@ BOOST_AUTO_TEST_CASE(metadata_license_ignored_stray_unicode)
|
|||||||
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_bidi_marks)
|
||||||
|
{
|
||||||
|
char const* sourceCode =
|
||||||
|
"// \xE2\x80\xAE""0.3-LPG :reifitnedI-esneciL-XDPS\xE2\x80\xAC\n"
|
||||||
|
"// NOTE: The text above is reversed using Unicode directional marks. In raw form it would look like this:\n"
|
||||||
|
"// <LRO>0.3-LPG :reifitnedI-esneciL-XDPS<PDF>\n"
|
||||||
|
"contract C {}\n";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == nullopt);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_bottom)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract C {}
|
||||||
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_cr_endings)
|
||||||
|
{
|
||||||
|
char const* sourceCode =
|
||||||
|
"// SPDX-License-Identifier: GPL-3.0\r"
|
||||||
|
"contract C {}\r";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_crlf_endings)
|
||||||
|
{
|
||||||
|
char const* sourceCode =
|
||||||
|
"// SPDX-License-Identifier: GPL-3.0\r\n"
|
||||||
|
"contract C {}\r\n";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_in_string)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract C {
|
||||||
|
bytes license = "// SPDX-License-Identifier: GPL-3.0";
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == nullopt);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_in_contract)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract C {
|
||||||
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == nullopt);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_missing_colon)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
// SPDX-License-Identifier GPL-3.0
|
||||||
|
contract C {}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == nullopt);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_multiline)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
/* SPDX-License-Identifier: GPL-3.0 */
|
||||||
|
contract C {}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_natspec)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
/// SPDX-License-Identifier: GPL-3.0
|
||||||
|
contract C {}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_natspec_multiline)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
/** SPDX-License-Identifier: GPL-3.0 */
|
||||||
|
contract C {}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_no_whitespace)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
//SPDX-License-Identifier:GPL-3.0
|
||||||
|
contract C {}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_no_whitespace_multiline)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
/*SPDX-License-Identifier:GPL-3.0*/
|
||||||
|
contract C {}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(metadata_license_nonempty_line)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
pragma solidity >= 0.0; // SPDX-License-Identifier: GPL-3.0
|
||||||
|
contract C {}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(compileAndCheckLicenseMetadata("C", sourceCode) == "GPL-3.0");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
// 0.3-LPG :reifitnedI-esneciL-XDPS
|
||||||
|
// NOTE: The text above is reversed using Unicode directional marks. In raw form it would look like this:
|
||||||
|
// <LRO>0.3-LPG :reifitnedI-esneciL-XDPS<PDF>
|
||||||
|
contract C {}
|
3
test/libsolidity/syntaxTests/license/license_bottom.sol
Normal file
3
test/libsolidity/syntaxTests/license/license_bottom.sol
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
contract C {}
|
||||||
|
// SPDX-License-Identifier: GPL-3.0
|
@ -0,0 +1 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
// SPDX-License-Identifier: GPL-3.0
contract C {}
|
@ -0,0 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
contract C {}
|
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 1878: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
|
@ -0,0 +1,5 @@
|
|||||||
|
import "// SPDX-License-Identifier: GPL-3.0";
|
||||||
|
contract C {}
|
||||||
|
// ----
|
||||||
|
// Warning 1878: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
|
||||||
|
// ParserError 6275: (0-45): Source "// SPDX-License-Identifier: GPL-3.0" not found: File not supplied initially.
|
@ -0,0 +1,5 @@
|
|||||||
|
contract C {
|
||||||
|
bytes license = "// SPDX-License-Identifier: GPL-3.0";
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning 1878: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
|
@ -0,0 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
// SPDX-License-Identifier GPL-3.0
|
||||||
|
contract C {}
|
@ -0,0 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
/* SPDX-License-Identifier: GPL-3.0 */
|
||||||
|
contract C {}
|
@ -1,2 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
/// SPDX-License-Identifier: GPL-3.0
|
/// SPDX-License-Identifier: GPL-3.0
|
||||||
contract C {}
|
contract C {}
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
/** SPDX-License-Identifier: GPL-3.0 */
|
||||||
|
contract C {}
|
@ -0,0 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
//SPDX-License-Identifier:GPL-3.0
|
||||||
|
contract C {}
|
@ -0,0 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
/*SPDX-License-Identifier:GPL-3.0*/
|
||||||
|
contract C {}
|
@ -0,0 +1,3 @@
|
|||||||
|
// This test is actually useless, as the test suite adds the automatic preamble.
|
||||||
|
pragma solidity >= 0.0; // SPDX-License-Identifier: GPL-3.0
|
||||||
|
contract C {}
|
@ -1,2 +1,3 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
// NOTE: Trailing space at the end of the line above is intentional.
|
||||||
contract C {}
|
contract C {}
|
||||||
|
Loading…
Reference in New Issue
Block a user