From e49b0e3d95c25c96d90ce309080e8bc41a9e3cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Thu, 16 Feb 2023 19:16:41 +0100 Subject: [PATCH] Update AST tests with block listeners --- .../spockframework/smoke/ast/AstSpec.groovy | 36 ++++-- .../smoke/ast/CleanupBlocksAstSpec.groovy | 118 ++++++++++-------- .../smoke/ast/DataAstSpec.groovy | 38 +++--- .../CollectionConditionAstSpec.groovy | 88 ++++++++----- .../ExceptionConditionsAstSpec.groovy | 48 ++++--- .../parameterization/DataProviders.groovy | 13 +- 6 files changed, 216 insertions(+), 125 deletions(-) diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/AstSpec.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/AstSpec.groovy index faa50ac401..c59138a495 100644 --- a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/AstSpec.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/AstSpec.groovy @@ -21,8 +21,13 @@ class AstSpec extends EmbeddedSpecification { result.source == '''\ @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = [])], parameterNames = []) public void $spock_feature_0_0() { - java.lang.Object nothing = null - this.getSpecificationContext().getMockController().leaveScope() + try { + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) + java.lang.Object nothing = null + this.getSpecificationContext().getMockController().leaveScope() + } + finally { + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } @@ -49,8 +54,13 @@ private java.lang.Object $spock_initializeFields() { @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 3, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = [])], parameterNames = []) public void $spock_feature_0_0() { - java.lang.Object nothing = null - this.getSpecificationContext().getMockController().leaveScope() + try { + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) + java.lang.Object nothing = null + this.getSpecificationContext().getMockController().leaveScope() + } + finally { + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } @@ -75,8 +85,13 @@ public class apackage.ASpec extends spock.lang.Specification { @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = [])], parameterNames = []) public void $spock_feature_0_0() { - java.lang.Object nothing = null - this.getSpecificationContext().getMockController().leaveScope() + try { + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) + java.lang.Object nothing = null + this.getSpecificationContext().getMockController().leaveScope() + } + finally { + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} } }''' @@ -101,8 +116,13 @@ public class apackage.ASpec extends spock.lang.Specification implements groovy.l @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = [])], parameterNames = []) public void $spock_feature_0_0() { - java.lang.Object nothing = null - this.getSpecificationContext().getMockController().leaveScope() + try { + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) + java.lang.Object nothing = null + this.getSpecificationContext().getMockController().leaveScope() + } + finally { + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} } }''' diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/CleanupBlocksAstSpec.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/CleanupBlocksAstSpec.groovy index d973cd8a7e..02ae1fdefa 100644 --- a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/CleanupBlocksAstSpec.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/CleanupBlocksAstSpec.groovy @@ -31,39 +31,48 @@ public java.lang.Object foobar() { } public void $spock_feature_0_0() { - org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE - org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() - java.lang.Object foobar - java.lang.Throwable $spock_feature_throwable try { - foobar = this.foobar() + org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE + org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() + java.lang.Object foobar + java.lang.Throwable $spock_feature_throwable try { - org.spockframework.runtime.SpockRuntime.verifyMethodCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'println(foobar)', 6, 3, null, this, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 'println'), new java.lang.Object[]{$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), foobar)}, $spock_valueRecorder.realizeNas(4, false), false, 3) - } - catch (java.lang.Throwable $spock_condition_throwable) { - org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'println(foobar)', 6, 3, null, $spock_condition_throwable)} - finally { - } - } - catch (java.lang.Throwable $spock_tmp_throwable) { - $spock_feature_throwable = $spock_tmp_throwable - throw $spock_tmp_throwable - } - finally { - try { - foobar.size() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.WHEN, [])) + foobar = this.foobar() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.THEN, [])) + try { + org.spockframework.runtime.SpockRuntime.verifyMethodCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'println(foobar)', 6, 3, null, this, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 'println'), new java.lang.Object[]{$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), foobar)}, $spock_valueRecorder.realizeNas(4, false), false, 3) + } + catch (java.lang.Throwable $spock_condition_throwable) { + org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'println(foobar)', 6, 3, null, $spock_condition_throwable)} + finally { + } } catch (java.lang.Throwable $spock_tmp_throwable) { - if ( $spock_feature_throwable != null) { - $spock_feature_throwable.addSuppressed($spock_tmp_throwable) - } else { - throw $spock_tmp_throwable - } + $spock_feature_throwable = $spock_tmp_throwable + throw $spock_tmp_throwable } finally { + try { + if ( $spock_feature_throwable == null) { + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.CLEANUP, [])) + } + foobar.size() + } + catch (java.lang.Throwable $spock_tmp_throwable) { + if ( $spock_feature_throwable != null) { + $spock_feature_throwable.addSuppressed($spock_tmp_throwable) + } else { + throw $spock_tmp_throwable + } + } + finally { + } } + this.getSpecificationContext().getMockController().leaveScope() } - this.getSpecificationContext().getMockController().leaveScope() + finally { + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } @@ -93,39 +102,48 @@ public java.lang.Object foobar() { } public void $spock_feature_0_0() { - org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE - org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() - def (java.lang.Object foobar, java.lang.Object b) = [null, null] - java.lang.Throwable $spock_feature_throwable try { - (foobar, b) = this.foobar() + org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE + org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() + def (java.lang.Object foobar, java.lang.Object b) = [null, null] + java.lang.Throwable $spock_feature_throwable try { - org.spockframework.runtime.SpockRuntime.verifyMethodCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'println(foobar)', 6, 3, null, this, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 'println'), new java.lang.Object[]{$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), foobar)}, $spock_valueRecorder.realizeNas(4, false), false, 3) - } - catch (java.lang.Throwable $spock_condition_throwable) { - org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'println(foobar)', 6, 3, null, $spock_condition_throwable)} - finally { - } - } - catch (java.lang.Throwable $spock_tmp_throwable) { - $spock_feature_throwable = $spock_tmp_throwable - throw $spock_tmp_throwable - } - finally { - try { - foobar.size() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.WHEN, [])) + (foobar, b) = this.foobar() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.THEN, [])) + try { + org.spockframework.runtime.SpockRuntime.verifyMethodCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'println(foobar)', 6, 3, null, this, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 'println'), new java.lang.Object[]{$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), foobar)}, $spock_valueRecorder.realizeNas(4, false), false, 3) + } + catch (java.lang.Throwable $spock_condition_throwable) { + org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'println(foobar)', 6, 3, null, $spock_condition_throwable)} + finally { + } } catch (java.lang.Throwable $spock_tmp_throwable) { - if ( $spock_feature_throwable != null) { - $spock_feature_throwable.addSuppressed($spock_tmp_throwable) - } else { - throw $spock_tmp_throwable - } + $spock_feature_throwable = $spock_tmp_throwable + throw $spock_tmp_throwable } finally { + try { + if ( $spock_feature_throwable == null) { + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.CLEANUP, [])) + } + foobar.size() + } + catch (java.lang.Throwable $spock_tmp_throwable) { + if ( $spock_feature_throwable != null) { + $spock_feature_throwable.addSuppressed($spock_tmp_throwable) + } else { + throw $spock_tmp_throwable + } + } + finally { + } } + this.getSpecificationContext().getMockController().leaveScope() } - this.getSpecificationContext().getMockController().leaveScope() + finally { + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/DataAstSpec.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/DataAstSpec.groovy index 0d207926bb..4e26865783 100644 --- a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/DataAstSpec.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/DataAstSpec.groovy @@ -15,16 +15,21 @@ class DataAstSpec extends EmbeddedSpecification { result.source == '''\ @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.EXPECT, texts = []), @org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.WHERE, texts = [])], parameterNames = ['a', 'b']) public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b) { - org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE - org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() try { - org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'a == b', 1, 83, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), a) == $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), b))) + org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE + org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.EXPECT, [])) + try { + org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'a == b', 1, 83, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), a) == $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), b))) + } + catch (java.lang.Throwable $spock_condition_throwable) { + org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'a == b', 1, 83, null, $spock_condition_throwable)} + finally { + } + this.getSpecificationContext().getMockController().leaveScope() } - catch (java.lang.Throwable $spock_condition_throwable) { - org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'a == b', 1, 83, null, $spock_condition_throwable)} finally { - } - this.getSpecificationContext().getMockController().leaveScope() + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} } @org.spockframework.runtime.model.DataProviderMetadata(line = 3, dataVariables = ['a', 'b']) @@ -52,16 +57,21 @@ public java.lang.Object $spock_feature_0_0proc(java.lang.Object $spock_p0) { result.source == '''\ @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.EXPECT, texts = []), @org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.WHERE, texts = [])], parameterNames = ['a', 'b']) public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b) { - org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE - org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() try { - org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'a == b', 1, 83, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), a) == $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), b))) + org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE + org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.EXPECT, [])) + try { + org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'a == b', 1, 83, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), a) == $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), b))) + } + catch (java.lang.Throwable $spock_condition_throwable) { + org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'a == b', 1, 83, null, $spock_condition_throwable)} + finally { + } + this.getSpecificationContext().getMockController().leaveScope() } - catch (java.lang.Throwable $spock_condition_throwable) { - org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'a == b', 1, 83, null, $spock_condition_throwable)} finally { - } - this.getSpecificationContext().getMockController().leaveScope() + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} } @org.spockframework.runtime.model.DataProviderMetadata(line = 3, dataVariables = ['a', 'b']) diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec.groovy index 8f6ce009b8..1e9834359f 100644 --- a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec.groovy @@ -18,17 +18,23 @@ class CollectionConditionAstSpec extends EmbeddedSpecification { result.source == '''\ @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = []), @org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.EXPECT, texts = [])], parameterNames = []) public void $spock_feature_0_0() { - org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE - org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() - java.lang.Object x = [1] try { - org.spockframework.runtime.SpockRuntime.verifyMethodCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'x =~ [1]', 4, 9, null, org.spockframework.runtime.SpockRuntime, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 'matchCollectionsAsSet'), new java.lang.Object[]{$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), x), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(3), [$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), 1)])}, $spock_valueRecorder.realizeNas(6, false), false, 5) + org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE + org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) + java.lang.Object x = [1] + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.EXPECT, [])) + try { + org.spockframework.runtime.SpockRuntime.verifyMethodCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'x =~ [1]', 4, 9, null, org.spockframework.runtime.SpockRuntime, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 'matchCollectionsAsSet'), new java.lang.Object[]{$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), x), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(3), [$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), 1)])}, $spock_valueRecorder.realizeNas(6, false), false, 5) + } + catch (java.lang.Throwable $spock_condition_throwable) { + org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x =~ [1]', 4, 9, null, $spock_condition_throwable)} + finally { + } + this.getSpecificationContext().getMockController().leaveScope() } - catch (java.lang.Throwable $spock_condition_throwable) { - org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x =~ [1]', 4, 9, null, $spock_condition_throwable)} finally { - } - this.getSpecificationContext().getMockController().leaveScope() + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } @@ -46,17 +52,23 @@ public void $spock_feature_0_0() { result.source == '''\ @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = []), @org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.EXPECT, texts = [])], parameterNames = []) public void $spock_feature_0_0() { - org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE - org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() - java.lang.Object x = [1] try { - org.spockframework.runtime.SpockRuntime.verifyMethodCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'x ==~ [1]', 4, 9, null, org.spockframework.runtime.SpockRuntime, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 'matchCollectionsInAnyOrder'), new java.lang.Object[]{$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), x), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(3), [$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), 1)])}, $spock_valueRecorder.realizeNas(6, false), false, 5) + org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE + org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) + java.lang.Object x = [1] + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.EXPECT, [])) + try { + org.spockframework.runtime.SpockRuntime.verifyMethodCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'x ==~ [1]', 4, 9, null, org.spockframework.runtime.SpockRuntime, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), 'matchCollectionsInAnyOrder'), new java.lang.Object[]{$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), x), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(3), [$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), 1)])}, $spock_valueRecorder.realizeNas(6, false), false, 5) + } + catch (java.lang.Throwable $spock_condition_throwable) { + org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x ==~ [1]', 4, 9, null, $spock_condition_throwable)} + finally { + } + this.getSpecificationContext().getMockController().leaveScope() } - catch (java.lang.Throwable $spock_condition_throwable) { - org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x ==~ [1]', 4, 9, null, $spock_condition_throwable)} finally { - } - this.getSpecificationContext().getMockController().leaveScope() + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } @@ -74,17 +86,23 @@ public void $spock_feature_0_0() { result.source == '''\ @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = []), @org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.EXPECT, texts = [])], parameterNames = []) public void $spock_feature_0_0() { - org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE - org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() - java.lang.Object x = '[1]\' try { - org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'x =~ /\\\\d/', 4, 9, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), x) =~ $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), '\\\\d'))) + org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE + org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) + java.lang.Object x = '[1]\' + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.EXPECT, [])) + try { + org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'x =~ /\\\\d/', 4, 9, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), x) =~ $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), '\\\\d'))) + } + catch (java.lang.Throwable $spock_condition_throwable) { + org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x =~ /\\\\d/', 4, 9, null, $spock_condition_throwable)} + finally { + } + this.getSpecificationContext().getMockController().leaveScope() } - catch (java.lang.Throwable $spock_condition_throwable) { - org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x =~ /\\\\d/', 4, 9, null, $spock_condition_throwable)} finally { - } - this.getSpecificationContext().getMockController().leaveScope() + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } @@ -102,17 +120,23 @@ public void $spock_feature_0_0() { result.source == '''\ @org.spockframework.runtime.model.FeatureMetadata(name = 'a feature', ordinal = 0, line = 1, blocks = [@org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.SETUP, texts = []), @org.spockframework.runtime.model.BlockMetadata(kind = org.spockframework.runtime.model.BlockKind.EXPECT, texts = [])], parameterNames = []) public void $spock_feature_0_0() { - org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE - org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() - java.lang.Object x = 'a1b' try { - org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'x ==~ /a\\\\db/', 4, 9, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), x) ==~ $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), 'a\\\\db'))) + org.spockframework.runtime.ErrorCollector $spock_errorCollector = org.spockframework.runtime.ErrorRethrower.INSTANCE + org.spockframework.runtime.ValueRecorder $spock_valueRecorder = new org.spockframework.runtime.ValueRecorder() + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.SETUP, [])) + java.lang.Object x = 'a1b\' + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.EXPECT, [])) + try { + org.spockframework.runtime.SpockRuntime.verifyCondition($spock_errorCollector, $spock_valueRecorder.reset(), 'x ==~ /a\\\\db/', 4, 9, null, $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(2), $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), x) ==~ $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(1), 'a\\\\db'))) + } + catch (java.lang.Throwable $spock_condition_throwable) { + org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x ==~ /a\\\\db/', 4, 9, null, $spock_condition_throwable)} + finally { + } + this.getSpecificationContext().getMockController().leaveScope() } - catch (java.lang.Throwable $spock_condition_throwable) { - org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x ==~ /a\\\\db/', 4, 9, null, $spock_condition_throwable)} finally { - } - this.getSpecificationContext().getMockController().leaveScope() + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } } diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec.groovy index acf2808fea..1ba4bb26e1 100644 --- a/spock-specs/src/test/groovy/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec.groovy @@ -28,18 +28,24 @@ public java.lang.Object foobar() { } public void $spock_feature_0_0() { - java.lang.Object foobar - this.getSpecificationContext().setThrownException(null) try { - foobar = this.foobar() - } - catch (java.lang.Throwable $spock_ex) { - this.getSpecificationContext().setThrownException($spock_ex) + java.lang.Object foobar + this.getSpecificationContext().setThrownException(null) + try { + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.WHEN, [])) + foobar = this.foobar() + } + catch (java.lang.Throwable $spock_ex) { + this.getSpecificationContext().setThrownException($spock_ex) + } + finally { + } + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.THEN, [])) + this.thrownImpl(null, null, java.lang.IllegalStateException) + this.getSpecificationContext().getMockController().leaveScope() } finally { - } - this.thrownImpl(null, null, java.lang.IllegalStateException) - this.getSpecificationContext().getMockController().leaveScope() + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } @@ -66,18 +72,24 @@ public java.lang.Object foobar() { } public void $spock_feature_0_0() { - def (java.lang.Object foobar, java.lang.Object b) = [null, null] - this.getSpecificationContext().setThrownException(null) try { - (foobar, b) = this.foobar() - } - catch (java.lang.Throwable $spock_ex) { - this.getSpecificationContext().setThrownException($spock_ex) + def (java.lang.Object foobar, java.lang.Object b) = [null, null] + this.getSpecificationContext().setThrownException(null) + try { + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.WHEN, [])) + (foobar, b) = this.foobar() + } + catch (java.lang.Throwable $spock_ex) { + this.getSpecificationContext().setThrownException($spock_ex) + } + finally { + } + org.spockframework.runtime.SpockRuntime.callEnterBlock(this.getSpecificationContext(), new org.spockframework.runtime.model.BlockInfo(org.spockframework.runtime.model.BlockKind.THEN, [])) + this.thrownImpl(null, null, java.lang.IllegalStateException) + this.getSpecificationContext().getMockController().leaveScope() } finally { - } - this.thrownImpl(null, null, java.lang.IllegalStateException) - this.getSpecificationContext().getMockController().leaveScope() + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} }''' } diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/parameterization/DataProviders.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/parameterization/DataProviders.groovy index ba2b59d4ba..88d5dca0a8 100755 --- a/spock-specs/src/test/groovy/org/spockframework/smoke/parameterization/DataProviders.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/parameterization/DataProviders.groovy @@ -114,7 +114,11 @@ where: x << [] then: result.source == '''\ public void $spock_feature_0_0(java.lang.Object dataPipe, java.lang.Object dataVariable) { - this.getSpecificationContext().getMockController().leaveScope() + try { + this.getSpecificationContext().getMockController().leaveScope() + } + finally { + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} } public java.lang.Object $spock_feature_0_0prov0() { @@ -163,7 +167,11 @@ public java.lang.Object $spock_feature_0_0proc(java.lang.Object $spock_p0) { then: result.source == '''\ public void $spock_feature_0_0(java.lang.Object dataPipe, java.lang.Object dataVariable) { - this.getSpecificationContext().getMockController().leaveScope() + try { + this.getSpecificationContext().getMockController().leaveScope() + } + finally { + org.spockframework.runtime.SpockRuntime.clearCurrentBlock(this.getSpecificationContext())} } public java.lang.Object $spock_feature_0_0prov0() { @@ -320,4 +328,3 @@ where: a << b } } } -