MCPcopy Create free account
hub / github.com/argotorg/solidity / checkJsonPathTest

Function checkJsonPathTest

test/buglistTests.js:104–125  ·  view source on GitHub ↗
(code, tmpdir, binary, query, idx)

Source from the content-addressed store, hash-verified

102}
103
104function checkJsonPathTest(code, tmpdir, binary, query, idx) {
105 return new Promise(function(resolve, reject) {
106 var solFile = tmpdir + "/jsonPath" + idx + ".sol"
107 var astFile = tmpdir + "/ast" + idx + ".json"
108 writeFilePromise(solFile, code)
109 .then(() => {
110 return exec(binary + " --ast-compact-json " + solFile + " > " + astFile)
111 })
112 .then(() => {
113 var jsonRE = /(\{[\s\S]*\})/
114 var ast = JSON.parse(jsonRE.exec(fs.readFileSync(astFile, 'utf8'))[0])
115 var result = JSONPath({json: ast, path: query})
116 if (result.length > 0)
117 resolve(true)
118 else
119 resolve(false)
120 })
121 .catch((err) => {
122 reject(err)
123 })
124 })
125}
126
127function writeFilePromise(filename, data) {
128 return new Promise(function(resolve, reject) {

Callers 1

checkJSONPathFunction · 0.85

Calls 2

writeFilePromiseFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected