mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow splitting string literals into multiple parts
This commit is contained in:
@@ -505,7 +505,7 @@ BOOST_AUTO_TEST_CASE(valid_hex_literal)
|
||||
{
|
||||
Scanner scanner(CharStream("{ hex\"00112233FF\"", ""));
|
||||
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral);
|
||||
BOOST_CHECK_EQUAL(scanner.next(), Token::HexStringLiteral);
|
||||
BOOST_CHECK_EQUAL(scanner.currentLiteral(), std::string("\x00\x11\x22\x33\xFF", 5));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
contract test {
|
||||
function f() public pure returns (bytes32) {
|
||||
bytes32 escapeCharacters = hex"aa" hex"b";
|
||||
return escapeCharacters;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (108-112): Expected even number of hex-nibbles within double-quotes.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract test {
|
||||
function f() public pure returns (bytes32) {
|
||||
bytes32 escapeCharacters = hex"0000"
|
||||
hex"deaf"
|
||||
hex"feed";
|
||||
return escapeCharacters;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,10 @@
|
||||
contract test {
|
||||
function f() public pure returns (bytes32) {
|
||||
bytes32 escapeCharacters = hex"0000"
|
||||
"deaf"
|
||||
"feed";
|
||||
return escapeCharacters;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (118-124): Expected ';' but got 'StringLiteral'
|
||||
@@ -0,0 +1,8 @@
|
||||
contract test {
|
||||
function f() public pure returns (bytes32) {
|
||||
bytes32 escapeCharacters = hex"aa" hex"bb" "cc";
|
||||
return escapeCharacters;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (116-120): Expected ';' but got 'StringLiteral'
|
||||
@@ -0,0 +1,8 @@
|
||||
contract test {
|
||||
function f() public pure returns (bytes32) {
|
||||
bytes32 escapeCharacters = "foo" "bar" hex"aa";
|
||||
return escapeCharacters;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (112-119): Expected ';' but got 'HexStringLiteral'
|
||||
@@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function f() public pure returns (bytes32) {
|
||||
bytes32 escapeCharacters = "first" "second" "third";
|
||||
return escapeCharacters;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
Reference in New Issue
Block a user