1- import org.junit.jupiter.api.Test
2-
3- import static groovy.test.GroovyAssert.assertScript
1+ import groovy.test.GroovyTestCase
42
53/*
64 * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,10 +18,9 @@ import static groovy.test.GroovyAssert.assertScript
2018 * specific language governing permissions and limitations
2119 * under the License.
2220 */
23- class ClosuresSpecTest {
21+ class ClosuresSpecTest extends GroovyTestCase {
2422 static void sink (Closure cl ) {}
2523
26- @Test
2724 void testClosureSyntax () {
2825 sink
2926 // tag::closure_syntax_1[]
@@ -64,7 +61,6 @@ class ClosuresSpecTest {
6461 // end::closure_syntax_6[]
6562 }
6663
67- @Test
6864 void testAssignClosureToAVariable () {
6965 // tag::closure_is_an_instance_of_Closure[]
7066 def listener = { e -> println " Clicked on $e. source " } // <1>
@@ -76,7 +72,6 @@ class ClosuresSpecTest {
7672 // end::closure_is_an_instance_of_Closure[]
7773 }
7874
79- @Test
8075 void testCallClosure () {
8176 // tag::closure_call_1[]
8277 def code = { 123 }
@@ -99,7 +94,6 @@ class ClosuresSpecTest {
9994 // end::closure_call_2[]
10095 }
10196
102- @Test
10397 void testClosureParameters () {
10498 // tag::closure_param_declaration[]
10599 def closureWithOneArg = { str -> str. toUpperCase() }
@@ -122,7 +116,6 @@ class ClosuresSpecTest {
122116 // end::closure_param_declaration[]
123117 }
124118
125- @Test
126119 void testImplicitIt () {
127120 assertScript '''
128121 // tag::implicit_it[]
@@ -153,7 +146,6 @@ class ClosuresSpecTest {
153146 '''
154147 }
155148
156- @Test
157149 void testClosureVargs () {
158150 // tag::closure_vargs[]
159151 def concat1 = { String ... args -> args. join(' ' ) } // <1>
@@ -169,7 +161,6 @@ class ClosuresSpecTest {
169161
170162 }
171163
172- @Test
173164 void testThisObject () {
174165 assertScript '''
175166 // tag::closure_this[]
@@ -226,7 +217,6 @@ class ClosuresSpecTest {
226217 '''
227218 }
228219
229- @Test
230220 void testOwner () {
231221 assertScript '''
232222 // tag::closure_owner[]
@@ -263,7 +253,6 @@ class ClosuresSpecTest {
263253'''
264254 }
265255
266- @Test
267256 void testClosureDelegate () {
268257 assertScript '''
269258 // tag::delegate_is_owner[]
@@ -317,7 +306,6 @@ class ClosuresSpecTest {
317306 '''
318307 }
319308
320- @Test
321309 void testDelegationStrategy () {
322310 assertScript '''
323311 // tag::delegation_strategy_intro[]
@@ -332,7 +320,6 @@ class ClosuresSpecTest {
332320 '''
333321 }
334322
335- @Test
336323 void testOwnerFirst () {
337324 assertScript '''
338325 // tag::closure_owner_first[]
@@ -362,7 +349,6 @@ class ClosuresSpecTest {
362349 '''
363350 }
364351
365- @Test
366352 void testDelegateOnly () {
367353 assertScript '''
368354 // tag::delegate_only[]
@@ -397,7 +383,6 @@ class ClosuresSpecTest {
397383 '''
398384 }
399385
400- @Test
401386 void testDelegateOnlyPropertyMissing () {
402387 assertScript '''
403388 // tag::delegate_only_prop_missing[]
@@ -423,7 +408,6 @@ class ClosuresSpecTest {
423408 '''
424409 }
425410
426- @Test
427411 void testGStringEager () {
428412 // tag::gstring_eager_intro[]
429413 def x = 1
@@ -440,7 +424,6 @@ class ClosuresSpecTest {
440424 assert gs == ' x = 1'
441425 }
442426
443- @Test
444427 void testGStringLazy () {
445428 // tag::gstring_lazy[]
446429 def x = 1
@@ -452,7 +435,6 @@ class ClosuresSpecTest {
452435 // end::gstring_lazy[]
453436 }
454437
455- @Test
456438 void testGStringWithMutation () {
457439 assertScript '''
458440 // tag::gstring_mutation[]
@@ -473,7 +455,6 @@ class ClosuresSpecTest {
473455 '''
474456 }
475457
476- @Test
477458 void testGStringWithoutMutation () {
478459 assertScript '''
479460 // tag::gstring_no_mutation[]
@@ -493,7 +474,6 @@ class ClosuresSpecTest {
493474 '''
494475 }
495476
496- @Test
497477 void testLeftCurry () {
498478 // tag::left_curry[]
499479 def nCopies = { int n , String str -> str* n } // <1>
@@ -503,7 +483,6 @@ class ClosuresSpecTest {
503483 // end::left_curry[]
504484 }
505485
506- @Test
507486 void testRightCurry () {
508487 // tag::right_curry[]
509488 def nCopies = { int n , String str -> str* n } // <1>
@@ -513,7 +492,6 @@ class ClosuresSpecTest {
513492 // end::right_curry[]
514493 }
515494
516- @Test
517495 void testNCurry () {
518496 // tag::ncurry[]
519497 def volume = { double l , double w , double h -> l* w* h } // <1>
@@ -524,7 +502,6 @@ class ClosuresSpecTest {
524502 // end::ncurry[]
525503 }
526504
527- @Test
528505 void testMemoize () {
529506 // tag::naive_fib[]
530507 def fib
@@ -537,7 +514,6 @@ class ClosuresSpecTest {
537514 // end::memoized_fib[]
538515 }
539516
540- @Test
541517 void testComposition () {
542518 // tag::closure_composition[]
543519 def plus2 = { it + 2 }
@@ -557,7 +533,6 @@ class ClosuresSpecTest {
557533
558534 }
559535
560- @Test
561536 void testTrampoline () {
562537 // tag::trampoline[]
563538 def factorial
0 commit comments