Browse files

Merge pull request #960 from alexrp/interface-unittest

Fix issue 8128 - allow unittest blocks in interfaces.
  • Loading branch information...
2 parents 9af1fac + 2375e48 commit 1d70dced6dc1f784eb6469d30637efa5ae85701b @9rnsr 9rnsr committed Sep 29, 2012
Showing with 19 additions and 2 deletions.
  1. +2 −2 src/func.c
  2. +17 −0 test/runnable/test19.d
View
4 src/func.c
@@ -353,8 +353,8 @@ void FuncDeclaration::semantic(Scope *sc)
#endif
isDtorDeclaration() ||
isInvariantDeclaration() ||
- isUnitTestDeclaration() || isNewDeclaration() || isDelete())
- error("constructors, destructors, postblits, invariants, unittests, new and delete functions are not allowed in interface %s", id->toChars());
+ isNewDeclaration() || isDelete())
+ error("constructors, destructors, postblits, invariants, new and delete functions are not allowed in interface %s", id->toChars());
if (fbody && isVirtual())
error("function body is not abstract in interface %s", id->toChars());
}
View
17 test/runnable/test19.d
@@ -401,7 +401,24 @@ void test20()
}
/* ================================ */
+// 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);
+}
int main()
{

0 comments on commit 1d70dce

Please sign in to comment.