Skip to content

Commit

Permalink
[Groovy3] isGroovy3() -> isGroovy3orNewer()
Browse files Browse the repository at this point in the history
  • Loading branch information
szpak committed Feb 8, 2020
1 parent c5e2c44 commit 5def0a9
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Object intercept(Object target, Method method, Object[] arguments, IRespo
return GroovyRuntimeUtil.invokeMethod(target, methodName, GroovyRuntimeUtil.asArgumentArray(normalizedArgs[1]));
}
}
if (GroovyRuntimeUtil.isGroovy3()) {
if (GroovyRuntimeUtil.isGroovy3orNewer()) {
//The following works fine also for Groovy 2, but it's somehow ugly and fragile, so used only for Groovy 3 it limits potential negative
//impact on Spock users. It should be replaced with something more reliable: https://github.com/spockframework/spock/issues/1076
if (isMethod(method, "getProperty", String.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,8 @@ public static boolean isGroovy2() {
}

@Internal
public static boolean isGroovy3() {
//In fact it is "isNotGroovy2()", but "isGroovy3()" sounds better and before Groovy 4 is on the horizon it leads to the same
//With "startsWith("3.") there could be (in the future) no tests executed at all for Groovy 4
public static boolean isGroovy3orNewer() {
//Having isGroovy3() with just "startsWith("3.") there could be (in the future) no tests executed at all for Groovy 4
return !isGroovy2();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ println( List )
node3.lastColumnNumber == 17 // should be: 15
}
@Requires({ GroovyRuntimeUtil.isGroovy3() })
@Requires({ GroovyRuntimeUtil.isGroovy3orNewer() })
def "short-form class literals have accurate line/column info"() {
inspector.load("""
List
Expand Down Expand Up @@ -154,7 +154,7 @@ List.class.methods
node2.lastColumnNumber == 11
}
@Requires({ GroovyRuntimeUtil.isGroovy3() })
@Requires({ GroovyRuntimeUtil.isGroovy3orNewer() })
def "long-form class literals have accurate line/column info"() {
inspector.load("""
List.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ x++ == null
}
}

@Requires({ GroovyRuntimeUtil.isGroovy3() })
@Requires({ GroovyRuntimeUtil.isGroovy3orNewer() })
def "PostfixExpression"() {
expect:
isRendered """
Expand Down Expand Up @@ -570,7 +570,7 @@ java.util./*.awt.*/List == java.lang.String // I. Like. Dots.
}
}

@Requires({ GroovyRuntimeUtil.isGroovy3() })
@Requires({ GroovyRuntimeUtil.isGroovy3orNewer() })
def "ClassExpression with dot-containing comments"() {
expect:
isRendered """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ x == 123
}
}
@Requires({ GroovyRuntimeUtil.isGroovy3() })
@Requires({ GroovyRuntimeUtil.isGroovy3orNewer() })
def "values with same literal representations"() {
expect:
isRendered """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ assert x $op 42
op << ["=", "+=", "-="]
}
@PendingFeatureIf(value = { GroovyRuntimeUtil.isGroovy3() }, exceptions = WrongExceptionThrownError,
@PendingFeatureIf(value = { GroovyRuntimeUtil.isGroovy3orNewer() }, exceptions = WrongExceptionThrownError,
reason = "+= and -= are allowed in Groovy 3, to be precised at Groovy side")
@Issue("https://issues.apache.org/jira/browse/GROOVY-9360")
def "assignment arithmetic operators are not allowed in explicit conditions"() {
Expand All @@ -102,7 +102,7 @@ assert x $op 42
op << ["+=", "-="]
}
@Requires({ GroovyRuntimeUtil.isGroovy3() })
@Requires({ GroovyRuntimeUtil.isGroovy3orNewer() })
def "assignments are not allowed in explicit conditions"() {
when:
compiler.compileFeatureBody("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class JavaMocksForGroovyClasses extends Specification {
}
// TODO: swallowed when mocking static inner class because the latter implements methodMissing/propertyMissing
@Requires({ GroovyRuntimeUtil.isGroovy3() })
@Requires({ GroovyRuntimeUtil.isGroovy3orNewer() })
@FailsWith(MissingMethodException)
def "dynamic properties are considered to not exist"() {
when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class JavaStubs extends Specification {
}
@Issue("https://github.com/spockframework/spock/issues/1076")
@Requires({ GroovyRuntimeUtil.isGroovy3() })
@Requires({ GroovyRuntimeUtil.isGroovy3orNewer() })
def "can stub property access for implicit getProperty() call"() {
given:
person = Stub(Person)
Expand Down

0 comments on commit 5def0a9

Please sign in to comment.