eldritch horrors
81559ea8ad
this is not necessary in any way, but it will make the following changes
smaller and easier to review. the aliases could also be added piecemeal,
but doing it here lets us lean heavily on our compilers for correctness.
(teacher notes: here the author foreshadows the shape of things to come.
not all names change, and only the names unchanged are those which will,
over time, become ever more unrecognizable. note especially nix/main.cc,
where `state` is not only cloned, but itself changes pointerness. it can
be seen as a nod to the trans community, but more realistically it is no
more than foreshadowing the future where `state` is only seen by proxy.)
Change-Id: I7732025e58df089b7f8e564fc63960cd91729d09
35 lines
802 B
C++
35 lines
802 B
C++
#include <sstream>
|
|
#include <string_view>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "tests/libexpr.hh"
|
|
|
|
#include "lix/libexpr/nixexpr.hh"
|
|
#include "lix/libutil/ref.hh"
|
|
|
|
namespace nix
|
|
{
|
|
|
|
using namespace testing;
|
|
struct ExprPrintingTests : LibExprTest
|
|
{
|
|
void test(Expr const & expr, std::string_view expected)
|
|
{
|
|
std::stringstream out;
|
|
expr.show(evaluator.symbols, out);
|
|
ASSERT_EQ(out.str(), expected);
|
|
}
|
|
};
|
|
|
|
TEST_F(ExprPrintingTests, ExprInheritFrom)
|
|
{
|
|
// ExprInheritFrom has its own show() impl.
|
|
// If it uses its parent class's impl it will crash.
|
|
auto inheritSource = make_ref<ExprVar>(evaluator.symbols.create("stdenv"));
|
|
ExprInheritFrom const eInheritFrom(noPos, 0, inheritSource);
|
|
test(eInheritFrom, "(/* expanded inherit (expr) */ stdenv)");
|
|
}
|
|
|
|
}
|