mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
User-defined literal suffixes: Tests
This commit is contained in:
@@ -0,0 +1,264 @@
|
||||
{
|
||||
"absolutePath": "a",
|
||||
"exportedSymbols":
|
||||
{
|
||||
"C":
|
||||
[
|
||||
16
|
||||
],
|
||||
"str":
|
||||
[
|
||||
10
|
||||
]
|
||||
},
|
||||
"id": 17,
|
||||
"nodeType": "SourceUnit",
|
||||
"nodes":
|
||||
[
|
||||
{
|
||||
"body":
|
||||
{
|
||||
"id": 9,
|
||||
"nodeType": "Block",
|
||||
"src": "63:2:1",
|
||||
"statements": []
|
||||
},
|
||||
"id": 10,
|
||||
"implemented": true,
|
||||
"kind": "freeFunction",
|
||||
"modifiers": [],
|
||||
"name": "str",
|
||||
"nameLocation": "9:3:1",
|
||||
"nodeType": "FunctionDefinition",
|
||||
"parameters":
|
||||
{
|
||||
"id": 5,
|
||||
"nodeType": "ParameterList",
|
||||
"parameters":
|
||||
[
|
||||
{
|
||||
"constant": false,
|
||||
"id": 2,
|
||||
"mutability": "mutable",
|
||||
"name": "",
|
||||
"nameLocation": "-1:-1:-1",
|
||||
"nodeType": "VariableDeclaration",
|
||||
"scope": 10,
|
||||
"src": "13:6:1",
|
||||
"stateVariable": false,
|
||||
"storageLocation": "default",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_uint32",
|
||||
"typeString": "uint32"
|
||||
},
|
||||
"typeName":
|
||||
{
|
||||
"id": 1,
|
||||
"name": "uint32",
|
||||
"nodeType": "ElementaryTypeName",
|
||||
"src": "13:6:1",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_uint32",
|
||||
"typeString": "uint32"
|
||||
}
|
||||
},
|
||||
"visibility": "internal"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"id": 4,
|
||||
"mutability": "mutable",
|
||||
"name": "",
|
||||
"nameLocation": "-1:-1:-1",
|
||||
"nodeType": "VariableDeclaration",
|
||||
"scope": 10,
|
||||
"src": "21:4:1",
|
||||
"stateVariable": false,
|
||||
"storageLocation": "default",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_uint256",
|
||||
"typeString": "uint256"
|
||||
},
|
||||
"typeName":
|
||||
{
|
||||
"id": 3,
|
||||
"name": "uint",
|
||||
"nodeType": "ElementaryTypeName",
|
||||
"src": "21:4:1",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_uint256",
|
||||
"typeString": "uint256"
|
||||
}
|
||||
},
|
||||
"visibility": "internal"
|
||||
}
|
||||
],
|
||||
"src": "12:14:1"
|
||||
},
|
||||
"returnParameters":
|
||||
{
|
||||
"id": 8,
|
||||
"nodeType": "ParameterList",
|
||||
"parameters":
|
||||
[
|
||||
{
|
||||
"constant": false,
|
||||
"id": 7,
|
||||
"mutability": "mutable",
|
||||
"name": "",
|
||||
"nameLocation": "-1:-1:-1",
|
||||
"nodeType": "VariableDeclaration",
|
||||
"scope": 10,
|
||||
"src": "48:13:1",
|
||||
"stateVariable": false,
|
||||
"storageLocation": "memory",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_string_memory_ptr",
|
||||
"typeString": "string"
|
||||
},
|
||||
"typeName":
|
||||
{
|
||||
"id": 6,
|
||||
"name": "string",
|
||||
"nodeType": "ElementaryTypeName",
|
||||
"src": "48:6:1",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_string_storage_ptr",
|
||||
"typeString": "string"
|
||||
}
|
||||
},
|
||||
"visibility": "internal"
|
||||
}
|
||||
],
|
||||
"src": "47:15:1"
|
||||
},
|
||||
"scope": 17,
|
||||
"src": "0:65:1",
|
||||
"stateMutability": "pure",
|
||||
"suffix": true,
|
||||
"virtual": false,
|
||||
"visibility": "internal"
|
||||
},
|
||||
{
|
||||
"abstract": false,
|
||||
"baseContracts": [],
|
||||
"canonicalName": "C",
|
||||
"contractDependencies": [],
|
||||
"contractKind": "contract",
|
||||
"fullyImplemented": true,
|
||||
"id": 16,
|
||||
"linearizedBaseContracts":
|
||||
[
|
||||
16
|
||||
],
|
||||
"name": "C",
|
||||
"nameLocation": "75:1:1",
|
||||
"nodeType": "ContractDefinition",
|
||||
"nodes":
|
||||
[
|
||||
{
|
||||
"constant": false,
|
||||
"id": 15,
|
||||
"mutability": "mutable",
|
||||
"name": "s",
|
||||
"nameLocation": "90:1:1",
|
||||
"nodeType": "VariableDeclaration",
|
||||
"scope": 16,
|
||||
"src": "83:26:1",
|
||||
"stateVariable": true,
|
||||
"storageLocation": "default",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_string_storage",
|
||||
"typeString": "string"
|
||||
},
|
||||
"typeName":
|
||||
{
|
||||
"id": 11,
|
||||
"name": "string",
|
||||
"nodeType": "ElementaryTypeName",
|
||||
"src": "83:6:1",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_string_storage_ptr",
|
||||
"typeString": "string"
|
||||
}
|
||||
},
|
||||
"value":
|
||||
{
|
||||
"arguments":
|
||||
[
|
||||
{
|
||||
"hexValue": "3132332e3334355f373839",
|
||||
"id": 12,
|
||||
"isConstant": false,
|
||||
"isLValue": false,
|
||||
"isPure": true,
|
||||
"kind": "number",
|
||||
"lValueRequested": false,
|
||||
"nodeType": "Literal",
|
||||
"src": "94:11:1",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_rational_123345789_by_1000000",
|
||||
"typeString": "rational_const 123345789 / 1000000"
|
||||
},
|
||||
"value": "123.345_789"
|
||||
}
|
||||
],
|
||||
"expression":
|
||||
{
|
||||
"argumentTypes":
|
||||
[
|
||||
{
|
||||
"typeIdentifier": "t_rational_123345789_by_1000000",
|
||||
"typeString": "rational_const 123345789 / 1000000"
|
||||
}
|
||||
],
|
||||
"id": 13,
|
||||
"name": "str",
|
||||
"nodeType": "Identifier",
|
||||
"overloadedDeclarations": [],
|
||||
"referencedDeclaration": 10,
|
||||
"src": "106:3:1",
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_function_internal_pure$_t_uint32_$_t_uint256_$returns$_t_string_memory_ptr_$",
|
||||
"typeString": "function (uint32,uint256) pure returns (string memory)"
|
||||
}
|
||||
},
|
||||
"id": 14,
|
||||
"isConstant": false,
|
||||
"isLValue": false,
|
||||
"isPure": false,
|
||||
"isSuffixCall": true,
|
||||
"kind": "functionCall",
|
||||
"lValueRequested": false,
|
||||
"nameLocations": [],
|
||||
"names": [],
|
||||
"nodeType": "FunctionCall",
|
||||
"src": "94:15:1",
|
||||
"tryCall": false,
|
||||
"typeDescriptions":
|
||||
{
|
||||
"typeIdentifier": "t_string_memory_ptr",
|
||||
"typeString": "string memory"
|
||||
}
|
||||
},
|
||||
"visibility": "internal"
|
||||
}
|
||||
],
|
||||
"scope": 17,
|
||||
"src": "66:46:1",
|
||||
"usedErrors": [],
|
||||
"usedEvents": []
|
||||
}
|
||||
],
|
||||
"src": "0:113:1"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
function str(uint32, uint) pure suffix returns (string memory) {}
|
||||
contract C {
|
||||
string s = 123.345_789 str;
|
||||
}
|
||||
|
||||
// ----
|
||||
@@ -0,0 +1,180 @@
|
||||
{
|
||||
"absolutePath": "a",
|
||||
"id": 17,
|
||||
"nodeType": "SourceUnit",
|
||||
"nodes":
|
||||
[
|
||||
{
|
||||
"body":
|
||||
{
|
||||
"id": 9,
|
||||
"nodeType": "Block",
|
||||
"src": "63:2:1",
|
||||
"statements": []
|
||||
},
|
||||
"id": 10,
|
||||
"implemented": true,
|
||||
"kind": "freeFunction",
|
||||
"modifiers": [],
|
||||
"name": "str",
|
||||
"nameLocation": "9:3:1",
|
||||
"nodeType": "FunctionDefinition",
|
||||
"parameters":
|
||||
{
|
||||
"id": 5,
|
||||
"nodeType": "ParameterList",
|
||||
"parameters":
|
||||
[
|
||||
{
|
||||
"constant": false,
|
||||
"id": 2,
|
||||
"mutability": "mutable",
|
||||
"name": "",
|
||||
"nameLocation": "-1:-1:-1",
|
||||
"nodeType": "VariableDeclaration",
|
||||
"src": "13:6:1",
|
||||
"stateVariable": false,
|
||||
"storageLocation": "default",
|
||||
"typeDescriptions": {},
|
||||
"typeName":
|
||||
{
|
||||
"id": 1,
|
||||
"name": "uint32",
|
||||
"nodeType": "ElementaryTypeName",
|
||||
"src": "13:6:1",
|
||||
"typeDescriptions": {}
|
||||
},
|
||||
"visibility": "internal"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"id": 4,
|
||||
"mutability": "mutable",
|
||||
"name": "",
|
||||
"nameLocation": "-1:-1:-1",
|
||||
"nodeType": "VariableDeclaration",
|
||||
"src": "21:4:1",
|
||||
"stateVariable": false,
|
||||
"storageLocation": "default",
|
||||
"typeDescriptions": {},
|
||||
"typeName":
|
||||
{
|
||||
"id": 3,
|
||||
"name": "uint",
|
||||
"nodeType": "ElementaryTypeName",
|
||||
"src": "21:4:1",
|
||||
"typeDescriptions": {}
|
||||
},
|
||||
"visibility": "internal"
|
||||
}
|
||||
],
|
||||
"src": "12:14:1"
|
||||
},
|
||||
"returnParameters":
|
||||
{
|
||||
"id": 8,
|
||||
"nodeType": "ParameterList",
|
||||
"parameters":
|
||||
[
|
||||
{
|
||||
"constant": false,
|
||||
"id": 7,
|
||||
"mutability": "mutable",
|
||||
"name": "",
|
||||
"nameLocation": "-1:-1:-1",
|
||||
"nodeType": "VariableDeclaration",
|
||||
"src": "48:13:1",
|
||||
"stateVariable": false,
|
||||
"storageLocation": "memory",
|
||||
"typeDescriptions": {},
|
||||
"typeName":
|
||||
{
|
||||
"id": 6,
|
||||
"name": "string",
|
||||
"nodeType": "ElementaryTypeName",
|
||||
"src": "48:6:1",
|
||||
"typeDescriptions": {}
|
||||
},
|
||||
"visibility": "internal"
|
||||
}
|
||||
],
|
||||
"src": "47:15:1"
|
||||
},
|
||||
"src": "0:65:1",
|
||||
"stateMutability": "pure",
|
||||
"suffix": true,
|
||||
"virtual": false,
|
||||
"visibility": "internal"
|
||||
},
|
||||
{
|
||||
"abstract": false,
|
||||
"baseContracts": [],
|
||||
"contractDependencies": [],
|
||||
"contractKind": "contract",
|
||||
"id": 16,
|
||||
"name": "C",
|
||||
"nameLocation": "75:1:1",
|
||||
"nodeType": "ContractDefinition",
|
||||
"nodes":
|
||||
[
|
||||
{
|
||||
"constant": false,
|
||||
"id": 15,
|
||||
"mutability": "mutable",
|
||||
"name": "s",
|
||||
"nameLocation": "90:1:1",
|
||||
"nodeType": "VariableDeclaration",
|
||||
"src": "83:26:1",
|
||||
"stateVariable": false,
|
||||
"storageLocation": "default",
|
||||
"typeDescriptions": {},
|
||||
"typeName":
|
||||
{
|
||||
"id": 11,
|
||||
"name": "string",
|
||||
"nodeType": "ElementaryTypeName",
|
||||
"src": "83:6:1",
|
||||
"typeDescriptions": {}
|
||||
},
|
||||
"value":
|
||||
{
|
||||
"arguments":
|
||||
[
|
||||
{
|
||||
"hexValue": "3132332e3334355f373839",
|
||||
"id": 12,
|
||||
"kind": "number",
|
||||
"nodeType": "Literal",
|
||||
"src": "94:11:1",
|
||||
"typeDescriptions": {},
|
||||
"value": "123.345_789"
|
||||
}
|
||||
],
|
||||
"expression":
|
||||
{
|
||||
"id": 13,
|
||||
"name": "str",
|
||||
"nodeType": "Identifier",
|
||||
"overloadedDeclarations": [],
|
||||
"src": "106:3:1",
|
||||
"typeDescriptions": {}
|
||||
},
|
||||
"id": 14,
|
||||
"isSuffixCall": true,
|
||||
"nameLocations": [],
|
||||
"names": [],
|
||||
"nodeType": "FunctionCall",
|
||||
"src": "94:15:1",
|
||||
"tryCall": false,
|
||||
"typeDescriptions": {}
|
||||
},
|
||||
"visibility": "internal"
|
||||
}
|
||||
],
|
||||
"src": "66:46:1",
|
||||
"usedErrors": [],
|
||||
"usedEvents": []
|
||||
}
|
||||
],
|
||||
"src": "0:113:1"
|
||||
}
|
||||
Reference in New Issue
Block a user