Fix issue 8128 - allow unittest blocks in interfaces. #960

Merged
merged 3 commits into from Sep 30, 2012

Conversation

Projects
None yet
4 participants

@yebblies yebblies and 1 other commented on an outdated diff Jul 8, 2012

src/func.c
@@ -358,7 +358,7 @@ void FuncDeclaration::semantic(Scope *sc)
#endif
isDtorDeclaration() ||
isInvariantDeclaration() ||
- isUnitTestDeclaration() || isNewDeclaration() || isDelete())
+ isNewDeclaration() || isDelete())
error("constructors, destructors, postblits, invariants, unittests, new and delete functions are not allowed in interface %s", id->toChars());
@yebblies

yebblies Jul 8, 2012

Member

Might want to fix the error message too.

Member

9rnsr commented Jul 21, 2012

You should add test for the feature.

Member

alexrp commented Aug 2, 2012

Rebased and added test.

Member

alexrp commented Sep 13, 2012

Poking this to make the auto tester run it on OS X machines.

Owner

andralex commented Sep 25, 2012

This is great in conjunction with the factory pattern. It's also consistent with the "turtles all the way down" principle. Approved. Please review implementation and merge.

On the topic: we should allow non-final method definitions in interfaces. C# added that feature recently amid feedback from its users.

Member

9rnsr commented Sep 29, 2012

@alexp , test/runnable/interface.d is not good place for the test, because it doesn't have REQUIRED_ARGS: -unittest.

You should write following test in test/runnable/test19.d.

/* ================================ */
// 8128

int flag8128 = 0;

interface I8128
{
    unittest
    {
        printf("utest, flag8128 = %d\n", flag8128);
        flag8128 = 1;
    }
}

void test8128()
{
    printf("main, flag8128 = %d\n", flag8128);
    assert(flag8128 == 1);
}

/* ================================ */
Member

9rnsr commented Sep 29, 2012

Implementation is good. After fixing test, I'll merge this.

Owner

andralex commented Sep 29, 2012

Great! What do you think about deprecated with message?

Member

9rnsr commented Sep 29, 2012

It sounds not so bad. I'll review it later.

Member

alexrp commented Sep 30, 2012

Rebased with requested changes.

@9rnsr 9rnsr added a commit that referenced this pull request Sep 30, 2012

@9rnsr 9rnsr Merge pull request #960 from alexrp/interface-unittest
Fix issue 8128 - allow unittest blocks in interfaces.
1d70dce

@9rnsr 9rnsr merged commit 1d70dce into dlang:master Sep 30, 2012

1 check failed

default Pass: 8, Fail: 1
Details
Member

9rnsr commented Sep 30, 2012

Merged. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment