forked from lix-project/lix
Qyriad
011fbeca47
ExprVar::show() assumes it has a name. dynamic inherits do not
necessarily (ever?) have a name.
Change-Id: If10893188e307431da17f0c1bd0787adc74f7141
35 lines
740 B
C++
35 lines
740 B
C++
#include <sstream>
|
|
#include <string_view>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "tests/libexpr.hh"
|
|
|
|
#include "nixexpr.hh"
|
|
#include "ref.hh"
|
|
|
|
namespace nix
|
|
{
|
|
|
|
using namespace testing;
|
|
struct ExprPrintingTests : LibExprTest
|
|
{
|
|
void test(Expr const & expr, std::string_view expected)
|
|
{
|
|
std::stringstream out;
|
|
expr.show(state.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>(state.symbols.create("stdenv"));
|
|
ExprInheritFrom const eInheritFrom(noPos, 0, inheritSource);
|
|
test(eInheritFrom, "(stdenv)");
|
|
}
|
|
|
|
}
|