Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathutils.ts
More file actions
Latest commit
33 lines (28 loc) · 1.16 KB
/
Copy pathutils.ts
File metadata and controls
33 lines (28 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import{assert}from'chai'
import*asparserfrom'../src/index'
import{ParseOptions}from'../src/types'
exportfunctionparseContract(source: string,options: ParseOptions={}){
constast: any=parser.parse(source,options)
assert.isOk(ast.children[0])
returnast.children[0]
}
exportfunctionparseNode(source: string,options={}){
constcontract=parseContract('contract test { '+source+' }',options)
assert.isOk(contract.subNodes[0])
returncontract.subNodes[0]
}
exportfunctionparseStatement(source: string,options={}){
constast=parseNode('function () { '+source+' }',options)
assert.isOk(ast.body.statements[0])
returnast.body.statements[0]
}
exportfunctionparseExpression(source: string,options={}){
constast=parseNode('function () { '+source+'; }',options)
assert.isOk(ast.body.statements[0].expression)
returnast.body.statements[0].expression
}
exportfunctionparseAssembly(source: string,options={}){
constast=parseNode('function () { assembly { '+source+' } }',options)
assert.isOk(ast.body.statements[0].body.operations[0])
returnast.body.statements[0].body.operations[0]
}