| 48 | } |
| 49 | |
| 50 | void NatspecJSONTest::parseCustomExpectations(std::istream& _stream) |
| 51 | { |
| 52 | soltestAssert(m_expectedNatspecJSON.empty()); |
| 53 | |
| 54 | // We expect a series of expectations in the following format: |
| 55 | // |
| 56 | // // <qualified contract name> <devdoc|userdoc> |
| 57 | // // <json> |
| 58 | |
| 59 | std::string line; |
| 60 | while (getline(_stream, line)) |
| 61 | { |
| 62 | std::string_view strippedLine = expectLinePrefix(line); |
| 63 | if (strippedLine.empty()) |
| 64 | continue; |
| 65 | |
| 66 | auto [contractName, kind] = parseExpectationHeader(strippedLine); |
| 67 | |
| 68 | std::string rawJSON = extractExpectationJSON(_stream); |
| 69 | std::string jsonErrors; |
| 70 | Json parsedJSON; |
| 71 | bool jsonParsingSuccessful = jsonParseStrict(rawJSON, parsedJSON, &jsonErrors); |
| 72 | if (!jsonParsingSuccessful) |
| 73 | BOOST_THROW_EXCEPTION(std::runtime_error(fmt::format( |
| 74 | "Malformed JSON in {} expectation for contract {}.\n" |
| 75 | "Note that JSON expectations must be pretty-printed to be split correctly. " |
| 76 | "The object is assumed to and at the first unindented closing brace.\n" |
| 77 | "{}", |
| 78 | toString(kind), |
| 79 | contractName, |
| 80 | rawJSON |
| 81 | ))); |
| 82 | |
| 83 | m_expectedNatspecJSON[std::string(contractName)][kind] = parsedJSON; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | bool NatspecJSONTest::expectationsMatch() |
| 88 | { |
nothing calls this directly
no test coverage detected