@@ -1076,6 +1076,35 @@ describe('AST', () => {
10761076 } ,
10771077 ] ,
10781078 names : [ ] ,
1079+ identifiers : [ ] ,
1080+ } ,
1081+ } )
1082+ } )
1083+
1084+ it ( 'EmitStatement with name/value pair' , function ( ) {
1085+ const ast : any = parseStatement ( 'emit EventCalled({x : 1});' )
1086+ assert . deepEqual ( ast , {
1087+ type : 'EmitStatement' ,
1088+ eventCall : {
1089+ type : 'FunctionCall' ,
1090+ expression : {
1091+ type : 'Identifier' ,
1092+ name : 'EventCalled' ,
1093+ } ,
1094+ arguments : [
1095+ {
1096+ type : 'NumberLiteral' ,
1097+ number : '1' ,
1098+ subdenomination : null ,
1099+ } ,
1100+ ] ,
1101+ names : [ 'x' ] ,
1102+ identifiers : [
1103+ {
1104+ type : 'Identifier' ,
1105+ name : 'x' ,
1106+ } ,
1107+ ] ,
10791108 } ,
10801109 } )
10811110 } )
@@ -1221,6 +1250,7 @@ describe('AST', () => {
12211250 } ,
12221251 ] ,
12231252 names : [ ] ,
1253+ identifiers : [ ] ,
12241254 } ,
12251255 returnParameters : [
12261256 {
@@ -1303,6 +1333,7 @@ describe('AST', () => {
13031333 } ,
13041334 ] ,
13051335 names : [ ] ,
1336+ identifiers : [ ] ,
13061337 } ,
13071338 returnParameters : [
13081339 {
@@ -1413,6 +1444,7 @@ describe('AST', () => {
14131444 } ,
14141445 ] ,
14151446 names : [ ] ,
1447+ identifiers : [ ] ,
14161448 } ,
14171449 returnParameters : [
14181450 {
@@ -1523,6 +1555,7 @@ describe('AST', () => {
15231555 } ,
15241556 ] ,
15251557 names : [ ] ,
1558+ identifiers : [ ] ,
15261559 } ,
15271560 returnParameters : [
15281561 {
@@ -1949,6 +1982,63 @@ describe('AST', () => {
19491982 } ,
19501983 ] ,
19511984 names : [ ] ,
1985+ identifiers : [ ] ,
1986+ } )
1987+ expr = parseExpression ( 'type(MyContract)' )
1988+ assert . deepEqual ( expr , {
1989+ type : 'FunctionCall' ,
1990+ expression : {
1991+ type : 'Identifier' ,
1992+ name : 'type' ,
1993+ } ,
1994+ arguments : [
1995+ {
1996+ type : 'Identifier' ,
1997+ name : 'MyContract' ,
1998+ } ,
1999+ ] ,
2000+ names : [ ] ,
2001+ identifiers : [ ] ,
2002+ } )
2003+ } )
2004+
2005+ it ( 'FunctionCall with name/value pairs' , function ( ) {
2006+ let expr = parseExpression ( 'f{value: 10}(1, 2)' )
2007+ assert . deepEqual ( expr , {
2008+ type : 'FunctionCall' ,
2009+ expression : {
2010+ type : 'NameValueExpression' ,
2011+ expression : {
2012+ type : 'Identifier' ,
2013+ name : 'f' ,
2014+ } ,
2015+ arguments : {
2016+ type : 'NameValueList' ,
2017+ names : [ 'value' ] ,
2018+ identifiers : [ { type : 'Identifier' , name : 'value' } ] ,
2019+ arguments : [
2020+ {
2021+ type : 'NumberLiteral' ,
2022+ number : '10' ,
2023+ subdenomination : null ,
2024+ } ,
2025+ ] ,
2026+ } ,
2027+ } ,
2028+ arguments : [
2029+ {
2030+ type : 'NumberLiteral' ,
2031+ number : '1' ,
2032+ subdenomination : null ,
2033+ } ,
2034+ {
2035+ type : 'NumberLiteral' ,
2036+ number : '2' ,
2037+ subdenomination : null ,
2038+ } ,
2039+ ] ,
2040+ names : [ ] ,
2041+ identifiers : [ ] ,
19522042 } )
19532043 expr = parseExpression ( 'type(MyContract)' )
19542044 assert . deepEqual ( expr , {
@@ -1964,6 +2054,57 @@ describe('AST', () => {
19642054 } ,
19652055 ] ,
19662056 names : [ ] ,
2057+ identifiers : [ ] ,
2058+ } )
2059+ } )
2060+
2061+ it ( 'FunctionCall with name/value arguments' , function ( ) {
2062+ let expr = parseExpression ( 'f({x: 1, y: 2})' )
2063+ assert . deepEqual ( expr , {
2064+ type : 'FunctionCall' ,
2065+ expression : {
2066+ type : 'Identifier' ,
2067+ name : 'f' ,
2068+ } ,
2069+ arguments : [
2070+ {
2071+ type : 'NumberLiteral' ,
2072+ number : '1' ,
2073+ subdenomination : null ,
2074+ } ,
2075+ {
2076+ type : 'NumberLiteral' ,
2077+ number : '2' ,
2078+ subdenomination : null ,
2079+ } ,
2080+ ] ,
2081+ names : [ 'x' , 'y' ] ,
2082+ identifiers : [
2083+ {
2084+ type : 'Identifier' ,
2085+ name : 'x' ,
2086+ } ,
2087+ {
2088+ type : 'Identifier' ,
2089+ name : 'y' ,
2090+ } ,
2091+ ] ,
2092+ } )
2093+ expr = parseExpression ( 'type(MyContract)' )
2094+ assert . deepEqual ( expr , {
2095+ type : 'FunctionCall' ,
2096+ expression : {
2097+ type : 'Identifier' ,
2098+ name : 'type' ,
2099+ } ,
2100+ arguments : [
2101+ {
2102+ type : 'Identifier' ,
2103+ name : 'MyContract' ,
2104+ } ,
2105+ ] ,
2106+ names : [ ] ,
2107+ identifiers : [ ] ,
19672108 } )
19682109 } )
19692110
@@ -2825,6 +2966,7 @@ describe('AST', () => {
28252966 arguments : {
28262967 type : 'NameValueList' ,
28272968 names : [ 'value' ] ,
2969+ identifiers : [ { type : 'Identifier' , name : 'value' } ] ,
28282970 arguments : [
28292971 {
28302972 number : '1' ,
@@ -2845,6 +2987,7 @@ describe('AST', () => {
28452987 } ,
28462988 arguments : [ ] ,
28472989 names : [ ] ,
2990+ identifiers : [ ] ,
28482991 } )
28492992
28502993 expr = parseExpression ( 'recipient.call{value: 1, gas: 21000}()' )
@@ -2854,6 +2997,10 @@ describe('AST', () => {
28542997 arguments : {
28552998 type : 'NameValueList' ,
28562999 names : [ 'value' , 'gas' ] ,
3000+ identifiers : [
3001+ { type : 'Identifier' , name : 'value' } ,
3002+ { type : 'Identifier' , name : 'gas' } ,
3003+ ] ,
28573004 arguments : [
28583005 {
28593006 number : '1' ,
@@ -2879,6 +3026,7 @@ describe('AST', () => {
28793026 } ,
28803027 arguments : [ ] ,
28813028 names : [ ] ,
3029+ identifiers : [ ] ,
28823030 } )
28833031 } )
28843032
@@ -2897,6 +3045,7 @@ describe('AST', () => {
28973045 } ,
28983046 ] ,
28993047 names : [ ] ,
3048+ identifiers : [ ] ,
29003049 } )
29013050 } )
29023051
@@ -3252,6 +3401,7 @@ describe('AST', () => {
32523401 type : 'Identifier' ,
32533402 } ,
32543403 names : [ ] ,
3404+ identifiers : [ ] ,
32553405 type : 'FunctionCall' ,
32563406 } ,
32573407 } )
@@ -3272,6 +3422,7 @@ describe('AST', () => {
32723422 type : 'Identifier' ,
32733423 } ,
32743424 names : [ ] ,
3425+ identifiers : [ ] ,
32753426 type : 'FunctionCall' ,
32763427 } ,
32773428 } )
0 commit comments