Skip to content
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

Document how to run unittests in -betterC #2436

Merged
merged 1 commit into from
Aug 3, 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
27 changes: 26 additions & 1 deletion spec/betterc.dd
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,34 @@ $(H2 $(LNAME2 retained, Retained Features))
$(LI COM classes and C++ classes)
$(LI `assert` failures are directed to the C runtime library)
$(LI `switch` with strings)
$(LI `unittest`)
)

$(H3 $(LNAME2 unittests, Running unittests in `-betterC`))

While, testing can be done without the $(TT -betterC) flag, it is sometimes desirable to run the testsuite in `-betterC` too.
`unittest` blocks can be listed with the $(DDSUBLINK spec/traits, getUnitTests, `getUnitTests`) trait:

---
unittest
{
assert(0);
}

extern(C) void main()
{
static foreach(u; __traits(getUnitTests, __traits(parent, main)))
u();
}
---

$(CONSOLE
> dmd -betterC -unittest -run test.d
dmd_runpezoXK: foo.d:3: Assertion `0' failed.
)

However, in `-betterC` `assert` expressions don't use Druntime's assert and are directed to `assert` of the C runtime library instead.

$(H2 $(LNAME2 consequences, Unavailable Features))

$(P D features not available with $(B BetterC):)
Expand All @@ -98,7 +124,6 @@ $(OL
$(LI `final switch`)
$(LI `synchronized` and $(MREF core, sync))
$(LI Static module constructors or destructors)
$(LI `unittest` (testing can be done without the $(TT -betterC) flag))
)


Expand Down