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

Method fillSources

test/libsolidity/ASTJSONTest.cpp:120–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void ASTJSONTest::fillSources(std::string const& _filename)
121{
122 std::ifstream file(_filename);
123 if (!file)
124 BOOST_THROW_EXCEPTION(std::runtime_error("Cannot open test contract: \"" + _filename + "\"."));
125 file.exceptions(std::ios::badbit);
126
127 std::string sourceName;
128 std::string source;
129 std::string line;
130 std::string const delimiter("// ----");
131 std::string const failMarker("// failAfter:");
132 while (getline(file, line))
133 {
134 if (boost::algorithm::starts_with(line, sourceDelimiter))
135 {
136 if (!sourceName.empty())
137 m_sources.emplace_back(sourceName, source);
138
139 sourceName = line.substr(
140 sourceDelimiter.size(),
141 line.size() - " ===="s.size() - sourceDelimiter.size()
142 );
143 source = std::string();
144 }
145 else if (boost::algorithm::starts_with(line, failMarker))
146 {
147 std::string state = line.substr(failMarker.size());
148 boost::algorithm::trim(state);
149 if (m_expectedFailAfter.has_value())
150 BOOST_THROW_EXCEPTION(std::runtime_error("Duplicated \"failAfter\" directive"));
151 m_expectedFailAfter = stringToCompilerState(state);
152
153 }
154 else if (!line.empty() && !boost::algorithm::starts_with(line, delimiter))
155 source += line + "\n";
156 }
157 m_sources.emplace_back(sourceName.empty() ? "a" : sourceName, source);
158 file.close();
159}
160
161void ASTJSONTest::validateTestConfiguration() const
162{

Callers

nothing calls this directly

Calls 4

trimFunction · 0.85
stringToCompilerStateFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected