-
Notifications
You must be signed in to change notification settings - Fork 205
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
Test Blocks In Src #4207
Comments
Sounds very specialized. It would make testing into a language feature, not just something you do using normal dart code and a helper library, a special compilation mode with some code only accessible when compiled for testing. Even if Dart chose to do that, it would probably be normal Day code inside the test block, so more likely ... The library code ...
test {
import test; // assume shorthand imports.
main() {
test("Foo", () {
// Some test code
});
}
} That would make the code inside the I'd probably generalize it to something similar to conditional imports/parts, where the condition is something you could use in such a conditional URI: if (test) {
// Declarations
} What would work the same as of that code was written inside a separate part file and included as part "empty.dart"
if (dart.mode.test) "the_code.dart"; Then you can define multiple modes. Still doesn't allow you to have multiple blocks of test code if each tries to introduce a if (test) {
import test/inline;
accumulator Tests tests = {};
main() => testSet(tests);
}
....
if (test) {
tests += {
test("Foo", () {
// The test
});
};
} Which would collect all the test declarations as literals of one set, and then access that set once in This is still much more complicated than what is being asked for, and therefore has more overhead, but it's also a general language feature that could be used for other things than testing. That makes it more likely to be worth doing. (Maybe, if that generality has any real uses.) |
I'm aware of two more features: |
It would be nice if tests could live next to their declarations in source. This would make it clearer what code does, make tests easier to write, and users would no longer have to maintain a mirrored directory tree in
tests
.e.g.
Prior art
The text was updated successfully, but these errors were encountered: