blob: 5b73e7a89844c47a14a3d2eda3ed9e2ddbacfd8c (
plain)
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
34
35
36
37
38
39
40
41
42
|
#include <gtest/gtest.h>
#include <string>
#include <string_view>
#include <optional>
#include <unistd.h>
#include "tests/characterization.hh"
#include "tests/cli-literate-parser.hh"
using namespace std::string_literals;
namespace nix {
static constexpr const char * REPL_PROMPT = "nix-repl> ";
class ReplSessionTest : public CharacterizationTest
{
Path unitTestData = getUnitTestData();
public:
Path goldenMaster(std::string_view testStem) const override
{
return unitTestData + "/" + testStem;
}
};
TEST_F(ReplSessionTest, parses)
{
writeTest("basic.ast", [this]() {
const std::string content = readFile(goldenMaster("basic.test"));
auto parser = CLILiterateParser{REPL_PROMPT};
parser.feed(content);
std::ostringstream out{};
for (auto & bit : parser.syntax()) {
out << bit.print() << "\n";
}
return out.str();
});
}
};
|