| 60 | BOOST_AUTO_TEST_SUITE(ProgramTest) |
| 61 | |
| 62 | BOOST_AUTO_TEST_CASE(copy_constructor_should_make_deep_copy_of_ast) |
| 63 | { |
| 64 | std::string sourceCode( |
| 65 | "{\n" |
| 66 | " let x := 1\n" |
| 67 | "}\n" |
| 68 | ); |
| 69 | CharStream sourceStream(sourceCode, current_test_case().p_name); |
| 70 | Program program = get<Program>(Program::load(sourceStream)); |
| 71 | |
| 72 | Program programCopy(program); |
| 73 | |
| 74 | BOOST_TEST(&programCopy.ast() != &program.ast()); |
| 75 | |
| 76 | // There might be a more direct way to compare ASTs but converting to JSON should be good enough |
| 77 | // as long as the conversion is deterministic. A very nice side effect of doing it this way is |
| 78 | // that BOOST_TEST will print the complete AST structure of both programs in case of a mismatch. |
| 79 | BOOST_TEST(programCopy.toJson() == program.toJson()); |
| 80 | } |
| 81 | |
| 82 | BOOST_AUTO_TEST_CASE(load_should_rewind_the_stream) |
| 83 | { |
nothing calls this directly
no test coverage detected