Add test.

This commit is contained in:
chriseth 2021-02-11 09:49:29 +01:00
parent 9ca389d6cd
commit f4790971ae
3 changed files with 283 additions and 0 deletions

View File

@ -0,0 +1,159 @@
{
"absolutePath": "a",
"exportedSymbols":
{
"A":
[
3
],
"f":
[
13
]
},
"id": 14,
"nodeType": "SourceUnit",
"nodes":
[
{
"canonicalName": "A",
"id": 3,
"members":
[
{
"id": 1,
"name": "X",
"nameLocation": "9:1:1",
"nodeType": "EnumValue",
"src": "9:1:1"
},
{
"id": 2,
"name": "Y",
"nameLocation": "12:1:1",
"nodeType": "EnumValue",
"src": "12:1:1"
}
],
"name": "A",
"nameLocation": "5:1:1",
"nodeType": "EnumDefinition",
"src": "0:15:1"
},
{
"body":
{
"id": 12,
"nodeType": "Block",
"src": "46:15:1",
"statements":
[
{
"expression":
{
"expression":
{
"id": 9,
"name": "A",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 3,
"src": "55:1:1",
"typeDescriptions":
{
"typeIdentifier": "t_type$_t_enum$_A_$3_$",
"typeString": "type(enum A)"
}
},
"id": 10,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"memberName": "X",
"nodeType": "MemberAccess",
"referencedDeclaration": 1,
"src": "55:3:1",
"typeDescriptions":
{
"typeIdentifier": "t_enum$_A_$3",
"typeString": "enum A"
}
},
"functionReturnParameters": 8,
"id": 11,
"nodeType": "Return",
"src": "48:10:1"
}
]
},
"id": 13,
"implemented": true,
"kind": "freeFunction",
"modifiers": [],
"name": "f",
"nameLocation": "25:1:1",
"nodeType": "FunctionDefinition",
"parameters":
{
"id": 4,
"nodeType": "ParameterList",
"parameters": [],
"src": "26:2:1"
},
"returnParameters":
{
"id": 8,
"nodeType": "ParameterList",
"parameters":
[
{
"constant": false,
"id": 7,
"mutability": "mutable",
"name": "",
"nameLocation": "-1:-1:-1",
"nodeType": "VariableDeclaration",
"scope": 13,
"src": "43:1:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions":
{
"typeIdentifier": "t_enum$_A_$3",
"typeString": "enum A"
},
"typeName":
{
"id": 6,
"nodeType": "UserDefinedTypeName",
"pathNode":
{
"id": 5,
"name": "A",
"nodeType": "IdentifierPath",
"referencedDeclaration": 3,
"src": "43:1:1"
},
"referencedDeclaration": 3,
"src": "43:1:1",
"typeDescriptions":
{
"typeIdentifier": "t_enum$_A_$3",
"typeString": "enum A"
}
},
"visibility": "internal"
}
],
"src": "42:3:1"
},
"scope": 14,
"src": "16:45:1",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
}
],
"src": "0:62:1"
}

View File

@ -0,0 +1,4 @@
enum A { X, Y }
function f() pure returns (A) { return A.X; }
// ----

View File

@ -0,0 +1,120 @@
{
"absolutePath": "a",
"id": 14,
"nodeType": "SourceUnit",
"nodes":
[
{
"id": 3,
"members":
[
{
"id": 1,
"name": "X",
"nameLocation": "9:1:1",
"nodeType": "EnumValue",
"src": "9:1:1"
},
{
"id": 2,
"name": "Y",
"nameLocation": "12:1:1",
"nodeType": "EnumValue",
"src": "12:1:1"
}
],
"name": "A",
"nameLocation": "5:1:1",
"nodeType": "EnumDefinition",
"src": "0:15:1"
},
{
"body":
{
"id": 12,
"nodeType": "Block",
"src": "46:15:1",
"statements":
[
{
"expression":
{
"expression":
{
"id": 9,
"name": "A",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"src": "55:1:1",
"typeDescriptions": {}
},
"id": 10,
"memberName": "X",
"nodeType": "MemberAccess",
"src": "55:3:1",
"typeDescriptions": {}
},
"id": 11,
"nodeType": "Return",
"src": "48:10:1"
}
]
},
"id": 13,
"implemented": true,
"kind": "freeFunction",
"modifiers": [],
"name": "f",
"nameLocation": "25:1:1",
"nodeType": "FunctionDefinition",
"parameters":
{
"id": 4,
"nodeType": "ParameterList",
"parameters": [],
"src": "26:2:1"
},
"returnParameters":
{
"id": 8,
"nodeType": "ParameterList",
"parameters":
[
{
"constant": false,
"id": 7,
"mutability": "mutable",
"name": "",
"nameLocation": "-1:-1:-1",
"nodeType": "VariableDeclaration",
"src": "43:1:1",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {},
"typeName":
{
"id": 6,
"nodeType": "UserDefinedTypeName",
"pathNode":
{
"id": 5,
"name": "A",
"nodeType": "IdentifierPath",
"src": "43:1:1"
},
"src": "43:1:1",
"typeDescriptions": {}
},
"visibility": "internal"
}
],
"src": "42:3:1"
},
"src": "16:45:1",
"stateMutability": "pure",
"virtual": false,
"visibility": "internal"
}
],
"src": "0:62:1"
}