groovy git commit: GROOVY-7717 StaticTypeCheckingTestCase#shouldFailWithMessages erroneously passes *StaticTypeCheckingTestCase: shouldFailWithMessages should only pass if all and only the expected error messages occur *PrecompiledExtensionNotExtendingDS

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

groovy git commit: GROOVY-7717 StaticTypeCheckingTestCase#shouldFailWithMessages erroneously passes *StaticTypeCheckingTestCase: shouldFailWithMessages should only pass if all and only the expected error messages occur *PrecompiledExtensionNotExtendingDS

shils-2
Repository: groovy
Updated Branches:
  refs/heads/master 52887d89d -> 738b5f669


GROOVY-7717 StaticTypeCheckingTestCase#shouldFailWithMessages erroneously passes
*StaticTypeCheckingTestCase: shouldFailWithMessages should only pass if all and only the expected error messages occur
*PrecompiledExtensionNotExtendingDSL:  fix ASTNode associated with error added in onMethodSelection method
(closes #217)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/738b5f66
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/738b5f66
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/738b5f66

Branch: refs/heads/master
Commit: 738b5f669f6ea10ecf720b81b2ceb1279c11551f
Parents: 52887d8
Author: Shil Sinha <[hidden email]>
Authored: Sun Dec 20 22:58:55 2015 -0500
Committer: Shil Sinha <[hidden email]>
Committed: Mon Dec 21 08:41:28 2015 -0500

----------------------------------------------------------------------
 .../stc/PrecompiledExtensionNotExtendingDSL.groovy          | 2 +-
 .../groovy/transform/stc/StaticTypeCheckingTestCase.groovy  | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/738b5f66/src/test/groovy/transform/stc/PrecompiledExtensionNotExtendingDSL.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/PrecompiledExtensionNotExtendingDSL.groovy b/src/test/groovy/transform/stc/PrecompiledExtensionNotExtendingDSL.groovy
index a6fade0..020304b 100644
--- a/src/test/groovy/transform/stc/PrecompiledExtensionNotExtendingDSL.groovy
+++ b/src/test/groovy/transform/stc/PrecompiledExtensionNotExtendingDSL.groovy
@@ -39,7 +39,7 @@ class PrecompiledExtensionNotExtendingDSL extends AbstractTypeCheckingExtension
     @Override
     void onMethodSelection(final Expression expression, final MethodNode target) {
         if (target.name=='println') {
-            addStaticTypeError('Error thrown from extension in onMethodSelection', expression.parameters[0])
+            addStaticTypeError('Error thrown from extension in onMethodSelection', expression.arguments[0])
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/738b5f66/src/test/groovy/transform/stc/StaticTypeCheckingTestCase.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/StaticTypeCheckingTestCase.groovy b/src/test/groovy/transform/stc/StaticTypeCheckingTestCase.groovy
index 3e267c4..e42600a 100644
--- a/src/test/groovy/transform/stc/StaticTypeCheckingTestCase.groovy
+++ b/src/test/groovy/transform/stc/StaticTypeCheckingTestCase.groovy
@@ -78,14 +78,13 @@ abstract class StaticTypeCheckingTestCase extends GroovyTestCase {
         try {
             shell.evaluate(code, getTestClassName())
         } catch (MultipleCompilationErrorsException mce) {
-            mce.errorCollector.errors.each {
-                messages.each { message ->
-                    success = success || (it instanceof SyntaxErrorMessage && it.cause.message.contains(message))
+            success = messages.every { message ->
+                mce.errorCollector.errors.any {
+                    it instanceof SyntaxErrorMessage && it.cause.message.contains(message)
                 }
             }
-            if (!success) throw mce;
             if (success && mce.errorCollector.errorCount!=messages.length) {
-                throw new AssertionError("Expected error message was found, but compiler thrown more than one error : "+mce.toString())
+                throw new AssertionError("Expected error messages were found, but compiler threw additional errors : " + mce.toString())
             }
         }
         if (!success) throw new AssertionError("Test should have failed with messages [$messages]")