Skip to content

Partially revert #303 until #317 is resolved #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions rdmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -831,23 +831,26 @@ string innerEvalCode(string[] eval)
import std.string : join, stripRight;
// assumeSafeAppend just to avoid unnecessary reallocation
string code = eval.join("\n").stripRight.assumeSafeAppend;
if (code.length > 0 && code[$ - 1] != ';')
code ~= ';';
// Revert https://github.com/dlang/tools/pull/303 until
// https://github.com/dlang/tools/pull/317 has been resolved
//if (code.length > 0 && code[$ - 1] != ';')
//code ~= ';';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a reversion of #303, it's a (breaking) change relative to previous behaviour.

Until #303, a terminating semicolon would always be added. What #303 changed was to stop that happening in cases where there was already a terminating semicolon.

return code;
}

// partially reverted until https://github.com/dlang/tools/pull/317 is resolved
unittest
{
assert(innerEvalCode([`writeln("Hello!")`]) == `writeln("Hello!");`);
//assert(innerEvalCode([`writeln("Hello!")`]) == `writeln("Hello!");`);
assert(innerEvalCode([`writeln("Hello!");`]) == `writeln("Hello!");`);

// test with trailing whitespace
assert(innerEvalCode([`writeln("Hello!") `]) == `writeln("Hello!");`);
//assert(innerEvalCode([`writeln("Hello!") `]) == `writeln("Hello!");`);
assert(innerEvalCode([`writeln("Hello!"); `]) == `writeln("Hello!");`);

// test with multiple entries
assert(innerEvalCode([`writeln("Hello!"); `, `writeln("You!") `])
== "writeln(\"Hello!\"); \nwriteln(\"You!\");");
//assert(innerEvalCode([`writeln("Hello!"); `, `writeln("You!") `])
//== "writeln(\"Hello!\"); \nwriteln(\"You!\");");
assert(innerEvalCode([`writeln("Hello!"); `, `writeln("You!"); `])
== "writeln(\"Hello!\"); \nwriteln(\"You!\");");
}
Expand Down Expand Up @@ -891,10 +894,11 @@ unittest
// innerEvalCode already tests the cases for different
// contents in `eval` array, so let's focus on testing
// the difference based on the `loop` flag
assert(makeEvalCode([`writeln("Hello!") `], No.loop) ==
importWorld
~ "void main(char[][] args) {\n"
~ "writeln(\"Hello!\");\n}");
// partially reverted until https://github.com/dlang/tools/pull/317 is resolved
//assert(makeEvalCode([`writeln("Hello!") `], No.loop) ==
//importWorld
//~ "void main(char[][] args) {\n"
//~ "writeln(\"Hello!\");\n}");

assert(makeEvalCode([`writeln("What!"); `], No.loop) ==
importWorld
Expand Down